From fe89e18a24b281511f784c45c6574adc9e599cf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=98=89=E6=B6=B5?= Date: Mon, 29 Apr 2019 14:17:47 +0800 Subject: [PATCH 01/12] [Doc] add progress tracking document --- docs/markdown/v2-progress-tracking.md | 45 +++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 docs/markdown/v2-progress-tracking.md diff --git a/docs/markdown/v2-progress-tracking.md b/docs/markdown/v2-progress-tracking.md new file mode 100644 index 000000000..c15ffcb36 --- /dev/null +++ b/docs/markdown/v2-progress-tracking.md @@ -0,0 +1,45 @@ +## Vant 2.0 + +### Actionsheet + +- [ ] 重命名为 ActionSheet + +### Button + +- [ ] 移除 bottom-action 属性 + +### Field + +- [ ] icon 属性重命名为 right-icon +- [ ] icon 插槽重命名为 right-icon + +### GoodsAction + +- [ ] GoodsActionBigBtn 重命名为 GoodsActionButton +- [ ] GoodsActionMiniBtn 重命名为 GoodsActionIcon + +### Step + +- [ ] 移除 icon 属性 +- [ ] 移除 title 属性 +- [ ] 移除 iconClass 属性 +- [ ] 移除 description 属性 +- [ ] 移除 message-extra 插槽 + +### Badge + +- [ ] 重命名为 SideNav + +### Loading + +- [ ] 移除 circle 类型 +- [ ] 移除 gradient-circle 类型 + +### Area + +- [ ] 数据结构改驼峰 + +### SwipeCell + +- [ ] 移除 left-width 属性 +- [ ] 移除 right-width 属性 From b8424f8de92d71a73f3e5e67ac08f6ed29db2564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=98=89=E6=B6=B5?= Date: Mon, 29 Apr 2019 14:20:00 +0800 Subject: [PATCH 02/12] [breaking change] Actionsheet: rename to ActionSheet --- docs/markdown/changelog.en-US.md | 30 +++++++++---------- docs/markdown/changelog.zh-CN.md | 30 +++++++++---------- docs/markdown/v2-progress-tracking.md | 2 +- docs/src/demo-entry.js | 2 +- docs/src/doc.config.js | 8 ++--- docs/src/docs-entry.js | 4 +-- .../demo/index.vue | 30 +++++++++---------- .../{actionsheet => action-sheet}/en-US.md | 24 +++++++-------- .../{actionsheet => action-sheet}/index.less | 2 +- .../{actionsheet => action-sheet}/index.tsx | 22 +++++++------- .../test/__snapshots__/demo.spec.js.snap | 6 ++-- .../test/__snapshots__/index.spec.js.snap | 17 +++++++++++ .../test/demo.spec.js | 0 .../test/index.spec.js | 12 ++++---- .../{actionsheet => action-sheet}/zh-CN.md | 22 +++++++------- .../test/__snapshots__/index.spec.js.snap | 17 ----------- packages/index.less | 2 +- packages/index.ts | 6 ++-- types/index.d.ts | 2 +- 19 files changed, 119 insertions(+), 119 deletions(-) rename packages/{actionsheet => action-sheet}/demo/index.vue (74%) rename packages/{actionsheet => action-sheet}/en-US.md (79%) rename packages/{actionsheet => action-sheet}/index.less (98%) rename packages/{actionsheet => action-sheet}/index.tsx (85%) rename packages/{actionsheet => action-sheet}/test/__snapshots__/demo.spec.js.snap (80%) create mode 100644 packages/action-sheet/test/__snapshots__/index.spec.js.snap rename packages/{actionsheet => action-sheet}/test/demo.spec.js (100%) rename packages/{actionsheet => action-sheet}/test/index.spec.js (81%) rename packages/{actionsheet => action-sheet}/zh-CN.md (86%) delete mode 100644 packages/actionsheet/test/__snapshots__/index.spec.js.snap diff --git a/docs/markdown/changelog.en-US.md b/docs/markdown/changelog.en-US.md index 78d8be853..ecf3fc0d2 100644 --- a/docs/markdown/changelog.en-US.md +++ b/docs/markdown/changelog.en-US.md @@ -34,7 +34,7 @@ - Tabbar: add safe-area-inset-bottom prop [\#3149](https://github.com/youzan/vant/pull/3149) - SubmitBar: add safe-area-inset-bottom prop [\#3172](https://github.com/youzan/vant/pull/3172) - GoodsAction: add safe-area-inset-bottom prop [\#3174](https://github.com/youzan/vant/pull/3174) -- Actionsheet: add safe-area-inset-bottom prop [\#3171](https://github.com/youzan/vant/pull/3171) +- ActionSheet: add safe-area-inset-bottom prop [\#3171](https://github.com/youzan/vant/pull/3171) - NumberKeyboard: add safe-area-inset-bottom prop [\#3173](https://github.com/youzan/vant/pull/3173) **Bug Fixes** @@ -89,7 +89,7 @@ **Improvements** -- Actionsheet: add less vars [\#3049](https://github.com/youzan/vant/pull/3049) +- ActionSheet: add less vars [\#3049](https://github.com/youzan/vant/pull/3049) **Bug Fixes** @@ -112,7 +112,7 @@ - NoticeBar: add wrapable prop [\#2992](https://github.com/youzan/vant/pull/2992) - Field: add error-message-align prop [\#3016](https://github.com/youzan/vant/pull/3016) - Sku: support set selectedNum when inited [\#3045](https://github.com/youzan/vant/pull/3045) -- Actionsheet: support use slot and cancel-text at same time [\#3021](https://github.com/youzan/vant/pull/3021) +- ActionSheet: support use slot and cancel-text at same time [\#3021](https://github.com/youzan/vant/pull/3021) **Bug Fixes** @@ -152,7 +152,7 @@ - CellGroup: add title prop [\#2928](https://github.com/youzan/vant/pull/2928) - Steps: add active-icon prop [\#2934](https://github.com/youzan/vant/pull/2934) - Picker: add default-index prop [\#2935](https://github.com/youzan/vant/pull/2935) -- Actionsheet: add index param for select event [\#2917](https://github.com/youzan/vant/pull/2917) +- ActionSheet: add index param for select event [\#2917](https://github.com/youzan/vant/pull/2917) **Bug Fixes** @@ -188,8 +188,8 @@ **Bug Fixes** -- fix Actionsheet lazy-render not work [\#2840](https://github.com/youzan/vant/pull/2840) -- fix Actionsheet get-container not work [\#2853](https://github.com/youzan/vant/pull/2853) +- fix ActionSheet lazy-render not work [\#2840](https://github.com/youzan/vant/pull/2840) +- fix ActionSheet get-container not work [\#2853](https://github.com/youzan/vant/pull/2853) - fix Tab should scroll to active tab when inited [\#2857](https://github.com/youzan/vant/pull/2857) - fix Checkbox uncheckable when inside cell [\#2855](https://github.com/youzan/vant/pull/2855) - fix CouponList incorrectly render when disabled list empty [\#2845](https://github.com/youzan/vant/pull/2845) @@ -873,14 +873,14 @@ Also we have optimized the UI of the following components:: **Improvements** -- Actionsheet: add select event [\#1594](https://github.com/youzan/vant/pull/1594) +- ActionSheet: add select event [\#1594](https://github.com/youzan/vant/pull/1594) - ImagePreview: suppot onClose callback [\#1589](https://github.com/youzan/vant/pull/1589) - List: add check method [\#1590](https://github.com/youzan/vant/pull/1590) - Search: update style [\#1603](https://github.com/youzan/vant/pull/1603) **Bug Fixes** -- fix Actionsheet item unclickable when loading [\#1587](https://github.com/youzan/vant/pull/1587) +- fix ActionSheet item unclickable when loading [\#1587](https://github.com/youzan/vant/pull/1587) - fix DatetimePicker value uncorrect when use formatter [\#1591](https://github.com/youzan/vant/pull/1591) @@ -970,7 +970,7 @@ Also we have optimized the UI of the following components:: **Improvements** -- Actionsheet: support lazy render [\#1365](https://github.com/youzan/vant/pull/1365) +- ActionSheet: support lazy render [\#1365](https://github.com/youzan/vant/pull/1365) - AddressEdit: adjust event order [\#1402](https://github.com/youzan/vant/pull/1402) - SwitchCell: add size prop [\#1371](https://github.com/youzan/vant/pull/1371) - Checkbox: add label-position prop [\#1394](https://github.com/youzan/vant/pull/1394) @@ -1015,7 +1015,7 @@ Also we have optimized the UI of the following components:: **Improvements** -- Actionsheet: support disable option [\#1293](https://github.com/youzan/vant/pull/1293) +- ActionSheet: support disable option [\#1293](https://github.com/youzan/vant/pull/1293) - Field: support clearable [\#1309](https://github.com/youzan/vant/pull/1309) - Layout: support flex layout [\#1305](https://github.com/youzan/vant/pull/1305) - Locale: add type definition [\#1294](https://github.com/youzan/vant/pull/1294) @@ -1046,7 +1046,7 @@ Also we have optimized the UI of the following components:: **Bug Fixes** -- fix Actionsheet title font size [\#1267](https://github.com/youzan/vant/pull/1267) +- fix ActionSheet title font size [\#1267](https://github.com/youzan/vant/pull/1267) - fix CheckboxGroup v-model type check [\#1254](https://github.com/youzan/vant/pull/1254) - fix Popup max height [\#1256](https://github.com/youzan/vant/pull/1256) - fix Tab resize line when title changed [\#1260](https://github.com/youzan/vant/pull/1260) @@ -1273,8 +1273,8 @@ Also we have optimized the UI of the following components:: **Improvements** -* Actionsheet: add cancel event [\#796](https://github.com/youzan/vant/pull/796) -* Actionsheet: support maxHeight [\#777](https://github.com/youzan/vant/pull/777) +* ActionSheet: add cancel event [\#796](https://github.com/youzan/vant/pull/796) +* ActionSheet: support maxHeight [\#777](https://github.com/youzan/vant/pull/777) * DatetimePicker: support all picker props [\#788](https://github.com/youzan/vant/pull/788) * SubmitBar: unite font-size [\#774](https://github.com/youzan/vant/pull/774) * i18n: support zh-HK language [\#812](https://github.com/youzan/vant/pull/812) @@ -1359,7 +1359,7 @@ Also we have optimized the UI of the following components:: **Bug Fixes** -* fix Actionsheet bottom border missing [\#686](https://github.com/youzan/vant/pull/686) +* fix ActionSheet bottom border missing [\#686](https://github.com/youzan/vant/pull/686) * fix AddressEdit area not selected when area_code changed [\#680](https://github.com/youzan/vant/pull/680) * fix Stepper value overlimit [\#691](https://github.com/youzan/vant/issues/691) * fix Badge info font weight when selected [\#687](https://github.com/youzan/vant/pull/687) @@ -1781,7 +1781,7 @@ Also we have optimized the UI of the following components:: **Improvements** -* Actionsheet: update close icon style [\#340](https://github.com/youzan/vant/pull/340) +* ActionSheet: update close icon style [\#340](https://github.com/youzan/vant/pull/340) * Popup: add overlayClass and overlayStyle props [\#349](https://github.com/youzan/vant/pull/349) [\#343](https://github.com/youzan/vant/pull/343) * Icon: adjust unicode for better display [\#330](https://github.com/youzan/vant/pull/330) * ImagePreview: support manually close [\#346](https://github.com/youzan/vant/pull/346) diff --git a/docs/markdown/changelog.zh-CN.md b/docs/markdown/changelog.zh-CN.md index a6137baa8..674be9ea2 100644 --- a/docs/markdown/changelog.zh-CN.md +++ b/docs/markdown/changelog.zh-CN.md @@ -34,7 +34,7 @@ - Tabbar: 新增 safe-area-inset-bottom 属性 [\#3149](https://github.com/youzan/vant/pull/3149) - SubmitBar: 新增 safe-area-inset-bottom 属性 [\#3172](https://github.com/youzan/vant/pull/3172) - GoodsAction: 新增 safe-area-inset-bottom 属性 [\#3174](https://github.com/youzan/vant/pull/3174) -- Actionsheet: 新增 safe-area-inset-bottom 属性 [\#3171](https://github.com/youzan/vant/pull/3171) +- ActionSheet: 新增 safe-area-inset-bottom 属性 [\#3171](https://github.com/youzan/vant/pull/3171) - NumberKeyboard: 新增 safe-area-inset-bottom 属性 [\#3173](https://github.com/youzan/vant/pull/3173) **Bug Fixes** @@ -89,7 +89,7 @@ **Improvements** -- Actionsheet: 新增 less 变量 [\#3049](https://github.com/youzan/vant/pull/3049) +- ActionSheet: 新增 less 变量 [\#3049](https://github.com/youzan/vant/pull/3049) **Bug Fixes** @@ -112,7 +112,7 @@ - NoticeBar: 新增 wrapable 属性 [\#2992](https://github.com/youzan/vant/pull/2992) - Field: 新增 error-message-align 属性 [\#3016](https://github.com/youzan/vant/pull/3016) - Sku: 支持在初始化时设置选中商品数量 [\#3045](https://github.com/youzan/vant/pull/3045) -- Actionsheet: 支持同时设置默认插槽和 cancel-text [\#3021](https://github.com/youzan/vant/pull/3021) +- ActionSheet: 支持同时设置默认插槽和 cancel-text [\#3021](https://github.com/youzan/vant/pull/3021) **Bug Fixes** @@ -152,7 +152,7 @@ - CellGroup: 新增 title 属性 [\#2928](https://github.com/youzan/vant/pull/2928) - Steps: 新增 active-icon 属性 [\#2934](https://github.com/youzan/vant/pull/2934) - Picker: 新增 default-index 属性 [\#2935](https://github.com/youzan/vant/pull/2935) -- Actionsheet: 新增 index 作为 select 事件的回调参数 [\#2917](https://github.com/youzan/vant/pull/2917) +- ActionSheet: 新增 index 作为 select 事件的回调参数 [\#2917](https://github.com/youzan/vant/pull/2917) **Bug Fixes** @@ -188,8 +188,8 @@ **Bug Fixes** -- 修复 Actionsheet lazy-render 属性不生效的问题 [\#2840](https://github.com/youzan/vant/pull/2840) -- 修复 Actionsheet get-container 属性不生效的问题 [\#2853](https://github.com/youzan/vant/pull/2853) +- 修复 ActionSheet lazy-render 属性不生效的问题 [\#2840](https://github.com/youzan/vant/pull/2840) +- 修复 ActionSheet get-container 属性不生效的问题 [\#2853](https://github.com/youzan/vant/pull/2853) - 修复 Tab 初始化时导航栏未自动滚动到当前标签位置的问题 [\#2857](https://github.com/youzan/vant/pull/2857) - 修复 Checkbox 与 Cell 组件嵌套用法在 Vue 2.6+ 上的兼容问题 [\#2855](https://github.com/youzan/vant/pull/2855) - 修复 CouponList 不可用券列表为空时展示错误的问题 [\#2845](https://github.com/youzan/vant/pull/2845) @@ -875,14 +875,14 @@ PS: 不小心跳过了 1.4.6 版本 ^_^ **Improvements** -- Actionsheet: 新增 select 事件 [\#1594](https://github.com/youzan/vant/pull/1594) +- ActionSheet: 新增 select 事件 [\#1594](https://github.com/youzan/vant/pull/1594) - ImagePreview: 支持传入 onClose 回调函数 [\#1589](https://github.com/youzan/vant/pull/1589) - List: 新增 check 方法 [\#1590](https://github.com/youzan/vant/pull/1590) - Search: 优化样式结构 [\#1603](https://github.com/youzan/vant/pull/1603) **Bug Fixes** -- 修复 Actionsheet 选项加载中时仍然有点击态的问题 [\#1587](https://github.com/youzan/vant/pull/1587) +- 修复 ActionSheet 选项加载中时仍然有点击态的问题 [\#1587](https://github.com/youzan/vant/pull/1587) - 修复 DatetimePicker 使用 formatter 时默认值错误的问题 [\#1591](https://github.com/youzan/vant/pull/1591) @@ -970,7 +970,7 @@ PS: 不小心跳过了 1.4.6 版本 ^_^ **Improvements** -- Actionsheet: 支持 lazy-render [\#1365](https://github.com/youzan/vant/pull/1365) +- ActionSheet: 支持 lazy-render [\#1365](https://github.com/youzan/vant/pull/1365) - AddressEdit: 优化事件触发顺序 [\#1402](https://github.com/youzan/vant/pull/1402) - SwitchCell: 新增 size 属性 [\#1371](https://github.com/youzan/vant/pull/1371) - Checkbox: 新增 label-position 属性 [\#1394](https://github.com/youzan/vant/pull/1394) @@ -1015,7 +1015,7 @@ PS: 不小心跳过了 1.4.6 版本 ^_^ **Improvements** -- Actionsheet: 支持禁用选项 [\#1293](https://github.com/youzan/vant/pull/1293) +- ActionSheet: 支持禁用选项 [\#1293](https://github.com/youzan/vant/pull/1293) - Field: 支持展示清除控件 [\#1309](https://github.com/youzan/vant/pull/1309) - Layout: 支持 Flex 布局 [\#1305](https://github.com/youzan/vant/pull/1305) - Locale: 新增 TS 类型定义 [\#1294](https://github.com/youzan/vant/pull/1294) @@ -1046,7 +1046,7 @@ PS: 不小心跳过了 1.4.6 版本 ^_^ **Bug Fixes** -- 修复 Actionsheet 在 rem 布局下标题文字大小错误的问题 [\#1267](https://github.com/youzan/vant/pull/1267) +- 修复 ActionSheet 在 rem 布局下标题文字大小错误的问题 [\#1267](https://github.com/youzan/vant/pull/1267) - 修复 CheckboxGroup v-model 类型检查错误 [\#1254](https://github.com/youzan/vant/pull/1254) - 修复 Tab 标题长度变化时底部条未重新渲染的问题 [\#1260](https://github.com/youzan/vant/pull/1260) - 修复 Popup 内容过高时超出屏幕可视范围的问题 [\#1256](https://github.com/youzan/vant/pull/1256) @@ -1269,8 +1269,8 @@ PS: 不小心跳过了 1.4.6 版本 ^_^ **Improvements** -- Actionsheet: 新增 cancel 事件 [\#796](https://github.com/youzan/vant/pull/796) -- Actionsheet: 增加最大高度限制 [\#777](https://github.com/youzan/vant/pull/777) +- ActionSheet: 新增 cancel 事件 [\#796](https://github.com/youzan/vant/pull/796) +- ActionSheet: 增加最大高度限制 [\#777](https://github.com/youzan/vant/pull/777) - DatetimePicker: 支持所有 picker 组件配置 [\#788](https://github.com/youzan/vant/pull/788) - SubmitBar: 统一文字大小 [\#774](https://github.com/youzan/vant/pull/774) - i18n: 支持 zh-HK 语言 [\#812](https://github.com/youzan/vant/pull/812) @@ -1353,7 +1353,7 @@ PS: 不小心跳过了 1.4.6 版本 ^_^ **Bug Fixes** -* 修复 Actionsheet 下边框未展示的问题 [\#686](https://github.com/youzan/vant/pull/686) +* 修复 ActionSheet 下边框未展示的问题 [\#686](https://github.com/youzan/vant/pull/686) * 修复 AddressEdit 在数据变更时未正确选中省市区的问题 [\#680](https://github.com/youzan/vant/pull/680) * 修复 Stepper value 溢出的问题 [\#691](https://github.com/youzan/vant/issues/691) * 修复 Badge 选中时字体粗细 [\#687](https://github.com/youzan/vant/pull/687) @@ -1774,7 +1774,7 @@ PS: 不小心跳过了 1.4.6 版本 ^_^ **Improvements** -* Actionsheet: 更新关闭按钮样式 [\#340](https://github.com/youzan/vant/pull/340) +* ActionSheet: 更新关闭按钮样式 [\#340](https://github.com/youzan/vant/pull/340) * Popup: 新增 overlayClass、overlayStyle 属性 [\#349](https://github.com/youzan/vant/pull/349) [\#343](https://github.com/youzan/vant/pull/343) * Icon: 调整 unicode,避免展示特殊字符 [\#330](https://github.com/youzan/vant/pull/330) * ImagePreview: 支持手动关闭 [\#346](https://github.com/youzan/vant/pull/346) diff --git a/docs/markdown/v2-progress-tracking.md b/docs/markdown/v2-progress-tracking.md index c15ffcb36..8e3974b47 100644 --- a/docs/markdown/v2-progress-tracking.md +++ b/docs/markdown/v2-progress-tracking.md @@ -2,7 +2,7 @@ ### Actionsheet -- [ ] 重命名为 ActionSheet +- [x] 重命名为 ActionSheet ### Button diff --git a/docs/src/demo-entry.js b/docs/src/demo-entry.js index 3549f9b06..52cb85d30 100644 --- a/docs/src/demo-entry.js +++ b/docs/src/demo-entry.js @@ -3,7 +3,7 @@ import { wrapper } from './demo-common'; export default { - 'actionsheet': () => wrapper(import('../../packages/actionsheet/demo'), 'actionsheet'), + 'action-sheet': () => wrapper(import('../../packages/action-sheet/demo'), 'action-sheet'), 'address-edit': () => wrapper(import('../../packages/address-edit/demo'), 'address-edit'), 'address-list': () => wrapper(import('../../packages/address-list/demo'), 'address-list'), 'area': () => wrapper(import('../../packages/area/demo'), 'area'), diff --git a/docs/src/doc.config.js b/docs/src/doc.config.js index dea1e0dfa..37ca5347b 100644 --- a/docs/src/doc.config.js +++ b/docs/src/doc.config.js @@ -168,8 +168,8 @@ module.exports = { icon: 'passed', list: [ { - path: '/actionsheet', - title: 'Actionsheet 上拉菜单' + path: '/action-sheet', + title: 'ActionSheet 上拉菜单' }, { path: '/dialog', @@ -475,8 +475,8 @@ module.exports = { icon: 'passed', list: [ { - path: '/actionsheet', - title: 'Actionsheet' + path: '/action-sheet', + title: 'ActionSheet' }, { path: '/dialog', diff --git a/docs/src/docs-entry.js b/docs/src/docs-entry.js index 80bb7857a..41b7d784f 100644 --- a/docs/src/docs-entry.js +++ b/docs/src/docs-entry.js @@ -12,8 +12,8 @@ export default { 'style-guide.zh-CN': () => import('../markdown/style-guide.zh-CN.md'), 'theme.en-US': () => import('../markdown/theme.en-US.md'), 'theme.zh-CN': () => import('../markdown/theme.zh-CN.md'), - 'actionsheet.en-US': () => import('../../packages/actionsheet/en-US.md'), - 'actionsheet.zh-CN': () => import('../../packages/actionsheet/zh-CN.md'), + 'action-sheet.en-US': () => import('../../packages/action-sheet/en-US.md'), + 'action-sheet.zh-CN': () => import('../../packages/action-sheet/zh-CN.md'), 'address-edit.en-US': () => import('../../packages/address-edit/en-US.md'), 'address-edit.zh-CN': () => import('../../packages/address-edit/zh-CN.md'), 'address-list.en-US': () => import('../../packages/address-list/en-US.md'), diff --git a/packages/actionsheet/demo/index.vue b/packages/action-sheet/demo/index.vue similarity index 74% rename from packages/actionsheet/demo/index.vue rename to packages/action-sheet/demo/index.vue index 2136a089f..8e0b8a860 100644 --- a/packages/actionsheet/demo/index.vue +++ b/packages/action-sheet/demo/index.vue @@ -2,7 +2,7 @@ {{ $t('button1') }} - {{ $t('button2') }} - {{ $t('button3') }} -

{{ $t('content') }}

-
+
@@ -36,20 +36,20 @@ export default { i18n: { 'zh-CN': { - button1: '弹出 Actionsheet', - button2: '弹出带取消按钮的 Actionsheet', - button3: '弹出带标题的 Actionsheet', - title2: '带取消按钮的 Actionsheet', - title3: '带标题的 Actionsheet', + button1: '弹出 ActionSheet', + button2: '弹出带取消按钮的 ActionSheet', + button3: '弹出带标题的 ActionSheet', + title2: '带取消按钮的 ActionSheet', + title3: '带标题的 ActionSheet', description: '描述信息', disabledOption: '禁用选项' }, 'en-US': { - button1: 'Show Actionsheet', - button2: 'Show Actionsheet with cancel button', - button3: 'Show Actionsheet with title', - title2: 'Actionsheet with cancel button', - title3: 'Actionsheet with title', + button1: 'Show ActionSheet', + button2: 'Show ActionSheet with cancel button', + button3: 'Show ActionSheet with title', + title2: 'ActionSheet with cancel button', + title3: 'ActionSheet with title', description: 'Description', disabledOption: 'Disabled Option' } @@ -89,7 +89,7 @@ export default { diff --git a/packages/waterfall/directive.js b/packages/waterfall/directive.js deleted file mode 100644 index 0e3716e46..000000000 --- a/packages/waterfall/directive.js +++ /dev/null @@ -1,133 +0,0 @@ -/* eslint-disable no-underscore-dangle */ -import { on, off } from '../utils/event'; -import { - getScrollTop, - getElementTop, - getVisibleHeight, - getScrollEventTarget -} from '../utils/scroll'; - -const CONTEXT = '@@Waterfall'; -const OFFSET = 300; - -// 处理滚动函数 -function handleScrollEvent() { - const element = this.el; - const { scrollEventTarget } = this; - // 已被禁止的滚动处理 - if (this.disabled) return; - - const targetScrollTop = getScrollTop(scrollEventTarget); - const targetVisibleHeight = getVisibleHeight(scrollEventTarget); - // 滚动元素可视区域下边沿到滚动元素元素最顶上 距离 - const targetBottom = targetScrollTop + targetVisibleHeight; - - // 如果无元素高度,考虑为元素隐藏,直接返回 - if (!targetVisibleHeight) return; - - // 判断是否到了底 - let needLoadMoreToLower = false; - if (element === scrollEventTarget) { - needLoadMoreToLower = scrollEventTarget.scrollHeight - targetBottom < this.offset; - } else { - const elementBottom = - getElementTop(element) - getElementTop(scrollEventTarget) + getVisibleHeight(element); - needLoadMoreToLower = elementBottom - targetVisibleHeight < this.offset; - } - if (needLoadMoreToLower) { - this.cb.lower && this.cb.lower({ target: scrollEventTarget, top: targetScrollTop }); - } - - // 判断是否到了顶 - let needLoadMoreToUpper = false; - if (element === scrollEventTarget) { - needLoadMoreToUpper = targetScrollTop < this.offset; - } else { - const elementTop = getElementTop(element) - getElementTop(scrollEventTarget); - needLoadMoreToUpper = elementTop + this.offset > 0; - } - if (needLoadMoreToUpper) { - this.cb.upper && this.cb.upper({ target: scrollEventTarget, top: targetScrollTop }); - } -} - -// 绑定事件到元素上 -// 读取基本的控制变量 -function doBindEvent() { - if (this.el[CONTEXT].binded) { - return; - } - this.el[CONTEXT].binded = true; - - this.scrollEventListener = handleScrollEvent.bind(this); - this.scrollEventTarget = getScrollEventTarget(this.el); - - const disabledExpr = this.el.getAttribute('waterfall-disabled'); - let disabled = false; - if (disabledExpr) { - this.vm.$watch(disabledExpr, value => { - this.disabled = value; - this.scrollEventListener(); - }); - disabled = Boolean(this.vm[disabledExpr]); - } - this.disabled = disabled; - - const offset = this.el.getAttribute('waterfall-offset'); - this.offset = Number(offset) || OFFSET; - - on(this.scrollEventTarget, 'scroll', this.scrollEventListener, true); - - this.scrollEventListener(); -} - -// 绑定事件 -function startBind(el) { - const context = el[CONTEXT]; - - context.vm.$nextTick(() => { - doBindEvent.call(el[CONTEXT]); - }); -} - -// 确认何时绑事件监听函数 -function doCheckStartBind(el) { - const context = el[CONTEXT]; - - if (context.vm._isMounted) { - startBind(el); - } else { - context.vm.$on('hook:mounted', () => { - startBind(el); - }); - } -} - -export default function (type) { - return { - bind(el, binding, vnode) { - if (!el[CONTEXT]) { - el[CONTEXT] = { - el, - vm: vnode.context, - cb: {} - }; - } - el[CONTEXT].cb[type] = binding.value; - - doCheckStartBind(el); - }, - - update(el) { - const context = el[CONTEXT]; - context.scrollEventListener && context.scrollEventListener(); - }, - - unbind(el) { - const context = el[CONTEXT]; - if (context.scrollEventTarget) { - off(context.scrollEventTarget, 'scroll', context.scrollEventListener); - } - } - }; -} diff --git a/packages/waterfall/en-US.md b/packages/waterfall/en-US.md deleted file mode 100644 index 7cff793bc..000000000 --- a/packages/waterfall/en-US.md +++ /dev/null @@ -1,77 +0,0 @@ -## Waterfall -Note: Waterfall is deprecated and no longer maintained, please use the [List](#/zh-CN/list) component instead. - -### Install - -#### Global registration - -```js -import Vue from 'vue'; -import { Waterfall } from 'vant'; - -Vue.use(Waterfall); -``` - -#### Local registration -If you just watch to use `Waterfall` in a component, you can register the directive in the component. - -```js -import { Waterfall } from 'vant'; - -export default { - directives: { - WaterfallLower: Waterfall('lower'), - WaterfallUpper: Waterfall('upper') - } -}; -``` - -### Usage - -#### Basic Usage - -```html - -``` - -```js -export default { - data() { - return { - list: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], - disabled: false - }; - }, - - directives: { - WaterfallLower: Waterfall('lower') - }, - - methods: { - loadMore() { - this.disabled = true; - setTimeout(() => { - for (let i = 0; i < 5; i++) { - this.list.push(this.list.length); - } - this.disabled = false; - }, 200); - } - } -}; -``` - -### API - -| Attribute | Description | Type | Default | -|------|------|------|------| -| v-waterfall-lower | Function to trigger when scroll to bottom | `Function` | - | -| v-waterfall-upper | Function to trigger when scroll to top | `Function` | - | -| waterfall-disabled | Key of the property to control disable status in instance | `String` | - | -| waterfall-offset | Offset to trigger callback function | `Number` | `300` | diff --git a/packages/waterfall/index.js b/packages/waterfall/index.js deleted file mode 100644 index a2b120669..000000000 --- a/packages/waterfall/index.js +++ /dev/null @@ -1,11 +0,0 @@ -import Waterfall from './directive'; - -Waterfall.install = function (Vue) { - if (process.env.NODE_ENV !== 'production') { - console.warn('[Vant] Waterfall is deprecated, please use List component instread'); - } - Vue.directive('WaterfallLower', Waterfall('lower')); - Vue.directive('WaterfallUpper', Waterfall('upper')); -}; - -export default Waterfall; diff --git a/packages/waterfall/zh-CN.md b/packages/waterfall/zh-CN.md deleted file mode 100644 index fe783340a..000000000 --- a/packages/waterfall/zh-CN.md +++ /dev/null @@ -1,81 +0,0 @@ -## Waterfall 瀑布流 -注意:Waterfall 组件已被废弃且不再维护,请使用 [List](#/zh-CN/list) 组件代替 - -### 使用指南 - -#### 全局注册 - -```js -import Vue from 'vue'; -import { Waterfall } from 'vant'; - -Vue.use(Waterfall); -``` - -#### 局部注册 - -如果你只是想在某个组件中使用`Waterfall`,可以在对应组件中注册`Waterfall`指令,这样只能在你注册的组件中使用`Waterfall`: - -```js -import { Waterfall } from 'vant'; - -export default { - directives: { - WaterfallLower: Waterfall('lower'), - WaterfallUpper: Waterfall('upper') - } -}; -``` - -### 代码演示 - -#### 基础用法 -使用 `v-waterfall-lower` 监听滚动到达底部,并执行相应函数。若是函数执行中需要异步加载数据,可以将 `waterfall-disabled` 指定的值置为 true,禁止 `v-waterfall-lower` 监听滚动事件 - -注意:`waterfall-disabled` 传入的是 vue 对象中表示是否禁止瀑布流触发 key 值,类型是字符串 - -```html - -``` - -```js -export default { - data() { - return { - list: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], - disabled: false - }; - }, - - directives: { - WaterfallLower: Waterfall('lower') - }, - - methods: { - loadMore() { - this.disabled = true; - setTimeout(() => { - for (let i = 0; i < 5; i++) { - this.list.push(this.list.length); - } - this.disabled = false; - }, 200); - } - } -}; -``` - -### API - -| 参数 | 说明 | 类型 | 默认值 | 版本 | -|------|------|------|------|------| -| v-waterfall-lower | 滚动到底部, 触发执行的函数 | `Function` | - | - | -| v-waterfall-upper | 滚动到顶部, 触发执行的函数 | `Function` | - | - | -| waterfall-disabled | 在 vue 对象中表示是否禁止瀑布流触发的 key 值 | `String` | - | - | -| waterfall-offset | 触发瀑布流加载的阈值 | `Number` | `300` | - | diff --git a/types/index.d.ts b/types/index.d.ts index 56ad1de66..997eab2da 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -5,7 +5,6 @@ import { Dialog } from './dialog'; import { Notify } from './notify'; import { Locale } from './locale'; import { Lazyload } from './lazyload'; -import { Waterfall } from './waterfall'; import { ImagePreview } from './image-preview'; export const version: string; @@ -78,6 +77,5 @@ export { Notify, Locale, Lazyload, - Waterfall, ImagePreview }; diff --git a/types/waterfall.d.ts b/types/waterfall.d.ts deleted file mode 100644 index 8beab86ba..000000000 --- a/types/waterfall.d.ts +++ /dev/null @@ -1,8 +0,0 @@ -import { DirectiveFunction, PluginFunction } from 'vue'; - -export interface Waterfall { - (type: string): DirectiveFunction; - install: PluginFunction; -} - -export const Waterfall: Waterfall; From baf309c33a39a073930d8f196b142175dc352d88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=98=89=E6=B6=B5?= Date: Mon, 29 Apr 2019 20:06:20 +0800 Subject: [PATCH 12/12] [breaking change] Badge: rename to sidebar --- docs/markdown/changelog.en-US.md | 12 ++-- docs/markdown/changelog.zh-CN.md | 14 ++-- docs/markdown/v2-progress-tracking.md | 3 +- docs/src/demo-entry.js | 2 +- docs/src/doc.config.js | 16 ++--- docs/src/docs-entry.js | 4 +- packages/badge-group/index.less | 5 -- packages/badge/en-US.md | 65 ------------------ packages/badge/index.less | 46 ------------- .../test/__snapshots__/demo.spec.js.snap | 22 ------ packages/badge/zh-CN.md | 66 ------------------ packages/index.less | 4 +- packages/index.ts | 12 ++-- packages/{badge => sidebar-item}/index.js | 18 ++--- packages/sidebar-item/index.less | 46 +++++++++++++ packages/{badge => sidebar}/demo/index.vue | 18 ++--- packages/sidebar/en-US.md | 67 +++++++++++++++++++ packages/{badge-group => sidebar}/index.js | 6 +- packages/sidebar/index.less | 5 ++ .../test/__snapshots__/demo.spec.js.snap | 22 ++++++ packages/{badge => sidebar}/test/demo.spec.js | 0 .../{badge => sidebar}/test/index.spec.js | 18 ++--- packages/sidebar/zh-CN.md | 67 +++++++++++++++++++ packages/style/var.less | 30 ++++----- types/index.d.ts | 4 +- 25 files changed, 288 insertions(+), 284 deletions(-) delete mode 100644 packages/badge-group/index.less delete mode 100644 packages/badge/en-US.md delete mode 100644 packages/badge/index.less delete mode 100644 packages/badge/test/__snapshots__/demo.spec.js.snap delete mode 100644 packages/badge/zh-CN.md rename packages/{badge => sidebar-item}/index.js (59%) create mode 100644 packages/sidebar-item/index.less rename packages/{badge => sidebar}/demo/index.vue (79%) create mode 100644 packages/sidebar/en-US.md rename packages/{badge-group => sidebar}/index.js (79%) create mode 100644 packages/sidebar/index.less create mode 100644 packages/sidebar/test/__snapshots__/demo.spec.js.snap rename packages/{badge => sidebar}/test/demo.spec.js (100%) rename packages/{badge => sidebar}/test/index.spec.js (66%) create mode 100644 packages/sidebar/zh-CN.md diff --git a/docs/markdown/changelog.en-US.md b/docs/markdown/changelog.en-US.md index ecf3fc0d2..751fc836a 100644 --- a/docs/markdown/changelog.en-US.md +++ b/docs/markdown/changelog.en-US.md @@ -55,7 +55,7 @@ - Cell: add less vars [\#3122](https://github.com/youzan/vant/pull/3122) - Rate: add less vars [\#3135](https://github.com/youzan/vant/pull/3135) - Panel: add less vars [\#3136](https://github.com/youzan/vant/pull/3136) -- Badge: add less vars [\#3131](https://github.com/youzan/vant/pull/3131) +- Sidebar: add less vars [\#3131](https://github.com/youzan/vant/pull/3131) - Dialog: add less vars [\#3123](https://github.com/youzan/vant/pull/3123) - Slider: add less vars [\#3125](https://github.com/youzan/vant/pull/3125) - Tabbar: add less vars [\#3124](https://github.com/youzan/vant/pull/3124) @@ -554,7 +554,7 @@ Also we have optimized the UI of the following components:: - Tab: add animated props [\#2126](https://github.com/youzan/vant/pull/2126) - Tab: update title style [\#2120](https://github.com/youzan/vant/pull/2120) -- Badge: update info style [\#2122](https://github.com/youzan/vant/pull/2122) +- Sidebar: update info style [\#2122](https://github.com/youzan/vant/pull/2122) - Radio: add checked-color prop [\#2129](https://github.com/youzan/vant/pull/2129) - Swipe: add indicator-color prop [\#2110](https://github.com/youzan/vant/pull/2110) - TreeSelect: support disable option [\#2107](https://github.com/youzan/vant/pull/2107) @@ -612,7 +612,7 @@ Also we have optimized the UI of the following components:: **Improvements** -- Badge: add change event [\#2017](https://github.com/youzan/vant/pull/2017) +- Sidebar: add change event [\#2017](https://github.com/youzan/vant/pull/2017) - Radio: update color [\#2018](https://github.com/youzan/vant/pull/2018) - Checkbox: update color [\#2018](https://github.com/youzan/vant/pull/2018) - Sku: support image preview [\#2019](https://github.com/youzan/vant/pull/2019) @@ -710,7 +710,7 @@ Also we have optimized the UI of the following components:: **Improvements** - Tab: upgrade style [\#1908](https://github.com/youzan/vant/pull/1908) -- Badge: upgrade style [\#1907](https://github.com/youzan/vant/pull/1907) +- Sidebar: upgrade style [\#1907](https://github.com/youzan/vant/pull/1907) - Dialog: upgrade style [\#1906](https://github.com/youzan/vant/pull/1906) - NoticeBar: upgrade style [\#1893](https://github.com/youzan/vant/pull/1893) - Collapse: add disabled prop [\#1892](https://github.com/youzan/vant/pull/1892) @@ -1362,7 +1362,7 @@ Also we have optimized the UI of the following components:: * fix ActionSheet bottom border missing [\#686](https://github.com/youzan/vant/pull/686) * fix AddressEdit area not selected when area_code changed [\#680](https://github.com/youzan/vant/pull/680) * fix Stepper value overlimit [\#691](https://github.com/youzan/vant/issues/691) -* fix Badge info font weight when selected [\#687](https://github.com/youzan/vant/pull/687) +* fix Sidebar info font weight when selected [\#687](https://github.com/youzan/vant/pull/687) ## [v0.12.14](https://github.com/youzan/vant/tree/v0.12.14) @@ -1652,7 +1652,7 @@ Also we have optimized the UI of the following components:: * Search: support native input attrs [\#418](https://github.com/youzan/vant/pull/418) * CellGroup: add 'border' prop [\#420](https://github.com/youzan/vant/pull/420) * AddressEdit: add focus、change-area、select-search events [\#426](https://github.com/youzan/vant/pull/426) -* Badge、CouponList、ContactCard: add active color [\#419](https://github.com/youzan/vant/pull/419) +* Sidebar、CouponList、ContactCard: add active color [\#419](https://github.com/youzan/vant/pull/419) **Bug Fixes** diff --git a/docs/markdown/changelog.zh-CN.md b/docs/markdown/changelog.zh-CN.md index 674be9ea2..b3ae6640a 100644 --- a/docs/markdown/changelog.zh-CN.md +++ b/docs/markdown/changelog.zh-CN.md @@ -55,7 +55,7 @@ - Cell: 新增多个 Less 变量 [\#3122](https://github.com/youzan/vant/pull/3122) - Rate: 新增多个 Less 变量 [\#3135](https://github.com/youzan/vant/pull/3135) - Panel: 新增多个 Less 变量 [\#3136](https://github.com/youzan/vant/pull/3136) -- Badge: 新增多个 Less 变量 [\#3131](https://github.com/youzan/vant/pull/3131) +- Sidebar: 新增多个 Less 变量 [\#3131](https://github.com/youzan/vant/pull/3131) - Dialog: 新增多个 Less 变量 [\#3123](https://github.com/youzan/vant/pull/3123) - Slider: 新增多个 Less 变量 [\#3125](https://github.com/youzan/vant/pull/3125) - Tabbar: 新增多个 Less 变量 [\#3124](https://github.com/youzan/vant/pull/3124) @@ -555,7 +555,7 @@ PS: 不小心跳过了 1.4.6 版本 ^_^ - Tab: 新增 animated 属性 [\#2126](https://github.com/youzan/vant/pull/2126) - Tab: 更新标题栏样式 [\#2120](https://github.com/youzan/vant/pull/2120) -- Badge: 更新提示样式 [\#2122](https://github.com/youzan/vant/pull/2122) +- Sidebar: 更新提示样式 [\#2122](https://github.com/youzan/vant/pull/2122) - Radio: 新增 checked-color 属性 [\#2129](https://github.com/youzan/vant/pull/2129) - Swipe: 新增 indica为r-color 属性 [\#2110](https://github.com/youzan/vant/pull/2110) - TreeSelect: 支持禁用选项 [\#2107](https://github.com/youzan/vant/pull/2107) @@ -616,7 +616,7 @@ PS: 不小心跳过了 1.4.6 版本 ^_^ - i18n: 支持土耳其语 [\#1998](https://github.com/youzan/vant/pull/1998) - i18n: 支持繁体中文(台) [\#1999](https://github.com/youzan/vant/pull/1999) - Icon: 新增 question2 图标 [\#2005](https://github.com/youzan/vant/pull/2005) -- Badge: 新增 change 事件 [\#2017](https://github.com/youzan/vant/pull/2017) +- Sidebar: 新增 change 事件 [\#2017](https://github.com/youzan/vant/pull/2017) - Switch: 新增 active-color 属性 [\#2013](https://github.com/youzan/vant/pull/2013) - Switch: 新增 inactive-color 属性 [\#2013](https://github.com/youzan/vant/pull/2013) - Radio: 选中态颜色调整为蓝色 [\#2018](https://github.com/youzan/vant/pull/2018) @@ -710,7 +710,7 @@ PS: 不小心跳过了 1.4.6 版本 ^_^ **Improvements** - Tab: 样式升级 [\#1908](https://github.com/youzan/vant/pull/1908) -- Badge: 样式升级 [\#1907](https://github.com/youzan/vant/pull/1907) +- Sidebar: 样式升级 [\#1907](https://github.com/youzan/vant/pull/1907) - Dialog: 样式升级 [\#1906](https://github.com/youzan/vant/pull/1906) - NoticeBar: 样式升级 [\#1893](https://github.com/youzan/vant/pull/1893) - Collapse: 新增 disabled 属性 [\#1892](https://github.com/youzan/vant/pull/1892) @@ -1356,7 +1356,7 @@ PS: 不小心跳过了 1.4.6 版本 ^_^ * 修复 ActionSheet 下边框未展示的问题 [\#686](https://github.com/youzan/vant/pull/686) * 修复 AddressEdit 在数据变更时未正确选中省市区的问题 [\#680](https://github.com/youzan/vant/pull/680) * 修复 Stepper value 溢出的问题 [\#691](https://github.com/youzan/vant/issues/691) -* 修复 Badge 选中时字体粗细 [\#687](https://github.com/youzan/vant/pull/687) +* 修复 Sidebar 选中时字体粗细 [\#687](https://github.com/youzan/vant/pull/687) ## [v0.12.14](https://github.com/youzan/vant/tree/v0.12.14) `2018-03-09` @@ -1644,7 +1644,7 @@ PS: 不小心跳过了 1.4.6 版本 ^_^ * Search: 支持 input 标签原生属性 [\#418](https://github.com/youzan/vant/pull/418) * CellGroup: 新增 'border' 属性 [\#420](https://github.com/youzan/vant/pull/420) * AddressEdit: 新增 focus、change-area、select-search 事件 [\#426](https://github.com/youzan/vant/pull/426) -* Badge、CouponList、ContactCard: 增加点击反馈 [\#419](https://github.com/youzan/vant/pull/419) +* Sidebar、CouponList、ContactCard: 增加点击反馈 [\#419](https://github.com/youzan/vant/pull/419) **Bug Fixes** @@ -2126,7 +2126,7 @@ PS: 不小心跳过了 1.4.6 版本 ^_^ * 新增 GoodsAction 组件 [\#102](https://github.com/youzan/vant/pull/102) * 新增 OrderGoods 组件 [\#99](https://github.com/youzan/vant/pull/99) * 新增 PayOrder 组件 [\#98](https://github.com/youzan/vant/pull/98) -* 优化 Step、Loading、Tag、Badge 文档 [\#101](https://github.com/youzan/vant/pull/101) +* 优化 Step、Loading、Tag、Sidebar 文档 [\#101](https://github.com/youzan/vant/pull/101) * Checkbox: 支持 change 事件 [\#104](https://github.com/youzan/vant/pull/104) **Bug Fixes** diff --git a/docs/markdown/v2-progress-tracking.md b/docs/markdown/v2-progress-tracking.md index ab05d4df0..41cfd6364 100644 --- a/docs/markdown/v2-progress-tracking.md +++ b/docs/markdown/v2-progress-tracking.md @@ -35,7 +35,8 @@ ### Badge -- [ ] 重命名为`SideNav` +- [x] `BadgeGroup`重命名为`Sidebar` +- [x] `Badge`重命名为`SlideBarItem` ### Loading diff --git a/docs/src/demo-entry.js b/docs/src/demo-entry.js index d8ba6c5ab..6f0a73fc6 100644 --- a/docs/src/demo-entry.js +++ b/docs/src/demo-entry.js @@ -7,7 +7,6 @@ export default { 'address-edit': () => wrapper(import('../../packages/address-edit/demo'), 'address-edit'), 'address-list': () => wrapper(import('../../packages/address-list/demo'), 'address-list'), 'area': () => wrapper(import('../../packages/area/demo'), 'area'), - 'badge': () => wrapper(import('../../packages/badge/demo'), 'badge'), 'button': () => wrapper(import('../../packages/button/demo'), 'button'), 'card': () => wrapper(import('../../packages/card/demo'), 'card'), 'cell': () => wrapper(import('../../packages/cell/demo'), 'cell'), @@ -40,6 +39,7 @@ export default { 'radio': () => wrapper(import('../../packages/radio/demo'), 'radio'), 'rate': () => wrapper(import('../../packages/rate/demo'), 'rate'), 'search': () => wrapper(import('../../packages/search/demo'), 'search'), + 'sidebar': () => wrapper(import('../../packages/sidebar/demo'), 'sidebar'), 'sku': () => wrapper(import('../../packages/sku/demo'), 'sku'), 'slider': () => wrapper(import('../../packages/slider/demo'), 'slider'), 'stepper': () => wrapper(import('../../packages/stepper/demo'), 'stepper'), diff --git a/docs/src/doc.config.js b/docs/src/doc.config.js index 37ca5347b..6a009488e 100644 --- a/docs/src/doc.config.js +++ b/docs/src/doc.config.js @@ -251,10 +251,6 @@ module.exports = { groupName: '导航组件', icon: 'https://img.yzcdn.cn/vant/nav-0401.svg', list: [ - { - path: '/badge', - title: 'Badge 徽章' - }, { path: '/nav-bar', title: 'NavBar 导航栏' @@ -263,6 +259,10 @@ module.exports = { path: '/pagination', title: 'Pagination 分页' }, + { + path: '/sidebar', + title: 'Sidebar 侧边导航' + }, { path: '/tab', title: 'Tab 标签页' @@ -558,10 +558,6 @@ module.exports = { groupName: 'Navigation Components', icon: 'https://img.yzcdn.cn/vant/nav-0401.svg', list: [ - { - path: '/badge', - title: 'Badge' - }, { path: '/nav-bar', title: 'NavBar' @@ -570,6 +566,10 @@ module.exports = { path: '/pagination', title: 'Pagination' }, + { + path: '/sidebar', + title: 'Sidebar' + }, { path: '/tab', title: 'Tab' diff --git a/docs/src/docs-entry.js b/docs/src/docs-entry.js index da7cb205a..5e9291552 100644 --- a/docs/src/docs-entry.js +++ b/docs/src/docs-entry.js @@ -21,8 +21,6 @@ export default { 'address-list.zh-CN': () => import('../../packages/address-list/zh-CN.md'), 'area.en-US': () => import('../../packages/area/en-US.md'), 'area.zh-CN': () => import('../../packages/area/zh-CN.md'), - 'badge.en-US': () => import('../../packages/badge/en-US.md'), - 'badge.zh-CN': () => import('../../packages/badge/zh-CN.md'), 'button.en-US': () => import('../../packages/button/en-US.md'), 'button.zh-CN': () => import('../../packages/button/zh-CN.md'), 'card.en-US': () => import('../../packages/card/en-US.md'), @@ -89,6 +87,8 @@ export default { 'rate.zh-CN': () => import('../../packages/rate/zh-CN.md'), 'search.en-US': () => import('../../packages/search/en-US.md'), 'search.zh-CN': () => import('../../packages/search/zh-CN.md'), + 'sidebar.en-US': () => import('../../packages/sidebar/en-US.md'), + 'sidebar.zh-CN': () => import('../../packages/sidebar/zh-CN.md'), 'sku.en-US': () => import('../../packages/sku/en-US.md'), 'sku.zh-CN': () => import('../../packages/sku/zh-CN.md'), 'slider.en-US': () => import('../../packages/slider/en-US.md'), diff --git a/packages/badge-group/index.less b/packages/badge-group/index.less deleted file mode 100644 index 545f9304b..000000000 --- a/packages/badge-group/index.less +++ /dev/null @@ -1,5 +0,0 @@ -@import '../style/var'; - -.badge-group { - width: @badge-group-width; -} diff --git a/packages/badge/en-US.md b/packages/badge/en-US.md deleted file mode 100644 index d4f9ea2a6..000000000 --- a/packages/badge/en-US.md +++ /dev/null @@ -1,65 +0,0 @@ -## Badge - -### Install -``` javascript -import { Badge, BadgeGroup } from 'vant'; - -Vue.use(Badge); -Vue.use(BadgeGroup); -``` - -### Usage - -#### Basic Usage -Use `active-key` prop to set index of chosen 'badge' - -```html - - - - - - -``` - -``` javascript -export default { - data() { - return { - activeKey: 0 - }; - }, - - methods: { - onChange(key) { - this.activeKey = key; - } - } -}; -``` - -### BadgeGroup API - -| Attribute | Description | Type | Default | -|------|------|------|------| -| active-key | Index of chosen badge | `String | Number` | `0` | - -### BadgeGroup Event - -| Event | Description | Arguments | -|------|------|------| -| change | Triggered when badge changed | key: index of current badge | - -### Badge API - -| Attribute | Description | Type | Default | -|------|------|------|------| -| title | Content | `String` | `''` | -| info | Info Message | `String | Number` | `''` | -| url | Link | `String` | - | - -### Badge Event - -| Event | Description | Arguments | -|------|------|------| -| click | Triggered when click badge | key: index of current badge | diff --git a/packages/badge/index.less b/packages/badge/index.less deleted file mode 100644 index 0269e487c..000000000 --- a/packages/badge/index.less +++ /dev/null @@ -1,46 +0,0 @@ -@import '../style/var'; - -.van-badge { - display: block; - overflow: hidden; - user-select: none; - word-break: break-all; - box-sizing: border-box; - color: @badge-text-color; - padding: @badge-padding; - font-size: @badge-font-size; - line-height: @badge-line-height; - background-color: @badge-background-color; - border-left: 3px solid transparent; - - &__text { - position: relative; - } - - &:active { - background-color: @badge-active-color; - } - - &:not(:last-child)::after { - border-bottom-width: 1px; - } - - &--select { - color: @badge-selected-text-color; - font-weight: @badge-selected-font-weight; - border-color: @badge-selected-border-color; - - &::after { - border-right-width: 1px; - } - - &, - &:active { - background-color: @badge-selected-background-color; - } - } - - .van-info { - right: 4px; - } -} diff --git a/packages/badge/test/__snapshots__/demo.spec.js.snap b/packages/badge/test/__snapshots__/demo.spec.js.snap deleted file mode 100644 index 85f87fc47..000000000 --- a/packages/badge/test/__snapshots__/demo.spec.js.snap +++ /dev/null @@ -1,22 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`renders demo correctly 1`] = ` -
- -
-`; diff --git a/packages/badge/zh-CN.md b/packages/badge/zh-CN.md deleted file mode 100644 index 5d33fef28..000000000 --- a/packages/badge/zh-CN.md +++ /dev/null @@ -1,66 +0,0 @@ -## Badge 徽章 - -### 使用指南 -``` javascript -import { Badge, BadgeGroup } from 'vant'; - -Vue.use(Badge); -Vue.use(BadgeGroup); -``` - -### 代码演示 - -#### 基础用法 - -通过在`van-badge-group`上设置`active-key`属性来控制选中的`badge` - -```html - - - - - - -``` - -``` javascript -export default { - data() { - return { - activeKey: 0 - }; - }, - - methods: { - onChange(key) { - this.activeKey = key; - } - } -}; -``` - -### BadgeGroup API - -| 参数 | 说明 | 类型 | 默认值 | 版本 | -|------|------|------|------|------| -| active-key | 选中`badge`的索引 | `String | Number` | `0` | - | - -### BadgeGroup Event - -| 事件名 | 说明 | 参数 | -|------|------|------| -| change | 切换徽章时触发 | key: 当前选中徽章的索引 | - -### Badge API - -| 参数 | 说明 | 类型 | 默认值 | 版本 | -|------|------|------|------|------| -| title | 内容 | `String` | `''` | - | -| info | 提示消息 | `String | Number` | `''` | - | -| url | 跳转链接 | `String` | - | - | - -### Badge Event - -| 事件名 | 说明 | 参数 | -|------|------|------| -| click | 点击徽章时触发 | key: 当前徽章的索引 | diff --git a/packages/index.less b/packages/index.less index b54ab34d7..ada57beec 100644 --- a/packages/index.less +++ b/packages/index.less @@ -8,8 +8,6 @@ /* common components */ @import './col/index'; @import './row/index'; -@import './badge/index'; -@import './badge-group/index'; @import './circle/index'; @import './collapse-item/index'; @import './list/index'; @@ -30,6 +28,8 @@ @import './image-preview/index'; @import './stepper/index'; @import './progress/index'; +@import './sidebar/index'; +@import './sidebar-item/index'; @import './swipe/index'; @import './swipe-item/index'; @import './slider/index'; diff --git a/packages/index.ts b/packages/index.ts index ed36c208e..3005a095d 100644 --- a/packages/index.ts +++ b/packages/index.ts @@ -5,8 +5,6 @@ import ActionSheet from './action-sheet'; import AddressEdit from './address-edit'; import AddressList from './address-list'; import Area from './area'; -import Badge from './badge'; -import BadgeGroup from './badge-group'; import Button from './button'; import Card from './card'; import Cell from './cell'; @@ -53,6 +51,8 @@ import RadioGroup from './radio-group'; import Rate from './rate'; import Row from './row'; import Search from './search'; +import Sidebar from './sidebar'; +import SidebarItem from './sidebar-item'; import Sku from './sku'; import Slider from './slider'; import Step from './step'; @@ -85,8 +85,6 @@ const components = [ AddressEdit, AddressList, Area, - Badge, - BadgeGroup, Button, Card, Cell, @@ -131,6 +129,8 @@ const components = [ Rate, Row, Search, + Sidebar, + SidebarItem, Sku, Slider, Step, @@ -170,8 +170,6 @@ export { AddressEdit, AddressList, Area, - Badge, - BadgeGroup, Button, Card, Cell, @@ -218,6 +216,8 @@ export { Rate, Row, Search, + Sidebar, + SidebarItem, Sku, Slider, Step, diff --git a/packages/badge/index.js b/packages/sidebar-item/index.js similarity index 59% rename from packages/badge/index.js rename to packages/sidebar-item/index.js index a4f4404f7..1bc302c3c 100644 --- a/packages/badge/index.js +++ b/packages/sidebar-item/index.js @@ -1,7 +1,7 @@ import { use } from '../utils'; import Info from '../info'; -const [sfc, bem] = use('badge'); +const [sfc, bem] = use('sidebar-item'); export default sfc({ props: { @@ -10,32 +10,32 @@ export default sfc({ title: String }, - inject: ['vanBadgeGroup'], + inject: ['vanSidebar'], created() { - this.parent.badges.push(this); + this.parent.items.push(this); }, beforeDestroy() { - this.parent.badges = this.parent.badges.filter(item => item !== this); + this.parent.items = this.parent.items.filter(item => item !== this); }, computed: { parent() { - if (process.env.NODE_ENV !== 'production' && !this.vanBadgeGroup) { - console.error('[Vant] Badge needs to be child of BadgeGroup'); + if (process.env.NODE_ENV !== 'production' && !this.vanSidebar) { + console.error('[Vant] SidebarItem needs to be child of Sidebar'); } - return this.vanBadgeGroup; + return this.vanSidebar; }, select() { - return this.parent.badges.indexOf(this) === +this.parent.activeKey; + return this.parent.items.indexOf(this) === +this.parent.activeKey; } }, methods: { onClick() { - const index = this.parent.badges.indexOf(this); + const index = this.parent.items.indexOf(this); this.$emit('click', index); this.parent.$emit('change', index); } diff --git a/packages/sidebar-item/index.less b/packages/sidebar-item/index.less new file mode 100644 index 000000000..54671b5a8 --- /dev/null +++ b/packages/sidebar-item/index.less @@ -0,0 +1,46 @@ +@import '../style/var'; + +.van-sidebar-item { + display: block; + overflow: hidden; + user-select: none; + word-break: break-all; + box-sizing: border-box; + color: @sidebar-text-color; + padding: @sidebar-padding; + font-size: @sidebar-font-size; + line-height: @sidebar-line-height; + background-color: @sidebar-background-color; + border-left: 3px solid transparent; + + &__text { + position: relative; + } + + &:active { + background-color: @sidebar-active-color; + } + + &:not(:last-child)::after { + border-bottom-width: 1px; + } + + &--select { + color: @sidebar-selected-text-color; + font-weight: @sidebar-selected-font-weight; + border-color: @sidebar-selected-border-color; + + &::after { + border-right-width: 1px; + } + + &, + &:active { + background-color: @sidebar-selected-background-color; + } + } + + .van-info { + right: 4px; + } +} diff --git a/packages/badge/demo/index.vue b/packages/sidebar/demo/index.vue similarity index 79% rename from packages/badge/demo/index.vue rename to packages/sidebar/demo/index.vue index 15337fc2c..6f68403dd 100644 --- a/packages/badge/demo/index.vue +++ b/packages/sidebar/demo/index.vue @@ -1,24 +1,24 @@ @@ -48,8 +48,8 @@ export default {