Skip to content

Commit

Permalink
feat: migrate less to token for Switch (ant-design#42192)
Browse files Browse the repository at this point in the history
* feat: migrate less to token for Switch

* chore: add demo

* chore: code clean

* chore: update demo

* docs: update docs en

* chore: code clean

---------

Co-authored-by: MadCcc <1075746765@qq.com>
  • Loading branch information
Yuiai01 and MadCcc authored Aug 16, 2023
1 parent 65989b4 commit b9f77fd
Show file tree
Hide file tree
Showing 10 changed files with 271 additions and 120 deletions.
4 changes: 3 additions & 1 deletion components/switch/__tests__/demo-extend.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { extendTest } from '../../../tests/shared/demoTest';

extendTest('switch');
extendTest('switch', {
skip: ['component-token.tsx'],
});
4 changes: 3 additions & 1 deletion components/switch/__tests__/demo.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('switch');
demoTest('switch', {
skip: ['component-token.tsx'],
});
7 changes: 7 additions & 0 deletions components/switch/demo/component-token.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## zh-CN

自定义组件 Token。

## en-US

Custom component token.
30 changes: 30 additions & 0 deletions components/switch/demo/component-token.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import { ConfigProvider, Space, Switch } from 'antd';

const App: React.FC = () => (
<ConfigProvider
theme={{
components: {
Switch: {
trackHeight: 14,
trackMinWidth: 32,
// opacityLoading: 0.1,
colorPrimary: 'rgb(25, 118, 210, 0.5)',
trackPadding: -3,
handleSize: 20,
handleBg: 'rgb(25, 118, 210)',
handleShadow:
'rgba(0, 0, 0, 0.2) 0px 2px 1px -1px, rgba(0, 0, 0, 0.14) 0px 1px 1px 0px, rgba(0, 0, 0, 0.12) 0px 1px 3px 0px',
// innerMinMargin: 4,
// innerMaxMargin: 8,
},
},
}}
>
<Space>
<Switch defaultChecked />
</Space>
</ConfigProvider>
);

export default App;
1 change: 1 addition & 0 deletions components/switch/index.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Switching Selector.
<code src="./demo/text.tsx">Text & icon</code>
<code src="./demo/size.tsx">Two sizes</code>
<code src="./demo/loading.tsx">Loading</code>
<code src="./demo/component-token.tsx" debug>Custom component token</code>

## API

Expand Down
1 change: 1 addition & 0 deletions components/switch/index.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ demo:
<code src="./demo/text.tsx">文字和图标</code>
<code src="./demo/size.tsx">两种大小</code>
<code src="./demo/loading.tsx">加载中</code>
<code src="./demo/component-token.tsx" debug>自定义组件 Token</code>

## API

Expand Down
Loading

0 comments on commit b9f77fd

Please sign in to comment.