[improvement] rename packages dir to src (#3659)

This commit is contained in:
neverland
2019-06-27 11:25:57 +08:00
committed by GitHub
parent 8489918dca
commit 75c79b7044
619 changed files with 21 additions and 21 deletions
+52
View File
@@ -0,0 +1,52 @@
<template>
<demo-section>
<demo-block :title="$t('basicUsage')">
<van-panel
:title="$t('title')"
:desc="$t('desc')"
:status="$t('status')"
>
<div>{{ $t('content') }}</div>
</van-panel>
</demo-block>
<demo-block :title="$t('advancedUsage')">
<van-panel
:title="$t('title')"
:desc="$t('desc')"
:status="$t('status')"
>
<div>{{ $t('content') }}</div>
<template #footer>
<van-button size="small">{{ $t('button') }}</van-button>
<van-button
size="small"
type="danger"
>
{{ $t('button') }}
</van-button>
</template>
</van-panel>
</demo-block>
</demo-section>
</template>
<script>
export default {};
</script>
<style lang="less">
.demo-panel {
.van-panel__footer {
text-align: right;
.van-button {
margin-left: 5px;
}
}
.van-panel__content {
padding: 20px;
}
}
</style>
+50
View File
@@ -0,0 +1,50 @@
# Panel
### Install
``` javascript
import { Panel } from 'vant';
Vue.use(Panel);
```
## Usage
### Basic Usage
```html
<van-panel title="Title" desc="Description" status="Status">
<div>Content</div>
</van-panel>
```
### Advanced Usage
```html
<van-panel title="Title" desc="Description" status="Status">
<div>Content</div>
<div slot="footer">
<van-button size="small">Button</van-button>
<van-button size="small" type="danger">Button</van-button>
</div>
</van-panel>
```
## API
### Props
| Attribute | Description | Type | Default |
|------|------|------|------|
| icon | Left Icon | `String` | - |
| title | Title | `String` | - |
| desc | Description | `String` | - |
| status | Status | `String` | - |
### Slots
| Name | Description |
|------|------|
| default | Default slot |
| header | Custom header |
| footer | Custom footer |
+13
View File
@@ -0,0 +1,13 @@
@import '../style/var';
.van-panel {
background: @panel-background-color;
&__header-value {
color: @panel-header-value-color;
}
&__footer {
padding: @panel-footer-padding;
}
}
+65
View File
@@ -0,0 +1,65 @@
import { createNamespace } from '../utils';
import Cell from '../cell';
import CellGroup from '../cell-group';
import { inherit } from '../utils/functional';
// Types
import { CreateElement, RenderContext } from 'vue/types';
import { ScopedSlot, DefaultSlots } from '../utils/types';
export type PanelProps = {
icon?: string;
desc?: string;
title?: string;
status?: string;
};
export type PanelSlots = DefaultSlots & {
header?: ScopedSlot;
footer?: ScopedSlot;
};
const [createComponent, bem] = createNamespace('panel');
function Panel(
h: CreateElement,
props: PanelProps,
slots: PanelSlots,
ctx: RenderContext<PanelProps>
) {
const Content = () => [
slots.header ? (
slots.header()
) : (
<Cell
icon={props.icon}
label={props.desc}
title={props.title}
value={props.status}
class={bem('header')}
valueClass={bem('header-value')}
/>
),
<div class={bem('content')}>{slots.default && slots.default()}</div>,
slots.footer && (
<div class={[bem('footer'), 'van-hairline--top']}>{slots.footer()}</div>
)
];
return (
<CellGroup
class={bem()}
scopedSlots={{ default: Content }}
{...inherit(ctx, true)}
/>
);
}
Panel.props = {
icon: String,
desc: String,
title: String,
status: String
};
export default createComponent<PanelProps>(Panel);
@@ -0,0 +1,35 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`renders demo correctly 1`] = `
<div>
<div>
<div class="van-cell-group van-hairline--top-bottom van-panel">
<div class="van-cell van-panel__header">
<div class="van-cell__title"><span>标题</span>
<div class="van-cell__label">描述信息</div>
</div>
<div class="van-cell__value van-panel__header-value"><span>状态</span></div>
</div>
<div class="van-panel__content">
<div>内容</div>
</div>
</div>
</div>
<div>
<div class="van-cell-group van-hairline--top-bottom van-panel">
<div class="van-cell van-panel__header">
<div class="van-cell__title"><span>标题</span>
<div class="van-cell__label">描述信息</div>
</div>
<div class="van-cell__value van-panel__header-value"><span>状态</span></div>
</div>
<div class="van-panel__content">
<div>内容</div>
</div>
<div class="van-panel__footer van-hairline--top"><button class="van-button van-button--default van-button--small"><span class="van-button__text">按钮</span></button> <button class="van-button van-button--danger van-button--small"><span class="van-button__text">
按钮
</span></button></div>
</div>
</div>
</div>
`;
+4
View File
@@ -0,0 +1,4 @@
import Demo from '../demo';
import demoTest from '../../../test/demo-test';
demoTest(Demo);
+54
View File
@@ -0,0 +1,54 @@
# Panel 面板
### 引入
``` javascript
import { Panel } from 'vant';
Vue.use(Panel);
```
## 代码演示
### 基础用法
面板只是一个容器,里面可以放入自定义的内容
```html
<van-panel title="标题" desc="描述信息" status="状态">
<div>内容</div>
</van-panel>
```
### 高级用法
使用`slot`自定义内容
```html
<van-panel title="标题" desc="描述信息" status="状态">
<div>内容</div>
<div slot="footer">
<van-button size="small">按钮</van-button>
<van-button size="small" type="danger">按钮</van-button>
</div>
</van-panel>
```
## API
### Props
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|------|------|------|------|------|
| title | 标题 | `String` | - | - |
| desc | 描述 | `String` | - | - |
| status | 状态 | `String` | - | - |
| icon | 标题左侧图标名称或图片链接,可选值见 Icon 组件 | `String` | - | 1.3.8 |
### Slots
| 名称 | 说明 |
|------|------|
| default | 自定义内容 |
| header | 自定义 header |
| footer | 自定义 footer |