From 966fb5f46a3795ffc3b64a10f79d825ebb44894f Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Tue, 18 Aug 2020 17:54:52 +0800 Subject: [PATCH] breaking change: remove SwitchCell component --- src/switch-cell/README.md | 78 ----------------- src/switch-cell/README.zh-CN.md | 86 ------------------- src/switch-cell/demo/index.vue | 31 ------- src/switch-cell/index.less | 15 ---- src/switch-cell/index.tsx | 61 ------------- .../test/__snapshots__/demo.spec.js.snap | 44 ---------- .../test/__snapshots__/index.spec.js.snap | 21 ----- src/switch-cell/test/demo.spec.js | 4 - src/switch-cell/test/index.spec.js | 37 -------- 9 files changed, 377 deletions(-) delete mode 100644 src/switch-cell/README.md delete mode 100644 src/switch-cell/README.zh-CN.md delete mode 100644 src/switch-cell/demo/index.vue delete mode 100644 src/switch-cell/index.less delete mode 100644 src/switch-cell/index.tsx delete mode 100644 src/switch-cell/test/__snapshots__/demo.spec.js.snap delete mode 100644 src/switch-cell/test/__snapshots__/index.spec.js.snap delete mode 100644 src/switch-cell/test/demo.spec.js delete mode 100644 src/switch-cell/test/index.spec.js diff --git a/src/switch-cell/README.md b/src/switch-cell/README.md deleted file mode 100644 index beb73c775..000000000 --- a/src/switch-cell/README.md +++ /dev/null @@ -1,78 +0,0 @@ -# SwitchCell - -### Deprecate Tip - -The SwitchCell component will be deprecated in version 3.0. Please use the Cell and Switch components instead. - -### Install - -```js -import Vue from 'vue'; -import { SwitchCell } from 'vant'; - -Vue.use(SwitchCell); -``` - -## Usage - -### Basic Usage - -```html - - - -``` - -```js -export default { - data() { - return { - checked: true, - }; - }, -}; -``` - -### Disabled - -use `disabled` property to disable the component - -```html - - - -``` - -### Loading - -use `loading` property to keep component in loading state - -```html - - - -``` - -## API - -### Props - -| Attribute | Description | Type | Default | -| --- | --- | --- | --- | -| v-model | on-off state of the switch | _any_ | `false` | -| title | the left side title | _string_ | `''` | -| border | whether to show cell border | _boolean_ | `true` | -| cell-size | Cell size,can be set to `large` | _string_ | - | -| loading | whether switch is loading | _boolean_ | `false` | -| disabled | whether to disable switch | _boolean_ | `false` | -| size | Size of switch | _number \| string_ | `24px` | -| active-color | Background of switch color when active | _string_ | `#1989fa` | -| inactive-color | Background of switch color when inactive | _string_ | `white` | -| active-value | Value when active | _any_ | `true` | -| inactive-value | Value when inactive | _any_ | `false` | - -### Events - -| Event | Description | Arguments | -| --- | --- | --- | -| change | triggered when the on-off state is changed | checked: switch is on or not | diff --git a/src/switch-cell/README.zh-CN.md b/src/switch-cell/README.zh-CN.md deleted file mode 100644 index d91c3cd58..000000000 --- a/src/switch-cell/README.zh-CN.md +++ /dev/null @@ -1,86 +0,0 @@ -# SwitchCell 开关单元格 - -### 废弃提示 - -SwitchCell 组件将在 3.0 版本中废弃,请直接使用 Cell 和 Switch 组件代替,替换写法如下: - -```html - - - -``` - -### 引入 - -```js -import Vue from 'vue'; -import { SwitchCell } from 'vant'; - -Vue.use(SwitchCell); -``` - -## 代码演示 - -### 基础用法 - -```html - - - -``` - -```js -export default { - data() { - return { - checked: true, - }; - }, -}; -``` - -### 禁用状态 - -通过`disabled`属性可以将组件设置为禁用状态 - -```html - - - -``` - -### 加载状态 - -通过`loading`属性可以将组件设置为加载状态 - -```html - - - -``` - -## API - -### Props - -| 参数 | 说明 | 类型 | 默认值 | -| --- | --- | --- | --- | -| v-model | 开关状态 | _any_ | `false` | -| title | 左侧标题 | _string_ | `''` | -| border | 是否展示单元格内边框 | _boolean_ | `true` | -| cell-size | 单元格大小,可选值为 `large` | _string_ | - | -| loading | 是否为加载状态 | _boolean_ | `false` | -| disabled | 是否为禁用状态 | _boolean_ | `false` | -| size | 开关尺寸 | _number \| string_ | `24px` | -| active-color | 开关时的背景色 | _string_ | `#1989fa` | -| inactive-color | 开关时的背景色 | _string_ | `white` | -| active-value | 打开时的值 | _any_ | `true` | -| inactive-value | 关闭时的值 | _any_ | `false` | - -### Events - -| 事件名 | 说明 | 回调参数 | -| ------ | ---------------- | --------------------- | -| change | 开关状态切换回调 | checked: 是否选中开关 | diff --git a/src/switch-cell/demo/index.vue b/src/switch-cell/demo/index.vue deleted file mode 100644 index f79632745..000000000 --- a/src/switch-cell/demo/index.vue +++ /dev/null @@ -1,31 +0,0 @@ - - - diff --git a/src/switch-cell/index.less b/src/switch-cell/index.less deleted file mode 100644 index df899d16c..000000000 --- a/src/switch-cell/index.less +++ /dev/null @@ -1,15 +0,0 @@ -@import '../style/var'; - -.van-switch-cell { - padding-top: @switch-cell-padding-top; - padding-bottom: @switch-cell-padding-bottom; - - &--large { - padding-top: @switch-cell-large-padding-top; - padding-bottom: @switch-cell-large-padding-bottom; - } - - .van-switch { - float: right; - } -} diff --git a/src/switch-cell/index.tsx b/src/switch-cell/index.tsx deleted file mode 100644 index 21d3173b0..000000000 --- a/src/switch-cell/index.tsx +++ /dev/null @@ -1,61 +0,0 @@ -// Utils -import { createNamespace } from '../utils'; -import { inherit } from '../utils/functional'; - -// Components -import Cell from '../cell'; -import Switch from '../switch'; -import { switchProps, SharedSwitchProps } from '../switch/shared'; - -// Types -import { CreateElement, RenderContext } from 'vue/types'; -import { DefaultSlots } from '../utils/types'; - -export type SwitchCellProps = SharedSwitchProps & { - size: string; - title?: string; - border?: boolean; - cellSize?: string; -}; - -export type SwitchCellEvents = { - onChange?(checked: boolean): void; -}; - -const [createComponent, bem] = createNamespace('switch-cell'); - -function SwitchCell( - h: CreateElement, - props: SwitchCellProps, - slots: DefaultSlots, - ctx: RenderContext -) { - return ( - - - - ); -} - -SwitchCell.props = { - ...switchProps, - title: String, - cellSize: String, - border: { - type: Boolean, - default: true, - }, - size: { - type: String, - default: '24px', - }, -}; - -export default createComponent(SwitchCell); diff --git a/src/switch-cell/test/__snapshots__/demo.spec.js.snap b/src/switch-cell/test/__snapshots__/demo.spec.js.snap deleted file mode 100644 index 70a597bc1..000000000 --- a/src/switch-cell/test/__snapshots__/demo.spec.js.snap +++ /dev/null @@ -1,44 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`renders demo correctly 1`] = ` -
-
-
-
-
标题
-
-
-
-
-
-
-
-
-
-
-
-
标题
-
-
-
-
-
-
-
-
-
-
-
-
标题
-
-
-
-
-
-
-
-
-
-
-
-`; diff --git a/src/switch-cell/test/__snapshots__/index.spec.js.snap b/src/switch-cell/test/__snapshots__/index.spec.js.snap deleted file mode 100644 index f3855ca9b..000000000 --- a/src/switch-cell/test/__snapshots__/index.spec.js.snap +++ /dev/null @@ -1,21 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`border prop 1`] = ` -
-
-
-
-
-
-
-`; - -exports[`cell-size prop 1`] = ` -
-
-
-
-
-
-
-`; diff --git a/src/switch-cell/test/demo.spec.js b/src/switch-cell/test/demo.spec.js deleted file mode 100644 index 5c70922b5..000000000 --- a/src/switch-cell/test/demo.spec.js +++ /dev/null @@ -1,4 +0,0 @@ -import Demo from '../demo'; -import { snapshotDemo } from '../../../test/demo'; - -snapshotDemo(Demo); diff --git a/src/switch-cell/test/index.spec.js b/src/switch-cell/test/index.spec.js deleted file mode 100644 index 17479b9ac..000000000 --- a/src/switch-cell/test/index.spec.js +++ /dev/null @@ -1,37 +0,0 @@ -import SwitchCell from '..'; -import { mount } from '../../../test'; - -test('change event', () => { - const onChange = jest.fn(); - const wrapper = mount(SwitchCell, { - context: { - on: { - change: onChange, - }, - }, - }); - - wrapper.find('.van-switch').trigger('click'); - - expect(onChange).toHaveBeenCalledWith(true); -}); - -test('border prop', () => { - const wrapper = mount(SwitchCell, { - propsData: { - border: false, - }, - }); - - expect(wrapper).toMatchSnapshot(); -}); - -test('cell-size prop', () => { - const wrapper = mount(SwitchCell, { - propsData: { - cellSize: 'large', - }, - }); - - expect(wrapper).toMatchSnapshot(); -});