├── .dumirc.ts ├── .editorconfig ├── .eslintrc.js ├── .fatherrc.ts ├── .github ├── dependabot.yml └── workflows │ ├── main.yml │ └── preview.yml ├── .gitignore ├── .husky └── pre-commit ├── .npmignore ├── .prettierignore ├── .prettierrc ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── docs ├── editor │ ├── index.md │ └── v4-theme.md ├── examples │ ├── color-panel.tsx │ ├── overview-error.tsx │ ├── overview-primary.tsx │ ├── overview-success.tsx │ ├── overview-warning.tsx │ ├── preview-demo.tsx │ ├── previewer-controlled.tsx │ ├── previewer-token-panel.tsx │ ├── previewer.tsx │ ├── theme-editor-simple.tsx │ └── v4-theme.tsx ├── index.md ├── others │ ├── color-panel.md │ └── overview.md └── previewer │ ├── controlled.md │ ├── index.md │ └── previewer-token-panel.md ├── index.js ├── jest.config.js ├── package.json ├── public └── icon │ ├── theme-editor.png │ └── theme-editor.svg ├── src ├── ColorPanel.tsx ├── ColorPicker.tsx ├── ColorPreview.tsx ├── FilterPanel.tsx ├── GlobalTokenEditor.tsx ├── IconSwitch.tsx ├── PreviewDemo.tsx ├── ThemeEditor.tsx ├── ThemeSelect.tsx ├── TokenInput.tsx ├── component-panel │ ├── ComponentCard.tsx │ ├── ComponentDemoGroup.tsx │ ├── ComponentTokenDrawer.tsx │ ├── ComponentTree.tsx │ └── index.tsx ├── component-token-editor │ ├── DemoCard.tsx │ ├── DemoWrapper.tsx │ ├── TokenInput.tsx │ ├── TokenItem.tsx │ └── index.tsx ├── context │ └── index.ts ├── editor-modal │ ├── JSONEditor.tsx │ └── index.tsx ├── hooks │ └── useControlledTheme.tsx ├── icons │ ├── Arrow.d.ts │ ├── Arrow.js │ ├── Brush.d.ts │ ├── Brush.js │ ├── Compact.d.ts │ ├── Compact.js │ ├── Control.d.ts │ ├── Control.js │ ├── Dark.d.ts │ ├── Dark.js │ ├── Light.d.ts │ ├── Light.js │ ├── Margin.d.ts │ ├── Margin.js │ ├── Motion.d.ts │ ├── Motion.js │ ├── Pick.d.ts │ ├── Pick.js │ ├── SearchDropdown.d.ts │ ├── SearchDropdown.js │ ├── ShapeLine.d.ts │ ├── ShapeLine.js │ ├── TokenPanel.d.ts │ ├── TokenPanel.js │ ├── index.d.ts │ └── index.js ├── index.tsx ├── interface.ts ├── locale │ ├── context.tsx │ ├── en-US.ts │ ├── index.ts │ ├── interface.ts │ └── zh-CN.ts ├── meta │ ├── TokenRelation.ts │ ├── category.ts │ ├── index.ts │ └── interface.ts ├── previewer.tsx ├── previews │ ├── components │ │ ├── alert │ │ │ ├── alert.tsx │ │ │ ├── error.tsx │ │ │ ├── index.ts │ │ │ ├── info.tsx │ │ │ ├── success.tsx │ │ │ └── warning.tsx │ │ ├── anchor │ │ │ ├── anchor.tsx │ │ │ ├── anchorInLayout.tsx │ │ │ └── index.ts │ │ ├── autoComplete │ │ │ ├── auto-complete.tsx │ │ │ └── index.ts │ │ ├── avatar │ │ │ ├── avatar.tsx │ │ │ └── index.tsx │ │ ├── badge │ │ │ ├── badge.tsx │ │ │ ├── index.ts │ │ │ ├── progress.tsx │ │ │ ├── success.tsx │ │ │ └── warning.tsx │ │ ├── breadcrumb │ │ │ ├── breadcrumb.tsx │ │ │ └── index.ts │ │ ├── button │ │ │ ├── button-icon.tsx │ │ │ ├── button.tsx │ │ │ ├── dangerButton.tsx │ │ │ ├── defaultButton.tsx │ │ │ ├── disabled.tsx │ │ │ └── index.ts │ │ ├── calendar │ │ │ ├── calendar.tsx │ │ │ ├── disabled.tsx │ │ │ └── index.ts │ │ ├── card │ │ │ ├── card.tsx │ │ │ ├── cardGrid.tsx │ │ │ ├── index.ts │ │ │ └── inner.tsx │ │ ├── carousel │ │ │ ├── carousel.tsx │ │ │ └── index.ts │ │ ├── cascader │ │ │ ├── cascader.tsx │ │ │ ├── data.ts │ │ │ ├── disable.tsx │ │ │ ├── highlight.tsx │ │ │ └── index.ts │ │ ├── checkbox │ │ │ ├── checkbox.tsx │ │ │ ├── disabled.tsx │ │ │ └── index.ts │ │ ├── collapse │ │ │ ├── collapse.tsx │ │ │ └── index.ts │ │ ├── datePicker │ │ │ ├── danger.tsx │ │ │ ├── date-picker.tsx │ │ │ ├── disabled.tsx │ │ │ ├── icon.tsx │ │ │ ├── index.ts │ │ │ └── warning.tsx │ │ ├── descriptions │ │ │ ├── descriptions.tsx │ │ │ └── index.ts │ │ ├── divider │ │ │ ├── divider.tsx │ │ │ └── index.ts │ │ ├── drawer │ │ │ ├── drawer.tsx │ │ │ └── index.ts │ │ ├── dropdown │ │ │ ├── dropdown.tsx │ │ │ ├── dropdownError.tsx │ │ │ ├── index.ts │ │ │ └── menu.tsx │ │ ├── empty │ │ │ ├── empty.tsx │ │ │ └── index.ts │ │ ├── form │ │ │ ├── danger.tsx │ │ │ ├── form.tsx │ │ │ ├── index.tsx │ │ │ └── warning.tsx │ │ ├── grid │ │ │ ├── grid.tsx │ │ │ └── index.ts │ │ ├── icon │ │ │ ├── icon.tsx │ │ │ └── index.ts │ │ ├── image │ │ │ ├── disabled.tsx │ │ │ ├── image.tsx │ │ │ └── index.ts │ │ ├── index.ts │ │ ├── input │ │ │ ├── clearIcon.tsx │ │ │ ├── danger.tsx │ │ │ ├── disabled.tsx │ │ │ ├── index.ts │ │ │ ├── input.tsx │ │ │ ├── success.tsx │ │ │ ├── warning.tsx │ │ │ └── withAddon.tsx │ │ ├── inputNumber │ │ │ ├── danger.tsx │ │ │ ├── disabled.tsx │ │ │ ├── index.ts │ │ │ ├── inputNumber.tsx │ │ │ └── warning.tsx │ │ ├── layout │ │ │ ├── index.ts │ │ │ └── top-side-2.tsx │ │ ├── list │ │ │ ├── index.ts │ │ │ └── list.tsx │ │ ├── mentions │ │ │ ├── danger.tsx │ │ │ ├── disabled.tsx │ │ │ ├── index.ts │ │ │ ├── mentions.tsx │ │ │ └── warning.tsx │ │ ├── menu │ │ │ ├── data.tsx │ │ │ ├── index.ts │ │ │ ├── menu.tsx │ │ │ ├── menuDanger.tsx │ │ │ └── menuInLayout.tsx │ │ ├── message │ │ │ ├── error.tsx │ │ │ ├── index.ts │ │ │ ├── info.tsx │ │ │ ├── message.tsx │ │ │ ├── success.tsx │ │ │ └── warning.tsx │ │ ├── modal │ │ │ ├── index.ts │ │ │ ├── info.tsx │ │ │ ├── modal.tsx │ │ │ ├── modalWithButton.tsx │ │ │ ├── success.tsx │ │ │ └── warning.tsx │ │ ├── notification │ │ │ ├── error.tsx │ │ │ ├── index.ts │ │ │ ├── info.tsx │ │ │ ├── notification.tsx │ │ │ ├── success.tsx │ │ │ └── warning.tsx │ │ ├── pagination │ │ │ ├── disabled.tsx │ │ │ ├── index.tsx │ │ │ ├── outline.tsx │ │ │ └── pagination.tsx │ │ ├── popconfirm │ │ │ ├── index.ts │ │ │ └── popconfirm.tsx │ │ ├── popover │ │ │ ├── index.ts │ │ │ └── popover.tsx │ │ ├── progress │ │ │ ├── danger.tsx │ │ │ ├── index.ts │ │ │ ├── info.tsx │ │ │ ├── progress.tsx │ │ │ ├── progressInBg.tsx │ │ │ └── success.tsx │ │ ├── radio │ │ │ ├── button.tsx │ │ │ ├── disabled.tsx │ │ │ ├── index.ts │ │ │ └── radio.tsx │ │ ├── rate │ │ │ ├── index.ts │ │ │ └── rate.tsx │ │ ├── result │ │ │ ├── danger.tsx │ │ │ ├── index.ts │ │ │ ├── info.tsx │ │ │ ├── result.tsx │ │ │ ├── resultWithDesc.tsx │ │ │ ├── success.tsx │ │ │ └── warning.tsx │ │ ├── segmented │ │ │ ├── index.ts │ │ │ └── segmented.tsx │ │ ├── select │ │ │ ├── _internal.ts │ │ │ ├── danger.tsx │ │ │ ├── data.ts │ │ │ ├── disabled.tsx │ │ │ ├── icon.tsx │ │ │ ├── index.ts │ │ │ ├── select.tsx │ │ │ ├── selectTag.tsx │ │ │ └── warning.tsx │ │ ├── skeleton │ │ │ ├── index.ts │ │ │ └── skeleton.tsx │ │ ├── slider │ │ │ ├── index.ts │ │ │ ├── slider.tsx │ │ │ └── sliderInBg.tsx │ │ ├── space │ │ │ ├── index.ts │ │ │ └── space.tsx │ │ ├── spin │ │ │ ├── index.ts │ │ │ └── spin.tsx │ │ ├── statistic │ │ │ ├── index.ts │ │ │ └── statistic.tsx │ │ ├── steps │ │ │ ├── danger.tsx │ │ │ ├── index.ts │ │ │ └── steps.tsx │ │ ├── switch │ │ │ ├── index.ts │ │ │ └── switch.tsx │ │ ├── table │ │ │ ├── filterTable.tsx │ │ │ ├── index.ts │ │ │ └── table.tsx │ │ ├── tabs │ │ │ ├── cardTabs.tsx │ │ │ ├── index.ts │ │ │ └── tabs.tsx │ │ ├── tag │ │ │ ├── closable.tsx │ │ │ ├── error.tsx │ │ │ ├── index.ts │ │ │ ├── info.tsx │ │ │ ├── multiTags.tsx │ │ │ ├── success.tsx │ │ │ ├── tag.tsx │ │ │ └── warning.tsx │ │ ├── timePicker │ │ │ ├── index.ts │ │ │ └── time-picker.tsx │ │ ├── timeline │ │ │ ├── danger.tsx │ │ │ ├── index.ts │ │ │ ├── success.tsx │ │ │ └── timeline.tsx │ │ ├── tooltip │ │ │ ├── index.ts │ │ │ └── tooltip.tsx │ │ ├── transfer │ │ │ ├── danger.tsx │ │ │ ├── data.ts │ │ │ ├── disabled.tsx │ │ │ ├── index.ts │ │ │ ├── transfer.tsx │ │ │ └── warning.tsx │ │ ├── tree │ │ │ ├── disabled.tsx │ │ │ ├── index.ts │ │ │ └── tree.tsx │ │ ├── treeSelect │ │ │ ├── disabled.tsx │ │ │ ├── index.ts │ │ │ └── tree-select.tsx │ │ ├── typography │ │ │ ├── Heading4.tsx │ │ │ ├── error.tsx │ │ │ ├── index.tsx │ │ │ ├── success.tsx │ │ │ ├── typography.tsx │ │ │ ├── typographyFull.tsx │ │ │ ├── warning.tsx │ │ │ ├── warningText.tsx │ │ │ └── warningTitle.tsx │ │ └── upload │ │ │ ├── avatar.tsx │ │ │ ├── danger.tsx │ │ │ ├── index.ts │ │ │ └── upload.tsx │ ├── overviews │ │ ├── Error.tsx │ │ ├── Primary.tsx │ │ ├── Success.tsx │ │ ├── Warning.tsx │ │ └── index.ts │ └── pages │ │ ├── dashboard │ │ └── index.tsx │ │ └── index.tsx ├── token-panel-pro │ ├── AliasPanel.tsx │ ├── ComponentDemoPro.tsx │ ├── InputNumberPlus.tsx │ ├── ResetTokenButton.tsx │ ├── TokenContent.tsx │ ├── TokenDetail.tsx │ ├── TokenPreview.tsx │ └── index.tsx ├── token-panel │ ├── index.tsx │ ├── token-card │ │ └── index.tsx │ └── token-item │ │ └── index.tsx └── utils │ ├── classifyToken.ts │ ├── constants.ts │ ├── deepUpdateObj.ts │ ├── getColorBgImg.ts │ ├── getDesignToken.ts │ ├── getValueByPath.ts │ ├── isColor.ts │ ├── makeStyle.tsx │ ├── parse-config.ts │ └── statistic.ts ├── tests ├── ComponentPanel.test.tsx ├── TokenInput.test.tsx ├── utils.test.tsx └── utils │ ├── setup.js │ └── setupAfterEnv.ts ├── tsconfig.json └── type.d.ts /.dumirc.ts: -------------------------------------------------------------------------------- 1 | // more config: https://d.umijs.org/config 2 | import { defineConfig } from 'dumi'; 3 | 4 | const isProdSite = 5 | // 不是预览模式 同时是生产环境 6 | process.env.PREVIEW !== '1' && process.env.NODE_ENV === 'production'; 7 | const sitePrefix = isProdSite ? '/antd-token-previewer' : ''; 8 | 9 | export default defineConfig({ 10 | themeConfig: { 11 | name: 'Theme Editor', 12 | sideBar: {}, 13 | nav: [ 14 | { title: 'Theme Editor', link: '/editor' }, 15 | { title: 'Previewer', link: '/previewer' }, 16 | { title: 'Others', link: '/others/color-panel' }, 17 | ], 18 | logo: `${sitePrefix}/icon/theme-editor.svg`, 19 | }, 20 | favicons: [`${sitePrefix}/icon/theme-editor.svg`], 21 | outputPath: '.doc', 22 | ssr: process.env.NODE_ENV === 'production' ? {} : false, 23 | exportStatic: {}, 24 | base: isProdSite ? '/antd-token-previewer/' : '/', 25 | publicPath: isProdSite ? '/antd-token-previewer/' : '/', 26 | hash: true, 27 | }); 28 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | 15 | [Makefile] 16 | indent_style = tab -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: [require.resolve('@umijs/fabric/dist/eslint')], 3 | ignorePatterns: ['src/icons/*'], 4 | rules: { 5 | 'no-template-curly-in-string': 0, 6 | 'prefer-promise-reject-errors': 0, 7 | 'react/no-array-index-key': 0, 8 | 'react/sort-comp': 0, 9 | '@typescript-eslint/no-explicit-any': 0, 10 | '@typescript-eslint/consistent-type-imports': 2, 11 | }, 12 | }; 13 | -------------------------------------------------------------------------------- /.fatherrc.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'father'; 2 | 3 | export default defineConfig({ 4 | plugins: ['@rc-component/father-plugin'], 5 | esm: { 6 | alias: { 7 | 'rc-util/lib': 'rc-util/es', 8 | 'antd/lib': 'antd/es', 9 | }, 10 | }, 11 | }); 12 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "npm" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "weekly" 12 | -------------------------------------------------------------------------------- /.github/workflows/preview.yml: -------------------------------------------------------------------------------- 1 | name: 🔂 Surge PR Preview 2 | 3 | on: [pull_request] 4 | 5 | jobs: 6 | preview: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | - uses: afc163/surge-preview@v1 11 | id: preview_step 12 | with: 13 | surge_token: ${{ secrets.SURGE_TOKEN }} 14 | github_token: ${{ secrets.GITHUB_TOKEN }} 15 | dist: .doc 16 | build: | 17 | npm install --force 18 | npm run docs:preview 19 | - name: Get the preview_url 20 | run: echo "url => ${{ steps.preview_step.outputs.preview_url }}" 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .storybook 2 | *.iml 3 | *.log 4 | .idea/ 5 | .ipr 6 | .iws 7 | *~ 8 | ~* 9 | *.diff 10 | *.patch 11 | *.bak 12 | .DS_Store 13 | Thumbs.db 14 | .project 15 | .*proj 16 | .svn/ 17 | *.swp 18 | *.swo 19 | *.pyc 20 | *.pyo 21 | .build 22 | node_modules 23 | .cache 24 | assets/**/*.css 25 | build 26 | lib 27 | es 28 | yarn.lock 29 | package-lock.json 30 | coverage/ 31 | .doc 32 | 33 | # umi 34 | .dumi/tmp 35 | .dumi/tmp-production 36 | .dumi/tmp-test 37 | server 38 | .env.local 39 | pnpm-lock.yaml 40 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | . "$(dirname -- "$0")/_/husky.sh" 3 | 4 | npx lint-staged 5 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | build/ 2 | *.cfg 3 | nohup.out 4 | *.iml 5 | .idea/ 6 | .ipr 7 | .iws 8 | *~ 9 | ~* 10 | *.diff 11 | *.log 12 | *.patch 13 | *.bak 14 | .DS_Store 15 | Thumbs.db 16 | .project 17 | .*proj 18 | .svn/ 19 | *.swp 20 | out/ 21 | .build 22 | node_modules 23 | .cache 24 | examples 25 | tests 26 | src 27 | /index.js 28 | .* 29 | public/**/*.less 30 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | .storybook 2 | node_modules 3 | lib 4 | es 5 | .cache 6 | package.json 7 | package-lock.json 8 | public 9 | .site 10 | _site 11 | .umi 12 | .doc 13 | .dumi/tmp 14 | .dumi/tmp-production 15 | server 16 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "endOfLine": "lf", 3 | "semi": true, 4 | "singleQuote": true, 5 | "tabWidth": 2, 6 | "trailingComma": "all" 7 | } 8 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2019-present afc163 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 6 | 7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # antd-token-previewer 🖥 2 | 3 | Help you customize theme in Ant Design. 4 | 5 | ![image](https://user-images.githubusercontent.com/27722486/235037764-54068c36-13de-4c06-9c7d-78b9a5475c28.png) 6 | 7 | ## Live Demo 8 | 9 | https://ant-design.github.io/antd-token-previewer/ 10 | 11 | ## Install 12 | 13 | ``` 14 | npm i antd-token-previewer 15 | ``` 16 | 17 | ## Usage 18 | 19 | Ref: https://ant-design.github.io/antd-token-previewer/editor 20 | 21 | ## API 22 | 23 | ### ThemeEditor 24 | 25 | | Property | Description | Type | Default | 26 | | ---------------- | ---------------------------------------- | ------------------------------ | ------- | 27 | | theme | Controlled Theme object | `Theme` | - | 28 | | onThemeChange | Callback when `theme` changed | `(theme: Theme) => void` | - | 29 | | locale | Language used in ThemeEditor | `Locale` | `zhCN` | 30 | | actions | Actions displayed on the right of header | `React.ReactNode` | - | 31 | | advanced | Advance mode | `boolean` | - | 32 | | onAdvancedChange | Callback when `advanced` change | `(advanced: booleaen) => void` | - | 33 | | children | Preview area. | `ReactNode` | - | 34 | 35 | ### Theme 36 | 37 | | Property | Description | Type | 38 | | -------- | ------------------------------ | ------------- | 39 | | name | Name of Theme | `string` | 40 | | key | Used as `key` for ReactElement | `string` | 41 | | config | Theme config of antd | `ThemeConfig` | 42 | 43 | ## Development 44 | 45 | ``` 46 | npm install 47 | npm start 48 | ``` 49 | 50 | ## License 51 | 52 | antd-token-previewer is released under the MIT license. 53 | -------------------------------------------------------------------------------- /docs/editor/index.md: -------------------------------------------------------------------------------- 1 | # Theme Editor 2 | 3 | 4 | -------------------------------------------------------------------------------- /docs/editor/v4-theme.md: -------------------------------------------------------------------------------- 1 | # V4 Theme 2 | 3 | 4 | -------------------------------------------------------------------------------- /docs/examples/color-panel.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import 'antd/es/style/reset.css'; 3 | import ColorPanel from '../../src/ColorPanel'; 4 | 5 | const Demo = () => { 6 | const [color, setColor] = React.useState('#1632ff'); 7 | 8 | return ( 9 | 10 | setColor(v)} /> 11 | 12 | ); 13 | }; 14 | 15 | export default Demo; 16 | -------------------------------------------------------------------------------- /docs/examples/overview-error.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Error } from 'antd-token-previewer'; 3 | 4 | const Demo = () => { 5 | return ( 6 |
7 |
8 | 9 |
10 |
11 | ); 12 | }; 13 | 14 | export default Demo; 15 | -------------------------------------------------------------------------------- /docs/examples/overview-primary.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Primary } from 'antd-token-previewer'; 3 | 4 | const Demo = () => { 5 | return ( 6 |
7 |
8 | 9 |
10 |
11 | ); 12 | }; 13 | 14 | export default Demo; 15 | -------------------------------------------------------------------------------- /docs/examples/overview-success.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Success } from 'antd-token-previewer'; 3 | 4 | const Demo = () => { 5 | return ( 6 |
7 |
8 | 9 |
10 |
11 | ); 12 | }; 13 | 14 | export default Demo; 15 | -------------------------------------------------------------------------------- /docs/examples/overview-warning.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Warning } from 'antd-token-previewer'; 3 | 4 | const Demo = () => { 5 | return ( 6 |
7 |
8 | 9 |
10 |
11 | ); 12 | }; 13 | 14 | export default Demo; 15 | -------------------------------------------------------------------------------- /docs/examples/preview-demo.tsx: -------------------------------------------------------------------------------- 1 | import { theme } from 'antd'; 2 | import { PreviewDemo } from 'antd-token-previewer'; 3 | import React from 'react'; 4 | 5 | const Demo = () => { 6 | return ( 7 | 18 | ); 19 | }; 20 | 21 | export default Demo; 22 | -------------------------------------------------------------------------------- /docs/examples/previewer-controlled.tsx: -------------------------------------------------------------------------------- 1 | import { ConfigProvider, message } from 'antd'; 2 | import type { Theme } from 'antd-token-previewer'; 3 | import { Previewer } from 'antd-token-previewer'; 4 | import React, { useEffect, useState } from 'react'; 5 | 6 | const ANT_DESIGN_V5_CUSTOM_THEME = 'ant-design-v5-custom-theme'; 7 | 8 | const Demo = () => { 9 | const [theme, setTheme] = useState({ 10 | name: '自定义主题', 11 | key: 'xiaozhuti', 12 | config: {}, 13 | }); 14 | const [messageApi, contextHolder] = message.useMessage(); 15 | 16 | useEffect(() => { 17 | const storedConfig = localStorage.getItem(ANT_DESIGN_V5_CUSTOM_THEME); 18 | if (storedConfig) { 19 | setTheme((prev) => ({ ...prev, config: JSON.parse(storedConfig) })); 20 | } 21 | }, []); 22 | 23 | return ( 24 | 25 | {contextHolder} 26 | setTheme({ ...theme, config })} 29 | onSave={(obj) => { 30 | localStorage.setItem(ANT_DESIGN_V5_CUSTOM_THEME, JSON.stringify(obj)); 31 | messageApi.success('保存成功'); 32 | }} 33 | /> 34 | 35 | ); 36 | }; 37 | 38 | export default Demo; 39 | -------------------------------------------------------------------------------- /docs/examples/previewer-token-panel.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Space } from 'antd'; 3 | import type { TokenPreviewProps } from 'antd-token-previewer'; 4 | import { TokenPanel } from 'antd-token-previewer'; 5 | 6 | export default () => { 7 | const tokens = [ 8 | { 9 | config: {}, 10 | key: 'default', 11 | name: '默认主题', 12 | }, 13 | ] as TokenPreviewProps['themes']; 14 | 15 | return ( 16 |
21 | 22 | 23 | 24 |
25 | ); 26 | }; 27 | -------------------------------------------------------------------------------- /docs/examples/previewer.tsx: -------------------------------------------------------------------------------- 1 | import { ConfigProvider } from 'antd'; 2 | import { Previewer } from 'antd-token-previewer'; 3 | import React from 'react'; 4 | 5 | const Demo = () => { 6 | return ( 7 | 8 | 9 | console.log(obj)} /> 10 | 11 | 12 | ); 13 | }; 14 | 15 | export default Demo; 16 | -------------------------------------------------------------------------------- /docs/examples/v4-theme.tsx: -------------------------------------------------------------------------------- 1 | import { darkAlgorithm, defaultTheme } from '@ant-design/compatible'; 2 | import { ConfigProvider } from 'antd'; 3 | import type { Theme } from 'antd-token-previewer'; 4 | import { ThemeEditor } from 'antd-token-previewer'; 5 | import 'antd/es/style/reset.css'; 6 | import React from 'react'; 7 | 8 | const Demo = () => { 9 | const [theme, setTheme] = React.useState({ 10 | name: 'antd 4.x', 11 | key: 'secret theme', 12 | config: defaultTheme, 13 | }); 14 | 15 | const handleThemeChange = (newTheme: Theme) => { 16 | setTheme(newTheme); 17 | }; 18 | 19 | return ( 20 | 21 | 22 | 28 | 29 | 30 | ); 31 | }; 32 | 33 | export default Demo; 34 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /docs/others/color-panel.md: -------------------------------------------------------------------------------- 1 | # Color Panel 2 | 3 | 4 | -------------------------------------------------------------------------------- /docs/others/overview.md: -------------------------------------------------------------------------------- 1 | # 总览组件 2 | 3 | ## 主色 4 | 5 | 6 | 7 | ## 成功色 8 | 9 | 10 | 11 | ## 警戒色 12 | 13 | 14 | 15 | ## 失败色 16 | 17 | 18 | 19 | ## 聚合 20 | 21 | 22 | -------------------------------------------------------------------------------- /docs/previewer/controlled.md: -------------------------------------------------------------------------------- 1 | # Previewer Controlled 2 | 3 | 4 | -------------------------------------------------------------------------------- /docs/previewer/index.md: -------------------------------------------------------------------------------- 1 | # Previewer 2 | 3 | 4 | -------------------------------------------------------------------------------- /docs/previewer/previewer-token-panel.md: -------------------------------------------------------------------------------- 1 | # Previewer Token Panel 2 | 3 | 4 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./src/'); 2 | -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | verbose: true, 3 | testEnvironment: 'jsdom', 4 | setupFiles: ['./tests/utils/setup.js'], 5 | setupFilesAfterEnv: ['./tests/utils/setupAfterEnv.ts'], 6 | transformIgnorePatterns: [ 7 | 'node_modules/(?!vanilla-jsoneditor|.*@(babel|antd))(?!array-move)[^/]+?/(?!(es|node_modules)/)', 8 | ], 9 | }; 10 | -------------------------------------------------------------------------------- /public/icon/theme-editor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ant-design/antd-token-previewer/e8068e12dd6e90569c9e9e0ad63b126e68463298/public/icon/theme-editor.png -------------------------------------------------------------------------------- /src/ColorPicker.tsx: -------------------------------------------------------------------------------- 1 | import type { ColorPickerProps } from 'antd'; 2 | import { ColorPicker as AntdColorPicker, theme as antdTheme } from 'antd'; 3 | import type { FC } from 'react'; 4 | import React, { useMemo } from 'react'; 5 | import { useLocale } from './locale'; 6 | 7 | const ColorPicker: FC = (props) => { 8 | const locale = useLocale(); 9 | const { token: antdToken } = antdTheme.useToken(); 10 | 11 | const presetColors = useMemo(() => { 12 | return [ 13 | antdToken.blue, 14 | antdToken.purple, 15 | antdToken.cyan, 16 | antdToken.green, 17 | antdToken.magenta, 18 | antdToken.red, 19 | antdToken.orange, 20 | antdToken.yellow, 21 | antdToken.volcano, 22 | antdToken.geekblue, 23 | antdToken.gold, 24 | antdToken.lime, 25 | '#000', 26 | ]; 27 | /* eslint-disable-next-line react-hooks/exhaustive-deps */ 28 | }, []); 29 | 30 | return ( 31 | 40 | ); 41 | }; 42 | 43 | export default ColorPicker; 44 | -------------------------------------------------------------------------------- /src/ColorPreview.tsx: -------------------------------------------------------------------------------- 1 | import classNames from 'classnames'; 2 | import type { FC } from 'react'; 3 | import React from 'react'; 4 | import getColorBgImg from './utils/getColorBgImg'; 5 | import makeStyle from './utils/makeStyle'; 6 | 7 | export type ColorPreviewProps = { 8 | color: string; 9 | dark?: boolean; 10 | className?: string; 11 | style?: React.CSSProperties; 12 | size?: number; 13 | }; 14 | 15 | const useStyle = makeStyle('ColorPreview', () => ({ 16 | '.previewer-color-preview': { 17 | position: 'relative', 18 | borderRadius: '50%', 19 | padding: 0, 20 | display: 'inline-block', 21 | 22 | '&::before': { 23 | content: '""', 24 | width: '100%', 25 | height: '100%', 26 | borderRadius: '50%', 27 | top: 0, 28 | insetInlineStart: 0, 29 | position: 'absolute', 30 | zIndex: 2, 31 | backgroundColor: 'var(--antd-token-previewer-color-preview)', 32 | boxShadow: 33 | '0 2px 3px -1px rgba(0,0,0,0.20), inset 0 0 0 1px rgba(0,0,0,0.09)', 34 | }, 35 | }, 36 | })); 37 | 38 | const ColorPreview: FC = ({ 39 | color, 40 | style, 41 | className, 42 | dark, 43 | size = 20, 44 | ...restProps 45 | }) => { 46 | const hashId = useStyle(); 47 | 48 | return ( 49 |
60 |
73 |
74 | ); 75 | }; 76 | 77 | export default ColorPreview; 78 | -------------------------------------------------------------------------------- /src/PreviewDemo.tsx: -------------------------------------------------------------------------------- 1 | import type { FC } from 'react'; 2 | import React from 'react'; 3 | import type { Theme } from './interface'; 4 | import ComponentDemoPro from './token-panel-pro/ComponentDemoPro'; 5 | 6 | export type PreviewDemoProps = { 7 | theme: Theme; 8 | style?: React.CSSProperties; 9 | }; 10 | 11 | const PreviewDemo: FC = ({ theme, style }) => { 12 | return ( 13 |
14 | 15 |
16 | ); 17 | }; 18 | 19 | export default PreviewDemo; 20 | -------------------------------------------------------------------------------- /src/component-token-editor/DemoCard.tsx: -------------------------------------------------------------------------------- 1 | import { Card, ConfigProvider, Tag, theme } from 'antd'; 2 | import type { FC } from 'react'; 3 | import React, { useMemo, useState } from 'react'; 4 | import type { ComponentDemo } from '../interface'; 5 | import { useLocale } from '../locale'; 6 | import { HIGHLIGHT_COLOR } from '../utils/constants'; 7 | 8 | export interface DemoCardProps { 9 | demo: ComponentDemo; 10 | } 11 | 12 | const DemoCard: FC = ({ demo: item }) => { 13 | const { token } = theme.useToken(); 14 | const locale = useLocale(); 15 | 16 | const [selectedTokens, setSelectedTokens] = useState([]); 17 | 18 | const toggle = (targetToken: string) => () => { 19 | setSelectedTokens((prev) => { 20 | return prev.includes(targetToken) 21 | ? prev.filter((t) => t !== targetToken) 22 | : [...prev, targetToken]; 23 | }); 24 | }; 25 | 26 | const tokenOverride = useMemo(() => { 27 | return selectedTokens.reduce((result, t) => { 28 | result[t] = HIGHLIGHT_COLOR; 29 | return result; 30 | }, {}); 31 | }, [selectedTokens]); 32 | 33 | const shownTokens = useMemo(() => { 34 | return item.tokens?.filter((t) => t.toLowerCase().includes('color')) ?? []; 35 | }, [item.tokens]); 36 | 37 | return ( 38 | 43 |
44 | 49 | {item.demo} 50 | 51 |
52 | {shownTokens.length > 0 && ( 53 |
61 |
62 | {locale.demo.relatedTokensDescription} 63 |
64 | {shownTokens.map((t) => ( 65 | 72 | {t} 73 | 74 | ))} 75 |
76 | )} 77 |
78 | ); 79 | }; 80 | 81 | export default DemoCard; 82 | -------------------------------------------------------------------------------- /src/component-token-editor/DemoWrapper.tsx: -------------------------------------------------------------------------------- 1 | import classNames from 'classnames'; 2 | import type { FC, PropsWithChildren } from 'react'; 3 | import React from 'react'; 4 | import makeStyle from '../utils/makeStyle'; 5 | 6 | const useStyle = makeStyle('ComponentTokenEditorDemoWrapper', (token) => ({ 7 | [`${token.componentCls}`]: { 8 | height: 0, 9 | overflow: 'auto', 10 | flex: 1, 11 | background: token.colorBgLayout, 12 | 13 | [`& > ${token.rootCls}-card`]: { 14 | margin: 24, 15 | width: 'calc(100% - 48px)', 16 | }, 17 | }, 18 | })); 19 | 20 | const DemoWrapper: FC = ({ children }) => { 21 | const prefixCls = `antd-component-token-editor-demo-wrapper`; 22 | 23 | const hashId = useStyle(prefixCls); 24 | 25 | return
{children}
; 26 | }; 27 | 28 | export default DemoWrapper; 29 | -------------------------------------------------------------------------------- /src/context/index.ts: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | type AdvancedType = boolean | undefined; 4 | 5 | export const AdvancedContext = React.createContext(false); 6 | 7 | export const useAdvanced = () => React.useContext(AdvancedContext); 8 | -------------------------------------------------------------------------------- /src/editor-modal/JSONEditor.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useRef } from 'react'; 2 | import type { JSONEditorPropsOptional } from 'vanilla-jsoneditor'; 3 | import { JSONEditor, Mode } from 'vanilla-jsoneditor'; 4 | 5 | const Editor: React.FC = (props) => { 6 | const editorRef = useRef(null); 7 | const container = useRef(null); 8 | 9 | useEffect(() => { 10 | editorRef.current = new JSONEditor({ 11 | target: container.current as HTMLDivElement, 12 | props: { mode: Mode.text }, 13 | }); 14 | return () => { 15 | editorRef.current?.destroy(); 16 | }; 17 | }, []); 18 | 19 | useEffect(() => { 20 | editorRef.current?.updateProps(props); 21 | }, [props]); 22 | 23 | return
; 24 | }; 25 | 26 | export default Editor; 27 | -------------------------------------------------------------------------------- /src/icons/Arrow.d.ts: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | declare const res: React.FC>; 4 | export default res; 5 | -------------------------------------------------------------------------------- /src/icons/Brush.d.ts: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | declare const res: React.FC>; 4 | export default res; 5 | -------------------------------------------------------------------------------- /src/icons/Compact.d.ts: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | declare const res: React.FC>; 4 | export default res; 5 | -------------------------------------------------------------------------------- /src/icons/Control.d.ts: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | declare const res: React.FC>; 4 | export default res; 5 | -------------------------------------------------------------------------------- /src/icons/Dark.d.ts: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | declare const res: React.FC>; 4 | export default res; 5 | -------------------------------------------------------------------------------- /src/icons/Light.d.ts: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | declare const res: React.FC>; 4 | export default res; 5 | -------------------------------------------------------------------------------- /src/icons/Margin.d.ts: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | declare const res: React.FC>; 4 | export default res; 5 | -------------------------------------------------------------------------------- /src/icons/Motion.d.ts: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | declare const res: React.FC>; 4 | export default res; 5 | -------------------------------------------------------------------------------- /src/icons/Pick.d.ts: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | declare const res: React.FC>; 4 | export default res; 5 | -------------------------------------------------------------------------------- /src/icons/SearchDropdown.d.ts: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | declare const res: React.FC>; 4 | export default res; 5 | -------------------------------------------------------------------------------- /src/icons/ShapeLine.d.ts: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | declare const res: React.FC>; 4 | export default res; 5 | -------------------------------------------------------------------------------- /src/icons/TokenPanel.d.ts: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | declare const res: React.FC>; 4 | export default res; 5 | -------------------------------------------------------------------------------- /src/icons/index.d.ts: -------------------------------------------------------------------------------- 1 | export { default as Margin } from './Margin.js'; 2 | export { default as Motion } from './Motion.js'; 3 | export { default as Pick } from './Pick.js'; 4 | export { default as ShapeLine } from './ShapeLine.js'; 5 | export { default as DarkTheme } from './Dark.js'; 6 | export { default as CompactTheme } from './Compact.js'; 7 | export { default as Control } from './Control.js'; 8 | export { default as Arrow } from './Arrow.js'; 9 | export { default as SearchDropdown } from './SearchDropdown.js'; 10 | export { default as TokenPanelIcon } from './TokenPanel.js'; 11 | export { default as Brush } from './Brush.js'; 12 | export { default as Light } from './Light.js'; 13 | -------------------------------------------------------------------------------- /src/icons/index.js: -------------------------------------------------------------------------------- 1 | export { default as Margin } from './Margin.js'; 2 | export { default as Motion } from './Motion.js'; 3 | export { default as Pick } from './Pick.js'; 4 | export { default as ShapeLine } from './ShapeLine.js'; 5 | export { default as DarkTheme } from './Dark.js'; 6 | export { default as CompactTheme } from './Compact.js'; 7 | export { default as Control } from './Control.js'; 8 | export { default as Arrow } from './Arrow.js'; 9 | export { default as SearchDropdown } from './SearchDropdown.js'; 10 | export { default as TokenPanelIcon } from './TokenPanel.js'; 11 | export { default as Brush } from './Brush.js'; 12 | export { default as Light } from './Light.js'; 13 | -------------------------------------------------------------------------------- /src/index.tsx: -------------------------------------------------------------------------------- 1 | export type { MutableTheme, PreviewerProps, Theme } from './interface'; 2 | export * from './locale'; 3 | export * from './meta'; 4 | export { default as PreviewDemo } from './PreviewDemo'; 5 | export type { PreviewDemoProps } from './PreviewDemo'; 6 | export { default as Previewer } from './previewer'; 7 | export * from './previews/overviews'; 8 | export { default as ThemeEditor } from './ThemeEditor'; 9 | export type { ThemeEditorProps, ThemeEditorRef } from './ThemeEditor'; 10 | export { default as TokenPanel } from './token-panel'; 11 | export type { TokenPanelRef, TokenPreviewProps } from './token-panel'; 12 | export { default as getDesignToken } from './utils/getDesignToken'; 13 | export { parsePlainConfig, parseThemeConfig } from './utils/parse-config'; 14 | -------------------------------------------------------------------------------- /src/interface.ts: -------------------------------------------------------------------------------- 1 | import type { ThemeConfig } from 'antd'; 2 | import type { ReactElement } from 'react'; 3 | 4 | export type Theme = { 5 | name: string; 6 | key: string; 7 | config: ThemeConfig; 8 | }; 9 | 10 | export type AliasToken = Exclude; 11 | export type TokenValue = string | number | string[] | number[] | boolean; 12 | export type TokenName = keyof AliasToken; 13 | 14 | export interface ComponentDemo { 15 | tokens?: TokenName[]; 16 | demo: ReactElement; 17 | key: string; 18 | } 19 | 20 | export interface MutableTheme extends Theme { 21 | onThemeChange?: (newTheme: ThemeConfig, path: string[]) => void; 22 | onReset?: (path: string[]) => void; 23 | onAbort?: (path: string[]) => void; 24 | getCanReset?: (path: string[]) => boolean; 25 | } 26 | 27 | export type PreviewerProps = { 28 | onSave?: (themeConfig: ThemeConfig) => void; 29 | showTheme?: boolean; 30 | theme?: Theme; 31 | onThemeChange?: (config: ThemeConfig) => void; 32 | }; 33 | 34 | export type SelectedToken = { 35 | seed?: string[]; 36 | map?: string[]; 37 | alias?: string[]; 38 | }; 39 | -------------------------------------------------------------------------------- /src/locale/context.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import type { Locale } from './interface'; 3 | import zhCN from './zh-CN'; 4 | 5 | export const LocaleContext = React.createContext(zhCN); 6 | 7 | export const useLocale = () => React.useContext(LocaleContext); 8 | -------------------------------------------------------------------------------- /src/locale/index.ts: -------------------------------------------------------------------------------- 1 | export { LocaleContext, useLocale } from './context'; 2 | export { default as enUS } from './en-US'; 3 | export type { Locale } from './interface'; 4 | export { default as zhCN } from './zh-CN'; 5 | -------------------------------------------------------------------------------- /src/meta/index.ts: -------------------------------------------------------------------------------- 1 | export { default as tokenCategory } from './category'; 2 | -------------------------------------------------------------------------------- /src/meta/interface.ts: -------------------------------------------------------------------------------- 1 | import type { ComponentTokenMap } from 'antd/es/theme/interface'; 2 | 3 | export interface TokenMeta { 4 | type: string; 5 | 6 | // Name 7 | name: string; 8 | nameEn: string; 9 | 10 | // Description 11 | desc: string; 12 | descEn: string; 13 | 14 | // Source 15 | source: 'seed' | 'map' | 'alias' | 'custom' | keyof ComponentTokenMap; 16 | } 17 | 18 | export type TokenMetaMap = Record; 19 | 20 | // 二级分类,如品牌色、中性色等 21 | export type TokenGroup = { 22 | key: string; 23 | 24 | // Group name 25 | name: string; 26 | nameEn: string; 27 | 28 | // Description 29 | desc: string; 30 | descEn: string; 31 | 32 | // Type 33 | type?: string; 34 | 35 | // Seed token 36 | seedToken?: T[]; 37 | mapToken?: T[]; 38 | aliasToken?: T[]; 39 | 40 | // Children Group 41 | groups?: TokenGroup[]; 42 | 43 | // Extra 44 | mapTokenGroups?: string[]; 45 | aliasTokenDescription?: string; 46 | }; 47 | 48 | // 一级分类,如颜色、尺寸等 49 | export type TokenCategory = { 50 | // Category name 51 | name: string; 52 | nameEn: string; 53 | 54 | // Description 55 | desc: string; 56 | descEn: string; 57 | 58 | groups: TokenGroup[]; 59 | }; 60 | 61 | export type TokenTree = TokenCategory[]; 62 | -------------------------------------------------------------------------------- /src/previews/components/alert/alert.tsx: -------------------------------------------------------------------------------- 1 | import { Alert, Space } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 | 7 | 8 | 9 | 10 | 11 | 12 | ); 13 | 14 | const componentDemo: ComponentDemo = { 15 | demo: , 16 | tokens: ['colorIconHover', 'colorIcon', 'colorText'], 17 | key: 'alert', 18 | }; 19 | 20 | export default componentDemo; 21 | -------------------------------------------------------------------------------- /src/previews/components/alert/error.tsx: -------------------------------------------------------------------------------- 1 | import { Alert, Space } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 | 7 | 8 | 9 | 15 | 16 | ); 17 | 18 | const componentDemo: ComponentDemo = { 19 | demo: , 20 | tokens: ['colorErrorBg', 'colorErrorBorder', 'colorError'], 21 | key: 'error', 22 | }; 23 | 24 | export default componentDemo; 25 | -------------------------------------------------------------------------------- /src/previews/components/alert/index.ts: -------------------------------------------------------------------------------- 1 | import Default from './alert'; 2 | import error from './error'; 3 | import info from './info'; 4 | import success from './success'; 5 | import warning from './warning'; 6 | 7 | import type { ComponentDemo } from '../../../interface'; 8 | 9 | const previewerDemo: ComponentDemo[] = [Default, error, info, success, warning]; 10 | 11 | export default previewerDemo; 12 | -------------------------------------------------------------------------------- /src/previews/components/alert/info.tsx: -------------------------------------------------------------------------------- 1 | import { Alert, Space } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 | 7 | 8 | 14 | 15 | ); 16 | 17 | const componentDemo: ComponentDemo = { 18 | demo: , 19 | tokens: ['colorInfo', 'colorInfoBorder', 'colorInfoBg'], 20 | key: 'info', 21 | }; 22 | 23 | export default componentDemo; 24 | -------------------------------------------------------------------------------- /src/previews/components/alert/success.tsx: -------------------------------------------------------------------------------- 1 | import { Alert, Space } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 | 7 | 8 | 14 | 15 | ); 16 | 17 | const componentDemo: ComponentDemo = { 18 | demo: , 19 | tokens: ['colorSuccess', 'colorSuccessBorder', 'colorSuccessBg'], 20 | key: 'success', 21 | }; 22 | 23 | export default componentDemo; 24 | -------------------------------------------------------------------------------- /src/previews/components/alert/warning.tsx: -------------------------------------------------------------------------------- 1 | import { Alert, Space } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 | 7 | 8 | 15 | 16 | ); 17 | 18 | const componentDemo: ComponentDemo = { 19 | demo: , 20 | tokens: ['colorWarning', 'colorWarningBorder', 'colorWarningBg'], 21 | key: 'warning', 22 | }; 23 | 24 | export default componentDemo; 25 | -------------------------------------------------------------------------------- /src/previews/components/anchor/anchor.tsx: -------------------------------------------------------------------------------- 1 | import { Anchor } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { Link } = Anchor; 6 | const Demo = () => { 7 | return ( 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | ); 19 | }; 20 | 21 | const componentDemo: ComponentDemo = { 22 | demo: , 23 | tokens: ['colorPrimary', 'colorSplit', 'colorBgContainer'], 24 | key: 'anchor', 25 | }; 26 | 27 | export default componentDemo; 28 | -------------------------------------------------------------------------------- /src/previews/components/anchor/anchorInLayout.tsx: -------------------------------------------------------------------------------- 1 | import { Anchor, theme } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { Link } = Anchor; 6 | const Demo = () => { 7 | const { token } = theme.useToken(); 8 | 9 | return ( 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | ); 21 | }; 22 | 23 | const componentDemo: ComponentDemo = { 24 | demo: , 25 | tokens: ['colorSplit'], 26 | key: 'anchorInLayout', 27 | }; 28 | 29 | export default componentDemo; 30 | -------------------------------------------------------------------------------- /src/previews/components/anchor/index.ts: -------------------------------------------------------------------------------- 1 | import Demo from './anchor'; 2 | import AnchorLayout from './anchorInLayout'; 3 | 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const previewerDemo: ComponentDemo[] = [Demo, AnchorLayout]; 7 | 8 | export default previewerDemo; 9 | -------------------------------------------------------------------------------- /src/previews/components/autoComplete/auto-complete.tsx: -------------------------------------------------------------------------------- 1 | import { AutoComplete } from 'antd'; 2 | import React, { useState } from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const mockVal = (str: string, repeat: number = 1) => ({ 6 | value: str.repeat(repeat), 7 | }); 8 | const Complete: React.FC = () => { 9 | const [value, setValue] = useState(''); 10 | const [options, setOptions] = useState<{ value: string }[]>([]); 11 | const onSearch = (searchText: string) => { 12 | setOptions( 13 | !searchText 14 | ? [] 15 | : [mockVal(searchText), mockVal(searchText, 2), mockVal(searchText, 3)], 16 | ); 17 | }; 18 | const onSelect = (data: string) => { 19 | // eslint-disable-next-line no-console 20 | console.log('onSelect', data); 21 | }; 22 | const onChange = (data: string) => { 23 | setValue(data); 24 | }; 25 | return ( 26 | <> 27 | {' '} 28 | {' '} 35 |

{' '} 36 | {' '} 45 | 46 | ); 47 | }; 48 | const Demo = () => ; 49 | 50 | const componentDemo: ComponentDemo = { 51 | demo: , 52 | tokens: [], 53 | key: 'autoComplete', 54 | }; 55 | 56 | export default componentDemo; 57 | -------------------------------------------------------------------------------- /src/previews/components/autoComplete/index.ts: -------------------------------------------------------------------------------- 1 | import Default from './auto-complete'; 2 | 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const previewerDemo: ComponentDemo[] = [Default]; 6 | 7 | export default previewerDemo; 8 | -------------------------------------------------------------------------------- /src/previews/components/avatar/avatar.tsx: -------------------------------------------------------------------------------- 1 | import { UserOutlined } from '@ant-design/icons'; 2 | import { Avatar, Space } from 'antd'; 3 | import React from 'react'; 4 | 5 | export default () => ( 6 | 7 | 8 | } /> 9 | } /> 10 | } /> 11 | } /> 12 | 13 | 14 | } /> 15 | } /> 16 | } /> 17 | } /> 18 | 19 | 20 | ); 21 | -------------------------------------------------------------------------------- /src/previews/components/avatar/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | 3 | import Default from './avatar'; 4 | // import Progress from './progress'; 5 | 6 | import type { ComponentDemo } from '../../../interface'; 7 | 8 | const previewerDemo: ComponentDemo[] = [ 9 | { 10 | demo: , 11 | key: 'default', 12 | }, 13 | ]; 14 | 15 | export default previewerDemo; 16 | -------------------------------------------------------------------------------- /src/previews/components/badge/badge.tsx: -------------------------------------------------------------------------------- 1 | import { ClockCircleFilled } from '@ant-design/icons'; 2 | import { Avatar, Badge, Space, theme } from 'antd'; 3 | import React from 'react'; 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const Demo = () => { 7 | const { token } = theme.useToken(); 8 | return ( 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | }> 17 | 18 | 19 | 20 | ); 21 | }; 22 | 23 | const componentDemo: ComponentDemo = { 24 | demo: , 25 | tokens: ['colorError', 'colorBorderBg', 'colorBgContainer'], 26 | key: 'badge', 27 | }; 28 | 29 | export default componentDemo; 30 | -------------------------------------------------------------------------------- /src/previews/components/badge/index.ts: -------------------------------------------------------------------------------- 1 | import Default from './badge'; 2 | import Progress from './progress'; 3 | import success from './success'; 4 | import warning from './warning'; 5 | 6 | import type { ComponentDemo } from '../../../interface'; 7 | 8 | const previewerDemo: ComponentDemo[] = [Default, Progress, warning, success]; 9 | 10 | export default previewerDemo; 11 | -------------------------------------------------------------------------------- /src/previews/components/badge/progress.tsx: -------------------------------------------------------------------------------- 1 | import { Badge, Space } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 | 7 | 8 | Process 9 | 10 | ); 11 | 12 | const componentDemo: ComponentDemo = { 13 | demo: , 14 | tokens: ['colorPrimary'], 15 | key: 'progress', 16 | }; 17 | 18 | export default componentDemo; 19 | -------------------------------------------------------------------------------- /src/previews/components/badge/success.tsx: -------------------------------------------------------------------------------- 1 | import { Badge, Space } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 | 7 | 8 | Success 9 | 10 | ); 11 | 12 | const componentDemo: ComponentDemo = { 13 | demo: , 14 | tokens: ['colorSuccess'], 15 | key: 'success', 16 | }; 17 | 18 | export default componentDemo; 19 | -------------------------------------------------------------------------------- /src/previews/components/badge/warning.tsx: -------------------------------------------------------------------------------- 1 | import { Badge, Space } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 | 7 | 8 | Warning 9 | 10 | ); 11 | 12 | const componentDemo: ComponentDemo = { 13 | demo: , 14 | tokens: ['colorWarning'], 15 | key: 'warning', 16 | }; 17 | 18 | export default componentDemo; 19 | -------------------------------------------------------------------------------- /src/previews/components/breadcrumb/breadcrumb.tsx: -------------------------------------------------------------------------------- 1 | import { Breadcrumb } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 | 7 | Home 8 | 9 | Application Center 10 | 11 | 12 | Application List 13 | 14 | An Application 15 | 16 | ); 17 | 18 | const componentDemo: ComponentDemo = { 19 | demo: , 20 | tokens: [ 21 | 'colorText', 22 | 'colorPrimary', 23 | 'colorPrimaryActive', 24 | 'colorPrimaryHover', 25 | ], 26 | key: 'breadcrumb', 27 | }; 28 | 29 | export default componentDemo; 30 | -------------------------------------------------------------------------------- /src/previews/components/breadcrumb/index.ts: -------------------------------------------------------------------------------- 1 | import Default from './breadcrumb'; 2 | 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const previewerDemo: ComponentDemo[] = [Default]; 6 | 7 | export default previewerDemo; 8 | -------------------------------------------------------------------------------- /src/previews/components/button/button-icon.tsx: -------------------------------------------------------------------------------- 1 | import { SearchOutlined } from '@ant-design/icons'; 2 | import { Button, Space, Tooltip } from 'antd'; 3 | import React from 'react'; 4 | 5 | import type { ComponentDemo } from '../../../interface'; 6 | 7 | const Demo = () => ( 8 | 9 | 10 | 11 | 16 | 19 | 20 | ); 21 | 22 | const componentDemo: ComponentDemo = { 23 | demo: , 24 | tokens: ['colorPrimary'], 25 | key: 'button-icon', 26 | }; 27 | 28 | export default componentDemo; 29 | -------------------------------------------------------------------------------- /src/previews/components/button/button.tsx: -------------------------------------------------------------------------------- 1 | import { Button, Space } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 |
14 | ); 15 | 16 | const componentDemo: ComponentDemo = { 17 | demo: , 18 | tokens: [ 19 | 'colorText', 20 | 'colorPrimary', 21 | 'colorPrimaryActive', 22 | 'colorPrimaryHover', 23 | 'controlOutline', 24 | 'controlTmpOutline', 25 | ], 26 | key: 'button', 27 | }; 28 | 29 | export default componentDemo; 30 | -------------------------------------------------------------------------------- /src/previews/components/button/dangerButton.tsx: -------------------------------------------------------------------------------- 1 | import { Button, Space } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 | 7 | 10 | 13 | 16 | {/**/} 19 | 22 | 23 | ); 24 | 25 | const componentDemo: ComponentDemo = { 26 | demo: , 27 | tokens: [ 28 | 'colorError', 29 | 'colorErrorActive', 30 | 'colorErrorHover', 31 | 'colorErrorBorder', 32 | 'colorErrorOutline', 33 | ], 34 | key: 'danger', 35 | }; 36 | 37 | export default componentDemo; 38 | -------------------------------------------------------------------------------- /src/previews/components/button/defaultButton.tsx: -------------------------------------------------------------------------------- 1 | import { Button } from 'antd'; 2 | import React from 'react'; 3 | 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const Demo = () => ; 7 | 8 | const componentDemo: ComponentDemo = { 9 | demo: , 10 | tokens: ['colorBgContainer'], 11 | key: 'defaultButton', 12 | }; 13 | 14 | export default componentDemo; 15 | -------------------------------------------------------------------------------- /src/previews/components/button/disabled.tsx: -------------------------------------------------------------------------------- 1 | import { Button, Space } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 | 7 | 10 | 11 | 14 |
15 | 18 | 21 | 24 |
25 | ); 26 | 27 | const componentDemo: ComponentDemo = { 28 | demo: , 29 | tokens: ['colorTextDisabled', 'colorBgContainerDisabled'], 30 | key: 'disabled', 31 | }; 32 | 33 | export default componentDemo; 34 | -------------------------------------------------------------------------------- /src/previews/components/button/index.ts: -------------------------------------------------------------------------------- 1 | import Default from './button'; 2 | import ButtonIconDemo from './button-icon'; 3 | import DangerButton from './dangerButton'; 4 | import DefaultButton from './defaultButton'; 5 | import disabled from './disabled'; 6 | 7 | import type { ComponentDemo } from '../../../interface'; 8 | 9 | const previewerDemo: ComponentDemo[] = [ 10 | Default, 11 | ButtonIconDemo, 12 | DangerButton, 13 | DefaultButton, 14 | disabled, 15 | ]; 16 | 17 | export default previewerDemo; 18 | -------------------------------------------------------------------------------- /src/previews/components/calendar/calendar.tsx: -------------------------------------------------------------------------------- 1 | import { Calendar } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ; 6 | 7 | const componentDemo: ComponentDemo = { 8 | demo: , 9 | tokens: ['colorPrimary', 'colorPrimaryHover', 'colorBgContainer'], 10 | key: 'default', 11 | }; 12 | 13 | export default componentDemo; 14 | -------------------------------------------------------------------------------- /src/previews/components/calendar/disabled.tsx: -------------------------------------------------------------------------------- 1 | import { Calendar } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => true} />; 6 | 7 | const componentDemo: ComponentDemo = { 8 | demo: , 9 | tokens: ['colorBgContainerDisabled', 'colorTextDisabled'], 10 | key: 'disabled', 11 | }; 12 | 13 | export default componentDemo; 14 | -------------------------------------------------------------------------------- /src/previews/components/calendar/index.ts: -------------------------------------------------------------------------------- 1 | import Default from './calendar'; 2 | import disabled from './disabled'; 3 | 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const previewerDemo: ComponentDemo[] = [Default, disabled]; 7 | 8 | export default previewerDemo; 9 | -------------------------------------------------------------------------------- /src/previews/components/card/card.tsx: -------------------------------------------------------------------------------- 1 | import { Card, Space } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 | 7 | More} 10 | style={{ width: 300 }} 11 | > 12 |

Card content

Card content

Card content

13 |
14 | More} 19 | style={{ width: 300 }} 20 | > 21 |

Card content

Card content

Card content

22 |
23 |
24 | ); 25 | 26 | const componentDemo: ComponentDemo = { 27 | demo: , 28 | tokens: [ 29 | 'colorText', 30 | 'colorTextHeading', 31 | 'colorTextSecondary', 32 | 'colorBgContainer', 33 | 'colorBorderSecondary', 34 | 'colorPrimary', 35 | 'colorBgContainer', 36 | ], 37 | key: 'card', 38 | }; 39 | 40 | export default componentDemo; 41 | -------------------------------------------------------------------------------- /src/previews/components/card/cardGrid.tsx: -------------------------------------------------------------------------------- 1 | import { Card } from 'antd'; 2 | import type { CSSProperties } from 'react'; 3 | import React from 'react'; 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const gridStyle: CSSProperties = { 7 | width: '25%', 8 | textAlign: 'center', 9 | }; 10 | 11 | const Demo = () => ( 12 | 13 | Content 14 | 15 | Content 16 | 17 | Content 18 | Content 19 | Content 20 | Content 21 | Content 22 | 23 | ); 24 | 25 | const componentDemo: ComponentDemo = { 26 | demo: , 27 | tokens: ['colorBorderSecondary'], 28 | key: 'cardGrid', 29 | }; 30 | 31 | export default componentDemo; 32 | -------------------------------------------------------------------------------- /src/previews/components/card/index.ts: -------------------------------------------------------------------------------- 1 | import Default from './card'; 2 | import cardGrid from './cardGrid'; 3 | import inner from './inner'; 4 | 5 | import type { ComponentDemo } from '../../../interface'; 6 | 7 | const previewerDemo: ComponentDemo[] = [Default, inner, cardGrid]; 8 | 9 | export default previewerDemo; 10 | -------------------------------------------------------------------------------- /src/previews/components/card/inner.tsx: -------------------------------------------------------------------------------- 1 | import { Card, Space } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 | 7 | 8 | Inner Card content 9 | 10 | 11 | ); 12 | 13 | const componentDemo: ComponentDemo = { 14 | demo: , 15 | tokens: ['colorFillAlter'], 16 | key: 'inner', 17 | }; 18 | 19 | export default componentDemo; 20 | -------------------------------------------------------------------------------- /src/previews/components/carousel/carousel.tsx: -------------------------------------------------------------------------------- 1 | import { Carousel } from 'antd'; 2 | import type { CSSProperties } from 'react'; 3 | import React from 'react'; 4 | 5 | import type { ComponentDemo } from '../../../interface'; 6 | 7 | const contentStyle = { 8 | height: '160px', 9 | color: '#fff', 10 | lineHeight: '160px', 11 | textAlign: 'center', 12 | background: '#364d79', 13 | }; 14 | const Demo = () => ( 15 | 16 |
17 |

1

18 |
19 |
20 |

2

21 |
22 |
23 |

3

24 |
25 |
26 |

4

27 |
28 |
29 | ); 30 | 31 | const componentDemo: ComponentDemo = { 32 | demo: , 33 | tokens: ['colorText', 'colorBgContainer'], 34 | key: 'default', 35 | }; 36 | 37 | export default componentDemo; 38 | -------------------------------------------------------------------------------- /src/previews/components/carousel/index.ts: -------------------------------------------------------------------------------- 1 | import Default from './carousel'; 2 | 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const previewerDemo: ComponentDemo[] = [Default]; 6 | 7 | export default previewerDemo; 8 | -------------------------------------------------------------------------------- /src/previews/components/cascader/cascader.tsx: -------------------------------------------------------------------------------- 1 | import { Cascader } from 'antd'; 2 | import React from 'react'; 3 | 4 | import type { ComponentDemo } from '../../../interface'; 5 | import options from './data'; 6 | const { _InternalPanelDoNotUseOrYouWillBeFired: InternalCascader } = Cascader; 7 | 8 | const Demo = (props: any) => ( 9 | 15 | ); 16 | 17 | const componentDemo: ComponentDemo = { 18 | demo: , 19 | tokens: ['colorBgContainer', 'colorPrimary'], 20 | key: 'default', 21 | }; 22 | 23 | export default componentDemo; 24 | -------------------------------------------------------------------------------- /src/previews/components/cascader/data.ts: -------------------------------------------------------------------------------- 1 | const options = [ 2 | { 3 | value: 'zhejiang', 4 | label: 'Zhejiang', 5 | children: [ 6 | { 7 | value: 'hangzhou', 8 | label: 'Hangzhou', 9 | children: [{ value: 'xihu', label: 'West Lake' }], 10 | }, 11 | ], 12 | }, 13 | { 14 | value: 'jiangsu', 15 | label: 'Jiangsu', 16 | children: [ 17 | { 18 | value: 'nanjing', 19 | label: 'Nanjing', 20 | children: [{ value: 'zhonghuamen', label: 'Zhong Hua Men' }], 21 | }, 22 | ], 23 | }, 24 | ]; 25 | 26 | export default options; 27 | -------------------------------------------------------------------------------- /src/previews/components/cascader/disable.tsx: -------------------------------------------------------------------------------- 1 | import { Cascader } from 'antd'; 2 | import React from 'react'; 3 | 4 | import type { ComponentDemo } from '../../../interface'; 5 | import options from './data'; 6 | 7 | const { _InternalPanelDoNotUseOrYouWillBeFired: InternalCascader } = Cascader; 8 | 9 | const Demo = () => ( 10 | 16 | ); 17 | 18 | const componentDemo: ComponentDemo = { 19 | demo: , 20 | tokens: ['colorBgContainerDisabled'], 21 | key: 'disabled', 22 | }; 23 | 24 | export default componentDemo; 25 | -------------------------------------------------------------------------------- /src/previews/components/cascader/highlight.tsx: -------------------------------------------------------------------------------- 1 | import { Cascader as _Cascader } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | import options from './data'; 6 | 7 | const { _InternalPanelDoNotUseOrYouWillBeFired: Cascader } = _Cascader; 8 | 9 | const Demo = () => { 10 | return ( 11 | 17 | ); 18 | }; 19 | 20 | const componentDemo: ComponentDemo = { 21 | demo: , 22 | tokens: ['colorHighlight'], 23 | key: 'highlight', 24 | }; 25 | 26 | export default componentDemo; 27 | -------------------------------------------------------------------------------- /src/previews/components/cascader/index.ts: -------------------------------------------------------------------------------- 1 | import Default from './cascader'; 2 | import disable from './disable'; 3 | import HighLight from './highlight'; 4 | 5 | import type { ComponentDemo } from '../../../interface'; 6 | 7 | const previewerDemo: ComponentDemo[] = [Default, HighLight, disable]; 8 | 9 | export default previewerDemo; 10 | -------------------------------------------------------------------------------- /src/previews/components/checkbox/checkbox.tsx: -------------------------------------------------------------------------------- 1 | import { Checkbox, Space } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = (props: any) => ( 6 | 7 | Checkbox 8 | 9 | 选中态 10 | 11 | 12 | ); 13 | 14 | const componentDemo: ComponentDemo = { 15 | demo: , 16 | tokens: ['colorPrimary', 'colorText', 'colorBgContainer'], 17 | key: 'default', 18 | }; 19 | 20 | export default componentDemo; 21 | -------------------------------------------------------------------------------- /src/previews/components/checkbox/disabled.tsx: -------------------------------------------------------------------------------- 1 | import { Checkbox } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => Checkbox; 6 | 7 | const componentDemo: ComponentDemo = { 8 | demo: , 9 | tokens: ['colorTextDisabled', 'colorBgContainerDisabled'], 10 | key: 'disabled', 11 | }; 12 | 13 | export default componentDemo; 14 | -------------------------------------------------------------------------------- /src/previews/components/checkbox/index.ts: -------------------------------------------------------------------------------- 1 | import Default from './checkbox'; 2 | import disabled from './disabled'; 3 | 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const previewerDemo: ComponentDemo[] = [Default, disabled]; 7 | 8 | export default previewerDemo; 9 | -------------------------------------------------------------------------------- /src/previews/components/collapse/collapse.tsx: -------------------------------------------------------------------------------- 1 | import { Collapse } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { Panel } = Collapse; 6 | const text = ` A dog is a type of domesticated animal. Known for its loyalty and faithfulness, it can be found as a welcome guest in many households across the world.`; 7 | 8 | const Demo = () => ( 9 | 10 | 11 |

{text}

12 |
13 | 14 |

{text}

15 |
16 | 17 |

{text}

18 |
19 |
20 | ); 21 | 22 | const componentDemo: ComponentDemo = { 23 | demo: , 24 | tokens: [ 25 | 'colorTextSecondary', 26 | 'colorText', 27 | 'colorFillAlter', 28 | 'colorBgContainer', 29 | ], 30 | key: 'default', 31 | }; 32 | 33 | export default componentDemo; 34 | -------------------------------------------------------------------------------- /src/previews/components/collapse/index.ts: -------------------------------------------------------------------------------- 1 | import Default from './collapse'; 2 | 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const previewerDemo: ComponentDemo[] = [Default]; 6 | 7 | export default previewerDemo; 8 | -------------------------------------------------------------------------------- /src/previews/components/datePicker/danger.tsx: -------------------------------------------------------------------------------- 1 | import { DatePicker } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ; 6 | 7 | const componentDemo: ComponentDemo = { 8 | demo: , 9 | tokens: [ 10 | 'colorError', 11 | 'colorErrorBorder', 12 | 'colorErrorHover', 13 | 'colorErrorOutline', 14 | ], 15 | key: 'danger', 16 | }; 17 | 18 | export default componentDemo; 19 | -------------------------------------------------------------------------------- /src/previews/components/datePicker/date-picker.tsx: -------------------------------------------------------------------------------- 1 | import { DatePicker, Space } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 | 7 | 8 | 9 | 10 | 11 | 12 | ); 13 | 14 | const componentDemo: ComponentDemo = { 15 | demo: , 16 | tokens: [ 17 | 'colorPrimary', 18 | 'colorPrimaryBorder', 19 | 'colorPrimaryHover', 20 | 'controlOutline', 21 | 'colorBgElevated', 22 | 'colorBgContainer', 23 | ], 24 | key: 'default', 25 | }; 26 | 27 | export default componentDemo; 28 | -------------------------------------------------------------------------------- /src/previews/components/datePicker/disabled.tsx: -------------------------------------------------------------------------------- 1 | import { DatePicker, Space } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | ); 14 | 15 | const componentDemo: ComponentDemo = { 16 | demo: , 17 | tokens: ['colorBgContainerDisabled', 'colorTextDisabled'], 18 | key: 'disabled', 19 | }; 20 | 21 | export default componentDemo; 22 | -------------------------------------------------------------------------------- /src/previews/components/datePicker/icon.tsx: -------------------------------------------------------------------------------- 1 | import { DatePicker } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ; 6 | 7 | const componentDemo: ComponentDemo = { 8 | demo: , 9 | tokens: ['colorIcon', 'colorIconHover'], 10 | key: 'icon', 11 | }; 12 | 13 | export default componentDemo; 14 | -------------------------------------------------------------------------------- /src/previews/components/datePicker/index.ts: -------------------------------------------------------------------------------- 1 | import danger from './danger'; 2 | import Default from './date-picker'; 3 | import disabled from './disabled'; 4 | import icon from './icon'; 5 | import warning from './warning'; 6 | 7 | import type { ComponentDemo } from '../../../interface'; 8 | 9 | const previewerDemo: ComponentDemo[] = [ 10 | Default, 11 | danger, 12 | warning, 13 | icon, 14 | disabled, 15 | ]; 16 | 17 | export default previewerDemo; 18 | -------------------------------------------------------------------------------- /src/previews/components/datePicker/warning.tsx: -------------------------------------------------------------------------------- 1 | import { DatePicker } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ; 6 | 7 | const componentDemo: ComponentDemo = { 8 | demo: , 9 | tokens: [ 10 | 'colorWarning', 11 | 'colorWarningBorder', 12 | 'colorWarningHover', 13 | 'colorWarningOutline', 14 | ], 15 | key: 'warning', 16 | }; 17 | 18 | export default componentDemo; 19 | -------------------------------------------------------------------------------- /src/previews/components/descriptions/descriptions.tsx: -------------------------------------------------------------------------------- 1 | import { Descriptions } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 | 7 | Cloud Database 8 | Prepaid 9 | YES 10 | 11 | 2018-04-24 18:00:00 12 | 13 | 14 | ); 15 | 16 | const componentDemo: ComponentDemo = { 17 | demo: , 18 | tokens: ['colorSplit', 'colorText', 'colorFillAlter'], 19 | key: 'default', 20 | }; 21 | 22 | export default componentDemo; 23 | -------------------------------------------------------------------------------- /src/previews/components/descriptions/index.ts: -------------------------------------------------------------------------------- 1 | import Default from './descriptions'; 2 | 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const previewerDemo: ComponentDemo[] = [Default]; 6 | 7 | export default previewerDemo; 8 | -------------------------------------------------------------------------------- /src/previews/components/divider/divider.tsx: -------------------------------------------------------------------------------- 1 | import { Divider } from 'antd'; 2 | import React from 'react'; 3 | 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const Demo = () => ( 7 | <> 8 |

9 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne 10 | merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, 11 | quo modo. 12 |

13 | Text 14 |

15 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne 16 | merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, 17 | quo modo. 18 |

19 | 20 | Left Text 21 | 22 |

23 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne 24 | merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, 25 | quo modo. 26 |

27 | 28 | Right Text 29 | 30 |

31 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nonne 32 | merninisti licere mihi ista probare, quae sunt a te dicta? Refert tamen, 33 | quo modo. 34 |

35 | 36 | ); 37 | 38 | const componentDemo: ComponentDemo = { 39 | demo: , 40 | tokens: ['colorSplit', 'colorText'], 41 | key: 'divider', 42 | }; 43 | 44 | export default componentDemo; 45 | -------------------------------------------------------------------------------- /src/previews/components/divider/index.ts: -------------------------------------------------------------------------------- 1 | import Default from './divider'; 2 | 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const previewerDemo: ComponentDemo[] = [Default]; 6 | 7 | export default previewerDemo; 8 | -------------------------------------------------------------------------------- /src/previews/components/drawer/drawer.tsx: -------------------------------------------------------------------------------- 1 | import { Button, Drawer } from 'antd'; 2 | import React, { useState } from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo: React.FC = () => { 6 | const [visible, setVisible] = useState(false); 7 | 8 | const showDrawer = () => { 9 | setVisible(true); 10 | }; 11 | 12 | const onClose = () => { 13 | setVisible(false); 14 | }; 15 | 16 | return ( 17 | <> 18 | 21 | 27 |

Some contents...

28 |

Some contents...

29 |

Some contents...

30 |
31 | 32 | ); 33 | }; 34 | 35 | const componentDemo: ComponentDemo = { 36 | demo: , 37 | tokens: ['colorBgMask', 'colorBgElevated'], 38 | key: 'default', 39 | }; 40 | 41 | export default componentDemo; 42 | -------------------------------------------------------------------------------- /src/previews/components/drawer/index.ts: -------------------------------------------------------------------------------- 1 | import Default from './drawer'; 2 | 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const previewerDemo: ComponentDemo[] = [Default]; 6 | 7 | export default previewerDemo; 8 | -------------------------------------------------------------------------------- /src/previews/components/dropdown/dropdown.tsx: -------------------------------------------------------------------------------- 1 | import { DownOutlined } from '@ant-design/icons'; 2 | import { Dropdown } from 'antd'; 3 | import React from 'react'; 4 | 5 | import menu from './menu'; 6 | 7 | import type { ComponentDemo } from '../../../interface'; 8 | 9 | const Demo = () => ( 10 | 16 | ); 17 | 18 | const componentDemo: ComponentDemo = { 19 | demo: , 20 | tokens: ['colorPrimary', 'colorError', 'colorErrorHover', 'colorBgElevated'], 21 | key: 'default', 22 | }; 23 | 24 | export default componentDemo; 25 | -------------------------------------------------------------------------------- /src/previews/components/dropdown/dropdownError.tsx: -------------------------------------------------------------------------------- 1 | import { DownOutlined } from '@ant-design/icons'; 2 | import { Dropdown, Typography } from 'antd'; 3 | import React from 'react'; 4 | 5 | import type { ComponentDemo } from '../../../interface'; 6 | 7 | const Demo = () => ( 8 |
9 | e.preventDefault()}> 10 | Hover me 11 | 12 | 33 |
34 | ); 35 | 36 | const componentDemo: ComponentDemo = { 37 | demo: , 38 | tokens: ['colorError', 'colorErrorHover', 'colorBgElevated'], 39 | key: 'default', 40 | }; 41 | 42 | export default componentDemo; 43 | -------------------------------------------------------------------------------- /src/previews/components/dropdown/index.ts: -------------------------------------------------------------------------------- 1 | import Default from './dropdown'; 2 | 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const previewerDemo: ComponentDemo[] = [Default]; 6 | 7 | export default previewerDemo; 8 | -------------------------------------------------------------------------------- /src/previews/components/dropdown/menu.tsx: -------------------------------------------------------------------------------- 1 | import { DownOutlined } from '@ant-design/icons'; 2 | import { Menu } from 'antd'; 3 | import React from 'react'; 4 | 5 | const menu = ( 6 | 7 | 8 | 13 | 1st menu item 14 | 15 | 16 | } disabled> 17 | 22 | 2nd menu item (disabled) 23 | 24 | 25 | 26 | 31 | 3rd menu item (disabled) 32 | 33 | 34 | a danger item 35 | 36 | ); 37 | 38 | export default menu; 39 | -------------------------------------------------------------------------------- /src/previews/components/empty/empty.tsx: -------------------------------------------------------------------------------- 1 | import { Empty } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ; 6 | 7 | const componentDemo: ComponentDemo = { 8 | demo: , 9 | tokens: ['colorTextDisabled'], 10 | key: 'default', 11 | }; 12 | 13 | export default componentDemo; 14 | -------------------------------------------------------------------------------- /src/previews/components/empty/index.ts: -------------------------------------------------------------------------------- 1 | import Default from './empty'; 2 | 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const previewerDemo: ComponentDemo[] = [Default]; 6 | 7 | export default previewerDemo; 8 | -------------------------------------------------------------------------------- /src/previews/components/form/danger.tsx: -------------------------------------------------------------------------------- 1 | import { Form, Input } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | function onFinish() {} 6 | 7 | const Demo = () => ( 8 |
16 | 22 | 23 | 24 |
25 | ); 26 | 27 | const componentDemo: ComponentDemo = { 28 | demo: , 29 | tokens: ['colorError', 'colorErrorBorder', 'colorErrorHover'], 30 | key: 'danger', 31 | }; 32 | 33 | export default componentDemo; 34 | -------------------------------------------------------------------------------- /src/previews/components/form/form.tsx: -------------------------------------------------------------------------------- 1 | import { Button, Checkbox, Form, Input } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => { 6 | const onFinish = () => {}; 7 | const onFinishFailed = () => {}; 8 | return ( 9 |
18 | 23 | 24 | 25 | 30 | 31 | 32 | 37 | Remember me 38 | 39 | 40 | 43 | 44 |
45 | ); 46 | }; 47 | 48 | const componentDemo: ComponentDemo = { 49 | demo: , 50 | tokens: [ 51 | 'colorError', 52 | 'controlOutline', 53 | 'colorErrorBorder', 54 | 'colorErrorHover', 55 | ], 56 | key: 'default', 57 | }; 58 | 59 | export default componentDemo; 60 | -------------------------------------------------------------------------------- /src/previews/components/form/index.tsx: -------------------------------------------------------------------------------- 1 | import Default from './form'; 2 | 3 | import danger from './danger'; 4 | import warning from './warning'; 5 | 6 | import type { ComponentDemo } from '../../../interface'; 7 | 8 | const previewerDemo: ComponentDemo[] = [Default, warning, danger]; 9 | 10 | export default previewerDemo; 11 | -------------------------------------------------------------------------------- /src/previews/components/form/warning.tsx: -------------------------------------------------------------------------------- 1 | import { Form, Input } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | function onFinish() {} 6 | 7 | const Demo = () => ( 8 |
16 | 22 | 23 | 24 |
25 | ); 26 | 27 | const componentDemo: ComponentDemo = { 28 | demo: , 29 | tokens: ['colorWarning'], 30 | key: 'warning', 31 | }; 32 | 33 | export default componentDemo; 34 | -------------------------------------------------------------------------------- /src/previews/components/grid/grid.tsx: -------------------------------------------------------------------------------- 1 | import { Col, Row } from 'antd'; 2 | import classNames from 'classnames'; 3 | import React from 'react'; 4 | import type { ComponentDemo } from '../../../interface'; 5 | import makeStyle from '../../../utils/makeStyle'; 6 | 7 | const useStyle = makeStyle('GridDemo', (token) => ({ 8 | '.previewer-grid-demo': { 9 | [`${token.rootCls}-row`]: { 10 | marginBottom: 16, 11 | }, 12 | [`${token.rootCls}-row > div:not(.gutter-row)`]: { 13 | padding: '16px 0', 14 | background: '#0092ff', 15 | color: '#fff', 16 | display: 'inline-flex', 17 | alignItems: 'center', 18 | justifyContent: 'center', 19 | 20 | '&:nth-child(2n + 1)': { 21 | background: 'rgba(0,146,255,.75)', 22 | }, 23 | }, 24 | }, 25 | })); 26 | 27 | const Demo = () => { 28 | const [, hashId] = useStyle(); 29 | 30 | return ( 31 |
32 | 33 | col 34 | 35 | 36 | col-12 col-12 37 | 38 | 39 | col-8 col-8 40 | col-8 41 | 42 | 43 | col-6 col-6 44 | col-6 45 | col-6 46 | 47 |
48 | ); 49 | }; 50 | 51 | const componentDemo: ComponentDemo = { 52 | demo: , 53 | key: 'default', 54 | }; 55 | 56 | export default componentDemo; 57 | -------------------------------------------------------------------------------- /src/previews/components/grid/index.ts: -------------------------------------------------------------------------------- 1 | import Default from './grid'; 2 | 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const previewerDemo: ComponentDemo[] = [Default]; 6 | 7 | export default previewerDemo; 8 | -------------------------------------------------------------------------------- /src/previews/components/icon/icon.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | HomeOutlined, 3 | LoadingOutlined, 4 | SettingFilled, 5 | SmileOutlined, 6 | SyncOutlined, 7 | } from '@ant-design/icons'; 8 | import { Space } from 'antd'; 9 | import React from 'react'; 10 | import type { ComponentDemo } from '../../../interface'; 11 | 12 | const Demo = () => ( 13 | 14 | 15 | 16 | 17 | ); 18 | 19 | const componentDemo: ComponentDemo = { 20 | demo: , 21 | key: 'default', 22 | }; 23 | 24 | export default componentDemo; 25 | -------------------------------------------------------------------------------- /src/previews/components/icon/index.ts: -------------------------------------------------------------------------------- 1 | import Default from './icon'; 2 | 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const previewerDemo: ComponentDemo[] = [Default]; 6 | 7 | export default previewerDemo; 8 | -------------------------------------------------------------------------------- /src/previews/components/image/disabled.tsx: -------------------------------------------------------------------------------- 1 | import { Image } from 'antd'; 2 | import React from 'react'; 3 | 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const Demo = () => { 7 | return ; 8 | }; 9 | 10 | const componentDemo: ComponentDemo = { 11 | demo: , 12 | tokens: ['colorBgContainerDisabled'], 13 | key: 'disabled', 14 | }; 15 | 16 | export default componentDemo; 17 | -------------------------------------------------------------------------------- /src/previews/components/image/image.tsx: -------------------------------------------------------------------------------- 1 | import { Image } from 'antd'; 2 | import React from 'react'; 3 | 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const Demo = () => { 7 | return ( 8 | 12 | ); 13 | }; 14 | 15 | const componentDemo: ComponentDemo = { 16 | demo: , 17 | tokens: ['colorBgMask'], 18 | key: 'default', 19 | }; 20 | 21 | export default componentDemo; 22 | -------------------------------------------------------------------------------- /src/previews/components/image/index.ts: -------------------------------------------------------------------------------- 1 | import disabled from './disabled'; 2 | import Default from './image'; 3 | 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const previewerDemo: ComponentDemo[] = [Default, disabled]; 7 | 8 | export default previewerDemo; 9 | -------------------------------------------------------------------------------- /src/previews/components/input/clearIcon.tsx: -------------------------------------------------------------------------------- 1 | import { Input } from 'antd'; 2 | import React from 'react'; 3 | 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const Demo = () => ( 7 | 12 | ); 13 | 14 | const componentDemo: ComponentDemo = { 15 | demo: , 16 | tokens: ['colorIcon', 'colorIconHover'], 17 | key: 'clearIcon', 18 | }; 19 | export default componentDemo; 20 | -------------------------------------------------------------------------------- /src/previews/components/input/danger.tsx: -------------------------------------------------------------------------------- 1 | import { Input } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | function onChange() {} 6 | 7 | const Demo = () => ( 8 | 9 | ); 10 | 11 | const componentDemo: ComponentDemo = { 12 | demo: , 13 | tokens: [ 14 | 'colorError', 15 | 'colorErrorOutline', 16 | 'colorErrorBorder', 17 | 'colorErrorHover', 18 | ], 19 | key: 'danger', 20 | }; 21 | 22 | export default componentDemo; 23 | -------------------------------------------------------------------------------- /src/previews/components/input/disabled.tsx: -------------------------------------------------------------------------------- 1 | import { Input } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ; 6 | 7 | const componentDemo: ComponentDemo = { 8 | demo: , 9 | tokens: ['colorBgContainerDisabled'], 10 | key: 'disabled', 11 | }; 12 | 13 | export default componentDemo; 14 | -------------------------------------------------------------------------------- /src/previews/components/input/index.ts: -------------------------------------------------------------------------------- 1 | import clearIcon from './clearIcon'; 2 | import danger from './danger'; 3 | import disabled from './disabled'; 4 | import Default from './input'; 5 | import warning from './warning'; 6 | import withAddon from './withAddon'; 7 | 8 | import type { ComponentDemo } from '../../../interface'; 9 | 10 | const previewerDemo: ComponentDemo[] = [ 11 | Default, 12 | clearIcon, 13 | danger, 14 | warning, 15 | withAddon, 16 | disabled, 17 | ]; 18 | 19 | export default previewerDemo; 20 | -------------------------------------------------------------------------------- /src/previews/components/input/input.tsx: -------------------------------------------------------------------------------- 1 | import { Input } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ; 6 | 7 | const componentDemo: ComponentDemo = { 8 | demo: , 9 | tokens: [ 10 | 'colorPrimary', 11 | 'colorPrimaryHover', 12 | 'controlOutline', 13 | 'colorBgContainer', 14 | ], 15 | key: 'default', 16 | }; 17 | 18 | export default componentDemo; 19 | -------------------------------------------------------------------------------- /src/previews/components/input/success.tsx: -------------------------------------------------------------------------------- 1 | import { CheckCircleFilled } from '@ant-design/icons'; 2 | import { Input, theme } from 'antd'; 3 | import React from 'react'; 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | function onChange() {} 7 | 8 | const Demo = () => { 9 | const { token } = theme.useToken(); 10 | return ( 11 | } 14 | onChange={onChange} 15 | /> 16 | ); 17 | }; 18 | 19 | const componentDemo: ComponentDemo = { 20 | demo: , 21 | tokens: ['colorSuccess'], 22 | key: 'warning', 23 | }; 24 | 25 | export default componentDemo; 26 | -------------------------------------------------------------------------------- /src/previews/components/input/warning.tsx: -------------------------------------------------------------------------------- 1 | import { Input } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | function onChange() {} 6 | 7 | const Demo = () => ( 8 | 9 | ); 10 | 11 | const componentDemo: ComponentDemo = { 12 | demo: , 13 | tokens: [ 14 | 'colorWarning', 15 | 'colorWarningBorder', 16 | 'colorWarningHover', 17 | 'colorWarningOutline', 18 | ], 19 | key: 'warning', 20 | }; 21 | 22 | export default componentDemo; 23 | -------------------------------------------------------------------------------- /src/previews/components/input/withAddon.tsx: -------------------------------------------------------------------------------- 1 | import { Input } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 | 7 | ); 8 | 9 | const componentDemo: ComponentDemo = { 10 | demo: , 11 | tokens: ['colorFillAlter'], 12 | key: 'withAddon', 13 | }; 14 | 15 | export default componentDemo; 16 | -------------------------------------------------------------------------------- /src/previews/components/inputNumber/danger.tsx: -------------------------------------------------------------------------------- 1 | import { InputNumber } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | function onChange() {} 6 | 7 | const Demo = () => ( 8 | 15 | ); 16 | 17 | const componentDemo: ComponentDemo = { 18 | demo: , 19 | tokens: [ 20 | 'colorErrorBorder', 21 | 'colorErrorOutline', 22 | 'colorErrorHover', 23 | 'colorError', 24 | ], 25 | key: 'danger', 26 | }; 27 | 28 | export default componentDemo; 29 | -------------------------------------------------------------------------------- /src/previews/components/inputNumber/disabled.tsx: -------------------------------------------------------------------------------- 1 | import { InputNumber } from 'antd'; 2 | import React from 'react'; 3 | 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const Demo = () => ; 7 | const componentDemo: ComponentDemo = { 8 | demo: , 9 | tokens: ['colorBgContainerDisabled'], 10 | key: 'disabled', 11 | }; 12 | 13 | export default componentDemo; 14 | -------------------------------------------------------------------------------- /src/previews/components/inputNumber/index.ts: -------------------------------------------------------------------------------- 1 | import danger from './danger'; 2 | import disabled from './disabled'; 3 | import Default from './inputNumber'; 4 | import warning from './warning'; 5 | 6 | import type { ComponentDemo } from '../../../interface'; 7 | 8 | const previewerDemo: ComponentDemo[] = [Default, danger, warning, disabled]; 9 | 10 | export default previewerDemo; 11 | -------------------------------------------------------------------------------- /src/previews/components/inputNumber/inputNumber.tsx: -------------------------------------------------------------------------------- 1 | import { InputNumber } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | function onChange() {} 6 | const Demo = () => ( 7 | 8 | ); 9 | 10 | const componentDemo: ComponentDemo = { 11 | demo: , 12 | tokens: [ 13 | 'colorPrimaryBorder', 14 | 'controlOutline', 15 | 'colorPrimaryHover', 16 | 'colorPrimary', 17 | 'colorBgContainer', 18 | ], 19 | key: 'default', 20 | }; 21 | 22 | export default componentDemo; 23 | -------------------------------------------------------------------------------- /src/previews/components/inputNumber/warning.tsx: -------------------------------------------------------------------------------- 1 | import { InputNumber } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | function onChange() {} 6 | 7 | const Demo = () => ( 8 | 15 | ); 16 | 17 | const componentDemo: ComponentDemo = { 18 | demo: , 19 | tokens: [ 20 | 'colorWarning', 21 | 'colorWarningBorder', 22 | 'colorWarningOutline', 23 | 'colorWarningHover', 24 | ], 25 | key: 'warning', 26 | }; 27 | 28 | export default componentDemo; 29 | -------------------------------------------------------------------------------- /src/previews/components/layout/index.ts: -------------------------------------------------------------------------------- 1 | import topSide2 from './top-side-2'; 2 | 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const previewerDemo: ComponentDemo[] = [topSide2]; 6 | 7 | export default previewerDemo; 8 | -------------------------------------------------------------------------------- /src/previews/components/list/index.ts: -------------------------------------------------------------------------------- 1 | import Default from './list'; 2 | 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const previewerDemo: ComponentDemo[] = [Default]; 6 | 7 | export default previewerDemo; 8 | -------------------------------------------------------------------------------- /src/previews/components/list/list.tsx: -------------------------------------------------------------------------------- 1 | import { Avatar, List } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const data = [ 6 | { title: 'Ant Design Title 1' }, 7 | { title: 'Ant Design Title 2' }, 8 | { title: 'Ant Design Title 3' }, 9 | { title: 'Ant Design Title 4' }, 10 | ]; 11 | const Demo = () => ( 12 | ( 16 | 17 | } 19 | title={{item.title}} 20 | description="Ant Design, a design language for background applications, is refined by Ant UED Team" 21 | /> 22 | 23 | )} 24 | /> 25 | ); 26 | 27 | const componentDemo: ComponentDemo = { 28 | demo: , 29 | tokens: [], 30 | key: 'default', 31 | }; 32 | 33 | export default componentDemo; 34 | -------------------------------------------------------------------------------- /src/previews/components/mentions/danger.tsx: -------------------------------------------------------------------------------- 1 | import { Mentions } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { Option } = Mentions; 6 | function onChange() {} 7 | function onSelect() {} 8 | 9 | const Demo = () => ( 10 | 17 | 18 | 19 | 20 | 21 | ); 22 | 23 | const componentDemo: ComponentDemo = { 24 | demo: , 25 | tokens: [ 26 | 'colorError', 27 | 'colorErrorOutline', 28 | 'colorErrorBorder', 29 | 'colorErrorHover', 30 | ], 31 | key: 'danger', 32 | }; 33 | 34 | export default componentDemo; 35 | -------------------------------------------------------------------------------- /src/previews/components/mentions/disabled.tsx: -------------------------------------------------------------------------------- 1 | import { Mentions } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { Option } = Mentions; 6 | 7 | const Demo = () => ( 8 | 14 | 15 | 16 | 17 | 18 | ); 19 | 20 | const componentDemo: ComponentDemo = { 21 | demo: , 22 | tokens: ['colorBgContainerDisabled', 'colorTextDisabled'], 23 | key: 'disabled', 24 | }; 25 | 26 | export default componentDemo; 27 | -------------------------------------------------------------------------------- /src/previews/components/mentions/index.ts: -------------------------------------------------------------------------------- 1 | import danger from './danger'; 2 | import disabled from './disabled'; 3 | import Default from './mentions'; 4 | import warning from './warning'; 5 | 6 | import type { ComponentDemo } from '../../../interface'; 7 | 8 | const previewerDemo: ComponentDemo[] = [Default, danger, warning, disabled]; 9 | 10 | export default previewerDemo; 11 | -------------------------------------------------------------------------------- /src/previews/components/mentions/mentions.tsx: -------------------------------------------------------------------------------- 1 | import { Mentions } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { Option } = Mentions; 6 | function onChange() {} 7 | function onSelect() {} 8 | const Demo = () => ( 9 | 15 | 16 | 17 | 18 | 19 | ); 20 | 21 | const componentDemo: ComponentDemo = { 22 | demo: , 23 | tokens: [ 24 | 'colorBgContainer', 25 | 'colorBorder', 26 | 'colorPrimary', 27 | 'colorPrimaryHover', 28 | 'controlOutline', 29 | ], 30 | key: 'default', 31 | }; 32 | 33 | export default componentDemo; 34 | -------------------------------------------------------------------------------- /src/previews/components/mentions/warning.tsx: -------------------------------------------------------------------------------- 1 | import { Mentions } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { Option } = Mentions; 6 | function onChange() {} 7 | function onSelect() {} 8 | 9 | const Demo = () => ( 10 | 17 | 18 | 19 | 20 | 21 | ); 22 | 23 | const componentDemo: ComponentDemo = { 24 | demo: , 25 | tokens: [ 26 | 'colorWarning', 27 | 'colorWarningBorder', 28 | 'colorWarningHover', 29 | 'colorWarningOutline', 30 | ], 31 | key: 'warning', 32 | }; 33 | 34 | export default componentDemo; 35 | -------------------------------------------------------------------------------- /src/previews/components/menu/data.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | AppstoreOutlined, 3 | MailOutlined, 4 | SettingOutlined, 5 | } from '@ant-design/icons'; 6 | import type { MenuProps } from 'antd'; 7 | import React from 'react'; 8 | 9 | type MenuItem = Required['items'][number]; 10 | 11 | const getItem = ( 12 | label: React.ReactNode, 13 | key: React.Key, 14 | icon?: React.ReactNode, 15 | children?: MenuItem[], 16 | type?: 'group', 17 | ): MenuItem => 18 | ({ 19 | key, 20 | icon, 21 | children, 22 | label, 23 | type, 24 | } as MenuItem); 25 | 26 | const items: MenuProps['items'] = [ 27 | getItem('Navigation One', 'sub1', , [ 28 | getItem( 29 | 'Item 1', 30 | 'g1', 31 | null, 32 | [getItem('Option 1', '1'), getItem('Option 2', '2')], 33 | 'group', 34 | ), 35 | getItem( 36 | 'Item 2', 37 | 'g2', 38 | null, 39 | [getItem('Option 3', '3'), getItem('Option 4', '4')], 40 | 'group', 41 | ), 42 | ]), 43 | 44 | getItem('Navigation Two', 'sub2', , [ 45 | getItem('Option 5', '5'), 46 | getItem('Option 6', '6'), 47 | getItem('Submenu', 'sub3', null, [ 48 | getItem('Option 7', '7'), 49 | getItem('Option 8', '8'), 50 | ]), 51 | ]), 52 | 53 | getItem('Navigation Three', 'sub4', , [ 54 | getItem('Option 9', '9'), 55 | getItem('Option 10', '10'), 56 | getItem('Option 11', '11'), 57 | getItem('Option 12', '12'), 58 | ]), 59 | ]; 60 | 61 | export default items; 62 | -------------------------------------------------------------------------------- /src/previews/components/menu/index.ts: -------------------------------------------------------------------------------- 1 | import Default from './menu'; 2 | import danger from './menuDanger'; 3 | import MenuInLayout from './menuInLayout'; 4 | 5 | import type { ComponentDemo } from '../../../interface'; 6 | 7 | const previewerDemo: ComponentDemo[] = [Default, danger, MenuInLayout]; 8 | 9 | export default previewerDemo; 10 | -------------------------------------------------------------------------------- /src/previews/components/menu/menu.tsx: -------------------------------------------------------------------------------- 1 | import type { MenuProps } from 'antd'; 2 | import { Menu } from 'antd'; 3 | import React from 'react'; 4 | 5 | import items from './data'; 6 | 7 | import type { ComponentDemo } from '../../../interface'; 8 | 9 | const Demo: React.FC = () => { 10 | const onClick: MenuProps['onClick'] = (e) => { 11 | console.log('click ', e); 12 | }; 13 | 14 | return ( 15 |
16 | 24 |
25 | ); 26 | }; 27 | 28 | const componentDemo: ComponentDemo = { 29 | demo: , 30 | tokens: [ 31 | 'colorPrimary', 32 | 'colorBgContainer', 33 | 'colorFillAlter', 34 | 'colorSplit', 35 | 'colorPrimaryHover', 36 | ], 37 | key: 'default', 38 | }; 39 | 40 | export default componentDemo; 41 | -------------------------------------------------------------------------------- /src/previews/components/menu/menuDanger.tsx: -------------------------------------------------------------------------------- 1 | import type { MenuProps } from 'antd'; 2 | import { Menu } from 'antd'; 3 | import React from 'react'; 4 | 5 | import type { ComponentDemo } from '../../../interface'; 6 | 7 | const items: MenuProps['items'] = [ 8 | { 9 | key: '0', 10 | danger: true, 11 | label: '危险', 12 | }, 13 | { 14 | key: '1', 15 | danger: true, 16 | label: '危险选中', 17 | }, 18 | { 19 | key: '2', 20 | danger: true, 21 | disabled: true, 22 | label: '危险禁用', 23 | }, 24 | ]; 25 | 26 | const Demo: React.FC = () => { 27 | const onClick: MenuProps['onClick'] = (e) => { 28 | console.log('click ', e); 29 | }; 30 | 31 | return ( 32 | 38 | ); 39 | }; 40 | 41 | const componentDemo: ComponentDemo = { 42 | demo: , 43 | tokens: ['colorError', 'colorErrorHover', 'colorErrorOutline'], 44 | key: 'danger', 45 | }; 46 | 47 | export default componentDemo; 48 | -------------------------------------------------------------------------------- /src/previews/components/menu/menuInLayout.tsx: -------------------------------------------------------------------------------- 1 | import { Menu, theme } from 'antd'; 2 | import React from 'react'; 3 | 4 | import items from './data'; 5 | 6 | import type { ComponentDemo } from '../../../interface'; 7 | 8 | const Demo: React.FC = () => { 9 | const { token } = theme.useToken(); 10 | return ( 11 |
12 | 19 |
20 | ); 21 | }; 22 | 23 | const componentDemo: ComponentDemo = { 24 | demo: , 25 | tokens: ['colorSplit'], 26 | key: 'menuInLayout', 27 | }; 28 | 29 | export default componentDemo; 30 | -------------------------------------------------------------------------------- /src/previews/components/message/error.tsx: -------------------------------------------------------------------------------- 1 | import { message } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { _InternalPanelDoNotUseOrYouWillBeFired } = message; 6 | 7 | const Demo = () => ( 8 | <_InternalPanelDoNotUseOrYouWillBeFired 9 | type={'error'} 10 | content={'这是一条异常消息,会主动消失'} 11 | /> 12 | ); 13 | 14 | const componentDemo: ComponentDemo = { 15 | demo: , 16 | tokens: ['colorError'], 17 | key: 'error', 18 | }; 19 | 20 | export default componentDemo; 21 | -------------------------------------------------------------------------------- /src/previews/components/message/index.ts: -------------------------------------------------------------------------------- 1 | import error from './error'; 2 | import info from './info'; 3 | import Default from './message'; 4 | import success from './success'; 5 | import warning from './warning'; 6 | 7 | import type { ComponentDemo } from '../../../interface'; 8 | 9 | const previewerDemo: ComponentDemo[] = [Default, error, info, success, warning]; 10 | 11 | export default previewerDemo; 12 | -------------------------------------------------------------------------------- /src/previews/components/message/info.tsx: -------------------------------------------------------------------------------- 1 | import { message } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { _InternalPanelDoNotUseOrYouWillBeFired } = message; 6 | 7 | const Demo = () => ( 8 | <_InternalPanelDoNotUseOrYouWillBeFired type={'info'} content={'Info'} /> 9 | ); 10 | 11 | const componentDemo: ComponentDemo = { 12 | demo: , 13 | tokens: ['colorInfo'], 14 | key: 'info', 15 | }; 16 | 17 | export default componentDemo; 18 | -------------------------------------------------------------------------------- /src/previews/components/message/message.tsx: -------------------------------------------------------------------------------- 1 | import { message } from 'antd'; 2 | import React from 'react'; 3 | 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const { _InternalPanelDoNotUseOrYouWillBeFired } = message; 7 | 8 | const Demo = () => ( 9 | <_InternalPanelDoNotUseOrYouWillBeFired 10 | type={'info'} 11 | content={`Hello, Ant Design!`} 12 | /> 13 | ); 14 | 15 | const componentDemo: ComponentDemo = { 16 | demo: , 17 | tokens: ['colorText', 'colorBgElevated'], 18 | key: 'message', 19 | }; 20 | 21 | export default componentDemo; 22 | -------------------------------------------------------------------------------- /src/previews/components/message/success.tsx: -------------------------------------------------------------------------------- 1 | import { message } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { _InternalPanelDoNotUseOrYouWillBeFired } = message; 6 | 7 | const Demo = () => ( 8 | <_InternalPanelDoNotUseOrYouWillBeFired 9 | type={'success'} 10 | content={'这是一条成功消息,会主动消失'} 11 | /> 12 | ); 13 | 14 | const componentDemo: ComponentDemo = { 15 | demo: , 16 | tokens: ['colorSuccess'], 17 | key: 'success', 18 | }; 19 | 20 | export default componentDemo; 21 | -------------------------------------------------------------------------------- /src/previews/components/message/warning.tsx: -------------------------------------------------------------------------------- 1 | import { message } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { _InternalPanelDoNotUseOrYouWillBeFired } = message; 6 | 7 | const Demo = () => ( 8 | <_InternalPanelDoNotUseOrYouWillBeFired 9 | type={'warning'} 10 | content={'这是一条警告消息,会主动消失'} 11 | /> 12 | ); 13 | 14 | const componentDemo: ComponentDemo = { 15 | demo: , 16 | tokens: ['colorWarning'], 17 | key: 'warning', 18 | }; 19 | 20 | export default componentDemo; 21 | -------------------------------------------------------------------------------- /src/previews/components/modal/index.ts: -------------------------------------------------------------------------------- 1 | import info from './info'; 2 | import Default from './modal'; 3 | import withButton from './modalWithButton'; 4 | import success from './success'; 5 | import warning from './warning'; 6 | 7 | import type { ComponentDemo } from '../../../interface'; 8 | 9 | const previewerDemo: ComponentDemo[] = [ 10 | Default, 11 | info, 12 | withButton, 13 | warning, 14 | success, 15 | ]; 16 | 17 | export default previewerDemo; 18 | -------------------------------------------------------------------------------- /src/previews/components/modal/info.tsx: -------------------------------------------------------------------------------- 1 | import { Modal } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { _InternalPanelDoNotUseOrYouWillBeFired } = Modal; 6 | const Demo = () => { 7 | return ( 8 | <> 9 | <_InternalPanelDoNotUseOrYouWillBeFired title="Basic Modal"> 10 |

Some contents...

Some contents...

Some contents...

11 | 12 | 13 | ); 14 | }; 15 | 16 | const componentDemo: ComponentDemo = { 17 | demo: , 18 | tokens: ['colorInfo'], 19 | key: 'info', 20 | }; 21 | export default componentDemo; 22 | -------------------------------------------------------------------------------- /src/previews/components/modal/modal.tsx: -------------------------------------------------------------------------------- 1 | import { Modal } from 'antd'; 2 | import React from 'react'; 3 | 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const Demo = () => { 7 | return ( 8 | 9 |

Some contents...

Some contents...

Some contents...

10 |
11 | ); 12 | }; 13 | 14 | const componentDemo: ComponentDemo = { 15 | demo: , 16 | tokens: ['colorBgElevated'], 17 | key: 'default', 18 | }; 19 | export default componentDemo; 20 | -------------------------------------------------------------------------------- /src/previews/components/modal/modalWithButton.tsx: -------------------------------------------------------------------------------- 1 | import { Button, Modal } from 'antd'; 2 | import React, { useState } from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => { 6 | const [isModalVisible, setIsModalVisible] = useState(false); 7 | const showModal = () => { 8 | setIsModalVisible(true); 9 | }; 10 | const handleOk = () => { 11 | setIsModalVisible(false); 12 | }; 13 | const handleCancel = () => { 14 | setIsModalVisible(false); 15 | }; 16 | return ( 17 | <> 18 | 21 | 27 |

Some contents...

Some contents...

Some contents...

28 |
29 | 30 | ); 31 | }; 32 | 33 | const componentDemo: ComponentDemo = { 34 | demo: , 35 | tokens: ['colorBgMask'], 36 | key: 'modalWithButton', 37 | }; 38 | export default componentDemo; 39 | -------------------------------------------------------------------------------- /src/previews/components/modal/success.tsx: -------------------------------------------------------------------------------- 1 | import { Modal } from 'antd'; 2 | import React from 'react'; 3 | 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const Demo = () => { 7 | return ( 8 | 9 | A good news! 10 | 11 | ); 12 | }; 13 | 14 | const componentDemo: ComponentDemo = { 15 | demo: , 16 | tokens: ['colorSuccess'], 17 | key: 'success', 18 | }; 19 | export default componentDemo; 20 | -------------------------------------------------------------------------------- /src/previews/components/modal/warning.tsx: -------------------------------------------------------------------------------- 1 | import { Modal } from 'antd'; 2 | import React from 'react'; 3 | 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const Demo = () => { 7 | return ( 8 | 14 | Some descriptions. 15 | 16 | ); 17 | }; 18 | 19 | const componentDemo: ComponentDemo = { 20 | demo: , 21 | tokens: ['colorWarning'], 22 | key: 'warning', 23 | }; 24 | export default componentDemo; 25 | -------------------------------------------------------------------------------- /src/previews/components/notification/error.tsx: -------------------------------------------------------------------------------- 1 | import { notification } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { _InternalPanelDoNotUseOrYouWillBeFired } = notification; 6 | 7 | const Demo = () => ( 8 | <_InternalPanelDoNotUseOrYouWillBeFired 9 | message={'Notification Title'} 10 | type={'error'} 11 | description={ 12 | 'This is the content of the notification. This is the content of the notification. This is the content of the notification.' 13 | } 14 | /> 15 | ); 16 | 17 | const componentDemo: ComponentDemo = { 18 | demo: , 19 | tokens: ['colorError'], 20 | key: 'error', 21 | }; 22 | 23 | export default componentDemo; 24 | -------------------------------------------------------------------------------- /src/previews/components/notification/index.ts: -------------------------------------------------------------------------------- 1 | import error from './error'; 2 | import info from './info'; 3 | import Demo from './notification'; 4 | import success from './success'; 5 | import warning from './warning'; 6 | 7 | import type { ComponentDemo } from '../../../interface'; 8 | 9 | const previewerDemo: ComponentDemo[] = [Demo, info, error, success, warning]; 10 | 11 | export default previewerDemo; 12 | -------------------------------------------------------------------------------- /src/previews/components/notification/info.tsx: -------------------------------------------------------------------------------- 1 | import { notification } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { _InternalPanelDoNotUseOrYouWillBeFired } = notification; 6 | 7 | const Demo = () => ( 8 | <_InternalPanelDoNotUseOrYouWillBeFired 9 | message={'Notification Title'} 10 | type={'info'} 11 | description={ 12 | 'This is the content of the notification. This is the content of the notification. This is the content of the notification.' 13 | } 14 | /> 15 | ); 16 | 17 | const componentDemo: ComponentDemo = { 18 | demo: , 19 | tokens: ['colorInfo'], 20 | key: 'info', 21 | }; 22 | 23 | export default componentDemo; 24 | -------------------------------------------------------------------------------- /src/previews/components/notification/notification.tsx: -------------------------------------------------------------------------------- 1 | import { notification } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { _InternalPanelDoNotUseOrYouWillBeFired } = notification; 6 | 7 | const Demo = () => ( 8 | <_InternalPanelDoNotUseOrYouWillBeFired 9 | message={'Notification Title'} 10 | description={ 11 | 'This is the content of the notification. This is the content of the notification. This is the content of the notification.' 12 | } 13 | /> 14 | ); 15 | 16 | const componentDemo: ComponentDemo = { 17 | demo: , 18 | tokens: ['colorIcon', 'colorIconHover', 'colorBgElevated'], 19 | key: 'default', 20 | }; 21 | 22 | export default componentDemo; 23 | -------------------------------------------------------------------------------- /src/previews/components/notification/success.tsx: -------------------------------------------------------------------------------- 1 | import { notification } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { _InternalPanelDoNotUseOrYouWillBeFired } = notification; 6 | 7 | const Demo = () => ( 8 | <_InternalPanelDoNotUseOrYouWillBeFired 9 | message={'Notification Title'} 10 | type={'success'} 11 | description={ 12 | 'This is the content of the notification. This is the content of the notification. This is the content of the notification.' 13 | } 14 | /> 15 | ); 16 | 17 | const componentDemo: ComponentDemo = { 18 | demo: , 19 | tokens: ['colorSuccess'], 20 | key: 'success', 21 | }; 22 | 23 | export default componentDemo; 24 | -------------------------------------------------------------------------------- /src/previews/components/notification/warning.tsx: -------------------------------------------------------------------------------- 1 | import { notification } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { _InternalPanelDoNotUseOrYouWillBeFired } = notification; 6 | 7 | const Demo = () => ( 8 | <_InternalPanelDoNotUseOrYouWillBeFired 9 | message={'Notification Title'} 10 | type={'warning'} 11 | description={ 12 | 'This is the content of the notification. This is the content of the notification. This is the content of the notification.' 13 | } 14 | /> 15 | ); 16 | 17 | const componentDemo: ComponentDemo = { 18 | demo: , 19 | tokens: ['colorWarning'], 20 | key: 'warning', 21 | }; 22 | 23 | export default componentDemo; 24 | -------------------------------------------------------------------------------- /src/previews/components/pagination/disabled.tsx: -------------------------------------------------------------------------------- 1 | import { Pagination } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo: React.FC = () => ( 6 | 7 | ); 8 | 9 | const componentDemo: ComponentDemo = { 10 | demo: , 11 | tokens: [ 12 | 'controlItemBgActiveDisabled', 13 | 'colorBgContainerDisabled', 14 | 'colorFillAlter', 15 | ], 16 | key: 'disabled', 17 | }; 18 | 19 | export default componentDemo; 20 | -------------------------------------------------------------------------------- /src/previews/components/pagination/index.tsx: -------------------------------------------------------------------------------- 1 | import disabled from './disabled'; 2 | import outline from './outline'; 3 | import Demo from './pagination'; 4 | 5 | import type { ComponentDemo } from '../../../interface'; 6 | 7 | const previewerDemo: ComponentDemo[] = [Demo, disabled, outline]; 8 | 9 | export default previewerDemo; 10 | -------------------------------------------------------------------------------- /src/previews/components/pagination/outline.tsx: -------------------------------------------------------------------------------- 1 | import { Pagination, Space } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo: React.FC = () => ( 6 | 7 | 8 | 9 | ); 10 | 11 | const componentDemo: ComponentDemo = { 12 | demo: , 13 | tokens: [ 14 | 'colorPrimary', 15 | 'controlOutline', 16 | 'colorPrimaryHover', 17 | 'colorBgContainer', 18 | ], 19 | key: 'outline', 20 | }; 21 | 22 | export default componentDemo; 23 | -------------------------------------------------------------------------------- /src/previews/components/pagination/pagination.tsx: -------------------------------------------------------------------------------- 1 | import { Pagination, Space } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo: React.FC = () => ( 6 | 7 | 8 | 9 | 10 | 11 | ); 12 | 13 | const componentDemo: ComponentDemo = { 14 | demo: , 15 | tokens: ['colorPrimary', 'colorPrimaryHover', 'colorBgContainer'], 16 | key: 'default', 17 | }; 18 | 19 | export default componentDemo; 20 | -------------------------------------------------------------------------------- /src/previews/components/popconfirm/index.ts: -------------------------------------------------------------------------------- 1 | import Demo from './popconfirm'; 2 | 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const previewerDemo: ComponentDemo[] = [Demo]; 6 | 7 | export default previewerDemo; 8 | -------------------------------------------------------------------------------- /src/previews/components/popconfirm/popconfirm.tsx: -------------------------------------------------------------------------------- 1 | import { message, Popconfirm } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | function confirm() { 6 | message.success('Click on Yes'); 7 | } 8 | function cancel() { 9 | message.error('Click on No'); 10 | } 11 | const Demo = () => ( 12 |
13 | 21 |
22 | ); 23 | 24 | const componentDemo: ComponentDemo = { 25 | demo: , 26 | tokens: ['colorBgElevated', 'colorWarning'], 27 | key: 'default', 28 | }; 29 | 30 | export default componentDemo; 31 | -------------------------------------------------------------------------------- /src/previews/components/popover/index.ts: -------------------------------------------------------------------------------- 1 | import Demo from './popover'; 2 | 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const previewerDemo: ComponentDemo[] = [Demo]; 6 | 7 | export default previewerDemo; 8 | -------------------------------------------------------------------------------- /src/previews/components/popover/popover.tsx: -------------------------------------------------------------------------------- 1 | import { Button, Popover } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const content = ( 6 |
7 |

Content

Content

8 |
9 | ); 10 | const Demo = () => ( 11 |
12 | 16 | 17 |
18 | ); 19 | 20 | const componentDemo: ComponentDemo = { 21 | demo: , 22 | tokens: ['colorBgElevated'], 23 | key: 'default', 24 | }; 25 | 26 | export default componentDemo; 27 | -------------------------------------------------------------------------------- /src/previews/components/progress/danger.tsx: -------------------------------------------------------------------------------- 1 | import { Flexbox } from '@arvinxu/layout-kit'; 2 | import { Progress } from 'antd'; 3 | import React from 'react'; 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const Demo: React.FC = () => ( 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | ); 15 | 16 | const componentDemo: ComponentDemo = { 17 | demo: , 18 | tokens: ['colorError'], 19 | key: 'danger', 20 | }; 21 | 22 | export default componentDemo; 23 | -------------------------------------------------------------------------------- /src/previews/components/progress/index.ts: -------------------------------------------------------------------------------- 1 | import danger from './danger'; 2 | import info from './info'; 3 | import Demo from './progress'; 4 | import progressInBg from './progressInBg'; 5 | import success from './success'; 6 | 7 | import type { ComponentDemo } from '../../../interface'; 8 | 9 | const previewerDemo: ComponentDemo[] = [ 10 | Demo, 11 | info, 12 | danger, 13 | success, 14 | progressInBg, 15 | ]; 16 | 17 | export default previewerDemo; 18 | -------------------------------------------------------------------------------- /src/previews/components/progress/info.tsx: -------------------------------------------------------------------------------- 1 | import { Progress } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo: React.FC = () => ( 6 | <> 7 | 8 | 9 | 10 | 11 | 12 | 13 | ); 14 | 15 | const componentDemo: ComponentDemo = { 16 | demo: , 17 | tokens: ['colorInfo'], 18 | key: 'info', 19 | }; 20 | 21 | export default componentDemo; 22 | -------------------------------------------------------------------------------- /src/previews/components/progress/progress.tsx: -------------------------------------------------------------------------------- 1 | import { Progress } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo: React.FC = () => ( 6 | <> 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | ); 15 | 16 | const componentDemo: ComponentDemo = { 17 | demo: , 18 | tokens: ['colorFillSecondary', 'colorText', 'colorBgContainer'], 19 | key: 'default', 20 | }; 21 | 22 | export default componentDemo; 23 | -------------------------------------------------------------------------------- /src/previews/components/progress/progressInBg.tsx: -------------------------------------------------------------------------------- 1 | import { Progress, theme } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo: React.FC = () => { 6 | const { token } = theme.useToken(); 7 | return ( 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | ); 17 | }; 18 | 19 | const componentDemo: ComponentDemo = { 20 | demo: , 21 | tokens: ['colorFillSecondary', 'colorText', 'colorBgContainer'], 22 | key: 'layout', 23 | }; 24 | 25 | export default componentDemo; 26 | -------------------------------------------------------------------------------- /src/previews/components/progress/success.tsx: -------------------------------------------------------------------------------- 1 | import { Flexbox } from '@arvinxu/layout-kit'; 2 | import { Progress } from 'antd'; 3 | import React from 'react'; 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const Demo: React.FC = () => ( 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | ); 15 | 16 | const componentDemo: ComponentDemo = { 17 | demo: , 18 | tokens: ['colorSuccess'], 19 | key: 'success', 20 | }; 21 | 22 | export default componentDemo; 23 | -------------------------------------------------------------------------------- /src/previews/components/radio/button.tsx: -------------------------------------------------------------------------------- 1 | import { Radio, Space } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 | 7 | 8 | 9 | Hangzhou 10 | 11 | Shanghai 12 | 13 | 14 |
15 | Apple 16 | Orange 17 |
18 |
19 | ); 20 | 21 | const componentDemo: ComponentDemo = { 22 | demo: , 23 | tokens: ['colorPrimaryActive', 'colorPrimaryHover'], 24 | key: 'button', 25 | }; 26 | 27 | export default componentDemo; 28 | -------------------------------------------------------------------------------- /src/previews/components/radio/disabled.tsx: -------------------------------------------------------------------------------- 1 | import { Radio } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => Radio; 6 | 7 | const componentDemo: ComponentDemo = { 8 | demo: , 9 | tokens: ['colorBgContainerDisabled'], 10 | key: 'disabled', 11 | }; 12 | 13 | export default componentDemo; 14 | -------------------------------------------------------------------------------- /src/previews/components/radio/index.ts: -------------------------------------------------------------------------------- 1 | import Button from './button'; 2 | import disabled from './disabled'; 3 | import Default from './radio'; 4 | 5 | import type { ComponentDemo } from '../../../interface'; 6 | 7 | const previewerDemo: ComponentDemo[] = [Default, Button, disabled]; 8 | 9 | export default previewerDemo; 10 | -------------------------------------------------------------------------------- /src/previews/components/radio/radio.tsx: -------------------------------------------------------------------------------- 1 | import { Radio } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => Radio; 6 | 7 | const componentDemo: ComponentDemo = { 8 | demo: , 9 | tokens: ['colorPrimary', 'controlOutline', 'colorBgContainer'], 10 | key: 'default', 11 | }; 12 | 13 | export default componentDemo; 14 | -------------------------------------------------------------------------------- /src/previews/components/rate/index.ts: -------------------------------------------------------------------------------- 1 | import Demo from './rate'; 2 | 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const previewerDemo: ComponentDemo[] = [Demo]; 6 | 7 | export default previewerDemo; 8 | -------------------------------------------------------------------------------- /src/previews/components/rate/rate.tsx: -------------------------------------------------------------------------------- 1 | import { Rate } from 'antd'; 2 | import React from 'react'; 3 | 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const Demo = () => ; 7 | 8 | const componentDemo: ComponentDemo = { 9 | demo: , 10 | tokens: ['colorFillContent'], 11 | key: 'default', 12 | }; 13 | 14 | export default componentDemo; 15 | -------------------------------------------------------------------------------- /src/previews/components/result/danger.tsx: -------------------------------------------------------------------------------- 1 | import { Result } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo: React.FC = () => ( 6 | 7 | ); 8 | 9 | const componentDemo: ComponentDemo = { 10 | demo: , 11 | tokens: ['colorError'], 12 | key: 'danger', 13 | }; 14 | 15 | export default componentDemo; 16 | -------------------------------------------------------------------------------- /src/previews/components/result/index.ts: -------------------------------------------------------------------------------- 1 | import danger from './danger'; 2 | import info from './info'; 3 | import Demo from './result'; 4 | import ResultWithDesc from './resultWithDesc'; 5 | import warning from './warning'; 6 | 7 | import type { ComponentDemo } from '../../../interface'; 8 | 9 | const previewerDemo: ComponentDemo[] = [ 10 | Demo, 11 | info, 12 | warning, 13 | danger, 14 | ResultWithDesc, 15 | ]; 16 | 17 | export default previewerDemo; 18 | -------------------------------------------------------------------------------- /src/previews/components/result/info.tsx: -------------------------------------------------------------------------------- 1 | import { Result } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo: React.FC = () => ( 6 | 7 | ); 8 | 9 | const componentDemo: ComponentDemo = { 10 | demo: , 11 | tokens: ['colorInfo'], 12 | key: 'info', 13 | }; 14 | 15 | export default componentDemo; 16 | -------------------------------------------------------------------------------- /src/previews/components/result/result.tsx: -------------------------------------------------------------------------------- 1 | import { Button, Result } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo: React.FC = () => ( 6 | 12 | Go Console 13 | , 14 | , 15 | ]} 16 | /> 17 | ); 18 | 19 | const componentDemo: ComponentDemo = { 20 | demo: , 21 | tokens: ['colorSuccess'], 22 | key: 'result', 23 | }; 24 | 25 | export default componentDemo; 26 | -------------------------------------------------------------------------------- /src/previews/components/result/resultWithDesc.tsx: -------------------------------------------------------------------------------- 1 | import { Result } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo: React.FC = () => ( 6 | 7 | Order number: 2017182818828182881 Cloud server configuration takes 1-5 8 | minutes, please wait. 9 | 10 | ); 11 | const componentDemo: ComponentDemo = { 12 | demo: , 13 | tokens: ['colorFillAlter'], 14 | key: 'resultWithDesc', 15 | }; 16 | 17 | export default componentDemo; 18 | -------------------------------------------------------------------------------- /src/previews/components/result/success.tsx: -------------------------------------------------------------------------------- 1 | import { Result } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo: React.FC = () => ( 6 | 12 | ); 13 | 14 | const componentDemo: ComponentDemo = { 15 | demo: , 16 | tokens: ['colorSuccess'], 17 | key: 'result', 18 | }; 19 | 20 | export default componentDemo; 21 | -------------------------------------------------------------------------------- /src/previews/components/result/warning.tsx: -------------------------------------------------------------------------------- 1 | import { Result } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo: React.FC = () => ( 6 | 7 | ); 8 | 9 | const componentDemo: ComponentDemo = { 10 | demo: , 11 | tokens: ['colorWarning'], 12 | key: 'warning', 13 | }; 14 | 15 | export default componentDemo; 16 | -------------------------------------------------------------------------------- /src/previews/components/segmented/index.ts: -------------------------------------------------------------------------------- 1 | import Demo from './segmented'; 2 | 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const previewerDemo: ComponentDemo[] = [Demo]; 6 | 7 | export default previewerDemo; 8 | -------------------------------------------------------------------------------- /src/previews/components/segmented/segmented.tsx: -------------------------------------------------------------------------------- 1 | import { Segmented } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 | 7 | ); 8 | 9 | const componentDemo: ComponentDemo = { 10 | demo: , 11 | key: 'default', 12 | tokens: [], 13 | }; 14 | 15 | export default componentDemo; 16 | -------------------------------------------------------------------------------- /src/previews/components/select/_internal.ts: -------------------------------------------------------------------------------- 1 | import { Select } from 'antd'; 2 | 3 | export default Select._InternalPanelDoNotUseOrYouWillBeFired; 4 | -------------------------------------------------------------------------------- /src/previews/components/select/danger.tsx: -------------------------------------------------------------------------------- 1 | import Select from './_internal'; 2 | 3 | import React from 'react'; 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | import options from './data'; 7 | 8 | const handleChange = (value: any) => { 9 | console.log(`selected ${value}`); 10 | }; 11 | 12 | const Demo = () => ( 13 | 20 | ); 21 | 22 | const componentDemo: ComponentDemo = { 23 | demo: , 24 | tokens: ['colorBgContainerDisabled', 'colorTextDisabled'], 25 | key: 'disabled', 26 | }; 27 | 28 | export default componentDemo; 29 | -------------------------------------------------------------------------------- /src/previews/components/select/icon.tsx: -------------------------------------------------------------------------------- 1 | import Select from './_internal'; 2 | 3 | import React from 'react'; 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | import options from './data'; 7 | 8 | const handleChange = (value: any) => { 9 | console.log(`selected ${value}`); 10 | }; 11 | 12 | const Demo = () => ( 13 | 11 | 12 | 15 | 16 | 17 | 20 | 23 | 26 | 27 | ); 28 | 29 | const componentDemo: ComponentDemo = { 30 | demo: , 31 | tokens: [ 32 | 'controlOutline', 33 | 'colorPrimary', 34 | 'colorPrimaryHover', 35 | 'colorText', 36 | 'colorBgElevated', 37 | 'colorBgContainer', 38 | ], 39 | key: 'select', 40 | }; 41 | 42 | export default componentDemo; 43 | -------------------------------------------------------------------------------- /src/previews/components/select/selectTag.tsx: -------------------------------------------------------------------------------- 1 | import Select from './_internal'; 2 | 3 | import React from 'react'; 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | import options from './data'; 7 | 8 | const handleChange = (value: any) => { 9 | console.log(`selected ${value}`); 10 | }; 11 | 12 | const Demo = () => ( 13 | 25 | ); 26 | 27 | const componentDemo: ComponentDemo = { 28 | demo: , 29 | tokens: ['colorWarningHover', 'colorWarningOutline'], 30 | key: 'warning', 31 | }; 32 | 33 | export default componentDemo; 34 | -------------------------------------------------------------------------------- /src/previews/components/skeleton/index.ts: -------------------------------------------------------------------------------- 1 | import Demo from './skeleton'; 2 | 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const previewerDemo: ComponentDemo[] = [Demo]; 6 | 7 | export default previewerDemo; 8 | -------------------------------------------------------------------------------- /src/previews/components/skeleton/skeleton.tsx: -------------------------------------------------------------------------------- 1 | import { Skeleton } from 'antd'; 2 | import React from 'react'; 3 | 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const Demo = () => ; 7 | 8 | const componentDemo: ComponentDemo = { 9 | demo: , 10 | tokens: ['colorFillContent', 'colorTextPlaceholder'], 11 | key: 'default', 12 | }; 13 | 14 | export default componentDemo; 15 | -------------------------------------------------------------------------------- /src/previews/components/slider/index.ts: -------------------------------------------------------------------------------- 1 | import Demo from './slider'; 2 | import SliderInBg from './sliderInBg'; 3 | 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const previewerDemo: ComponentDemo[] = [Demo, SliderInBg]; 7 | 8 | export default previewerDemo; 9 | -------------------------------------------------------------------------------- /src/previews/components/slider/slider.tsx: -------------------------------------------------------------------------------- 1 | import { Slider } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 | <> 7 | 8 | 9 | 10 | ); 11 | 12 | const componentDemo: ComponentDemo = { 13 | demo: , 14 | tokens: [ 15 | 'colorFillSecondary', 16 | 'colorFillContentHover', 17 | 'colorBgContainer', 18 | 'colorPrimary', 19 | 'colorPrimaryHover', 20 | 'colorPrimaryBorderHover', 21 | 'colorPrimaryBorder', 22 | ], 23 | key: 'default', 24 | }; 25 | 26 | export default componentDemo; 27 | -------------------------------------------------------------------------------- /src/previews/components/slider/sliderInBg.tsx: -------------------------------------------------------------------------------- 1 | import { Slider, theme } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => { 6 | const { token } = theme.useToken(); 7 | return ( 8 |
9 | 10 | 11 |
12 | ); 13 | }; 14 | 15 | const componentDemo: ComponentDemo = { 16 | demo: , 17 | tokens: [ 18 | 'colorFillSecondary', 19 | 'colorFillContentHover', 20 | 'colorBgContainer', 21 | 'colorPrimary', 22 | 'colorPrimaryHover', 23 | 'colorPrimaryBorderHover', 24 | 'colorPrimaryBorder', 25 | ], 26 | key: 'sliderInBg', 27 | }; 28 | 29 | export default componentDemo; 30 | -------------------------------------------------------------------------------- /src/previews/components/space/index.ts: -------------------------------------------------------------------------------- 1 | import Demo from './space'; 2 | 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const previewerDemo: ComponentDemo[] = [Demo]; 6 | 7 | export default previewerDemo; 8 | -------------------------------------------------------------------------------- /src/previews/components/space/space.tsx: -------------------------------------------------------------------------------- 1 | import { UploadOutlined } from '@ant-design/icons'; 2 | import { Button, Popconfirm, Space, Upload } from 'antd'; 3 | import React from 'react'; 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const Demo: React.FC = () => ( 7 | 8 | Space 9 | 10 | 11 | 14 | 15 | 20 | 21 | 22 | 23 | ); 24 | 25 | const componentDemo: ComponentDemo = { 26 | demo: , 27 | key: 'default', 28 | }; 29 | 30 | export default componentDemo; 31 | -------------------------------------------------------------------------------- /src/previews/components/spin/index.ts: -------------------------------------------------------------------------------- 1 | import Default from './spin'; 2 | 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const previewerDemo: ComponentDemo[] = [Default]; 6 | 7 | export default previewerDemo; 8 | -------------------------------------------------------------------------------- /src/previews/components/spin/spin.tsx: -------------------------------------------------------------------------------- 1 | import { Spin } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ; 6 | 7 | const componentDemo: ComponentDemo = { 8 | demo: , 9 | tokens: ['colorPrimary', 'colorBgContainer'], 10 | key: 'default', 11 | }; 12 | 13 | export default componentDemo; 14 | -------------------------------------------------------------------------------- /src/previews/components/statistic/index.ts: -------------------------------------------------------------------------------- 1 | import Demo from './statistic'; 2 | 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const previewerDemo: ComponentDemo[] = [Demo]; 6 | 7 | export default previewerDemo; 8 | -------------------------------------------------------------------------------- /src/previews/components/statistic/statistic.tsx: -------------------------------------------------------------------------------- 1 | import { Button, Col, Row, Statistic } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 | 7 | 8 | 9 | 10 | 11 | 12 | 15 | 16 | 17 | 18 | 19 | 20 | ); 21 | 22 | const componentDemo: ComponentDemo = { 23 | demo: , 24 | tokens: ['colorPrimary'], 25 | key: 'default', 26 | }; 27 | 28 | export default componentDemo; 29 | -------------------------------------------------------------------------------- /src/previews/components/steps/danger.tsx: -------------------------------------------------------------------------------- 1 | import { Steps } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { Step } = Steps; 6 | 7 | const Demo: React.FC = () => ( 8 | 9 | 10 | 16 | 17 | ); 18 | 19 | const componentDemo: ComponentDemo = { 20 | demo: , 21 | tokens: ['colorError'], 22 | key: 'danger', 23 | }; 24 | 25 | export default componentDemo; 26 | -------------------------------------------------------------------------------- /src/previews/components/steps/index.ts: -------------------------------------------------------------------------------- 1 | import danger from './danger'; 2 | import Demo from './steps'; 3 | 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const previewerDemo: ComponentDemo[] = [Demo, danger]; 7 | 8 | export default previewerDemo; 9 | -------------------------------------------------------------------------------- /src/previews/components/steps/steps.tsx: -------------------------------------------------------------------------------- 1 | import { Steps } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { Step } = Steps; 6 | 7 | const Demo: React.FC = () => ( 8 | 9 | 10 | 15 | 16 | 17 | ); 18 | 19 | const componentDemo: ComponentDemo = { 20 | demo: , 21 | tokens: ['colorPrimary', 'colorBgContainer'], 22 | key: 'default', 23 | }; 24 | 25 | export default componentDemo; 26 | -------------------------------------------------------------------------------- /src/previews/components/switch/index.ts: -------------------------------------------------------------------------------- 1 | import Demo from './switch'; 2 | 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const previewerDemo: ComponentDemo[] = [Demo]; 6 | 7 | export default previewerDemo; 8 | -------------------------------------------------------------------------------- /src/previews/components/switch/switch.tsx: -------------------------------------------------------------------------------- 1 | import { Switch } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | function onChange() {} 6 | const Demo = () => ; 7 | 8 | const componentDemo: ComponentDemo = { 9 | demo: , 10 | tokens: ['colorPrimary', 'controlOutline', 'colorBgContainer'], 11 | key: 'default', 12 | }; 13 | 14 | export default componentDemo; 15 | -------------------------------------------------------------------------------- /src/previews/components/table/index.ts: -------------------------------------------------------------------------------- 1 | import Filter from './filterTable'; 2 | import Default from './table'; 3 | 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const previewerDemo: ComponentDemo[] = [Default, Filter]; 7 | 8 | export default previewerDemo; 9 | -------------------------------------------------------------------------------- /src/previews/components/table/table.tsx: -------------------------------------------------------------------------------- 1 | import { Space, Table, Tag } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const columns = [ 6 | { 7 | title: 'Name', 8 | dataIndex: 'name', 9 | key: 'name', 10 | render: (text: string) => {text}, 11 | }, 12 | { title: 'Age', dataIndex: 'age', key: 'age' }, 13 | { title: 'Address', dataIndex: 'address', key: 'address' }, 14 | { 15 | title: 'Tags', 16 | key: 'tags', 17 | dataIndex: 'tags', 18 | render: (tags: string[]) => ( 19 | <> 20 | {tags.map((tag: string) => { 21 | let color = tag.length > 5 ? 'geekblue' : 'green'; 22 | if (tag === 'loser') { 23 | color = 'volcano'; 24 | } 25 | return ( 26 | 27 | {tag.toUpperCase()} 28 | 29 | ); 30 | })} 31 | 32 | ), 33 | }, 34 | { 35 | title: 'Action', 36 | key: 'action', 37 | render: (_: string, record: any) => ( 38 | 39 | Invite {record.name} Delete 40 | 41 | ), 42 | }, 43 | ]; 44 | const data = [ 45 | { 46 | key: '1', 47 | name: 'John Brown', 48 | age: 32, 49 | address: 'New York No. 1 Lake Park', 50 | tags: ['nice', 'developer'], 51 | }, 52 | { 53 | key: '2', 54 | name: 'Jim Green', 55 | age: 42, 56 | address: 'London No. 1 Lake Park', 57 | tags: ['loser'], 58 | }, 59 | { 60 | key: '3', 61 | name: 'Joe Black', 62 | age: 32, 63 | address: 'Sidney No. 1 Lake Park', 64 | tags: ['cool', 'teacher'], 65 | }, 66 | ]; 67 | const Demo = () => ( 68 | 69 | ); 70 | 71 | const componentDemo: ComponentDemo = { 72 | demo: , 73 | tokens: ['colorPrimaryActive', 'colorBgContainer'], 74 | key: 'table', 75 | }; 76 | 77 | export default componentDemo; 78 | -------------------------------------------------------------------------------- /src/previews/components/tabs/cardTabs.tsx: -------------------------------------------------------------------------------- 1 | import { Tabs } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { TabPane } = Tabs; 6 | 7 | const Demo = () => ( 8 | 9 | 10 | Content of Tab Pane 1 11 | 12 | 13 | Content of Tab Pane 2 14 | 15 | 16 | Content of Tab Pane 3 17 | 18 | 19 | ); 20 | 21 | const componentDemo: ComponentDemo = { 22 | demo: , 23 | tokens: ['colorFillAlter'], 24 | key: 'cardTabs', 25 | }; 26 | 27 | export default componentDemo; 28 | -------------------------------------------------------------------------------- /src/previews/components/tabs/index.ts: -------------------------------------------------------------------------------- 1 | import card from './cardTabs'; 2 | import Default from './tabs'; 3 | 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const previewerDemo: ComponentDemo[] = [Default, card]; 7 | 8 | export default previewerDemo; 9 | -------------------------------------------------------------------------------- /src/previews/components/tabs/tabs.tsx: -------------------------------------------------------------------------------- 1 | import { Tabs } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { TabPane } = Tabs; 6 | function callback() {} 7 | const Demo = () => ( 8 | 9 | 10 | Content of Tab Pane 1 11 | 12 | 13 | Content of Tab Pane 2 14 | 15 | 16 | Content of Tab Pane 3 17 | 18 | 19 | ); 20 | 21 | const componentDemo: ComponentDemo = { 22 | demo: , 23 | tokens: [ 24 | 'colorPrimary', 25 | 'colorPrimaryHover', 26 | 'colorPrimaryActive', 27 | 'colorBgContainer', 28 | ], 29 | key: 'default', 30 | }; 31 | 32 | export default componentDemo; 33 | -------------------------------------------------------------------------------- /src/previews/components/tag/closable.tsx: -------------------------------------------------------------------------------- 1 | import { Tag } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => Error; 6 | 7 | const componentDemo: ComponentDemo = { 8 | demo: , 9 | tokens: ['colorFillAlter', 'colorIcon', 'colorIconHover'], 10 | key: 'closable', 11 | }; 12 | 13 | export default componentDemo; 14 | -------------------------------------------------------------------------------- /src/previews/components/tag/error.tsx: -------------------------------------------------------------------------------- 1 | import { Tag } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => Error; 6 | 7 | const componentDemo: ComponentDemo = { 8 | demo: , 9 | tokens: ['colorError', 'colorErrorBg', 'colorErrorBorder'], 10 | key: 'error', 11 | }; 12 | 13 | export default componentDemo; 14 | -------------------------------------------------------------------------------- /src/previews/components/tag/index.ts: -------------------------------------------------------------------------------- 1 | import closable from './closable'; 2 | import error from './error'; 3 | import info from './info'; 4 | import multiTags from './multiTags'; 5 | import success from './success'; 6 | import Default from './tag'; 7 | import warning from './warning'; 8 | 9 | import type { ComponentDemo } from '../../../interface'; 10 | 11 | const previewerDemo: ComponentDemo[] = [ 12 | Default, 13 | error, 14 | info, 15 | success, 16 | warning, 17 | multiTags, 18 | closable, 19 | ]; 20 | 21 | export default previewerDemo; 22 | -------------------------------------------------------------------------------- /src/previews/components/tag/info.tsx: -------------------------------------------------------------------------------- 1 | import { Tag } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => Info; 6 | 7 | const componentDemo: ComponentDemo = { 8 | demo: , 9 | tokens: ['colorInfo', 'colorInfoBg', 'colorInfoBorder'], 10 | key: 'info', 11 | }; 12 | 13 | export default componentDemo; 14 | -------------------------------------------------------------------------------- /src/previews/components/tag/multiTags.tsx: -------------------------------------------------------------------------------- 1 | import { Tag } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { CheckableTag } = Tag; 6 | 7 | const Checkable = () => ( 8 |
9 | Error 10 | Error 11 |
12 | ); 13 | 14 | const componentDemo: ComponentDemo = { 15 | demo: , 16 | tokens: ['colorPrimary', 'colorPrimaryHover', 'colorPrimaryActive'], 17 | key: 'multiTags', 18 | }; 19 | 20 | export default componentDemo; 21 | -------------------------------------------------------------------------------- /src/previews/components/tag/success.tsx: -------------------------------------------------------------------------------- 1 | import { Tag } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => Success; 6 | 7 | const componentDemo: ComponentDemo = { 8 | demo: , 9 | tokens: ['colorSuccess', 'colorSuccessBg', 'colorSuccessBorder'], 10 | key: 'success', 11 | }; 12 | 13 | export default componentDemo; 14 | -------------------------------------------------------------------------------- /src/previews/components/tag/warning.tsx: -------------------------------------------------------------------------------- 1 | import { Tag } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => Warning; 6 | 7 | const componentDemo: ComponentDemo = { 8 | demo: , 9 | tokens: ['colorWarning', 'colorWarningBg', 'colorWarningBorder'], 10 | key: 'warning', 11 | }; 12 | 13 | export default componentDemo; 14 | -------------------------------------------------------------------------------- /src/previews/components/timePicker/index.ts: -------------------------------------------------------------------------------- 1 | import Demo from './time-picker'; 2 | 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const previewerDemo: ComponentDemo[] = [Demo]; 6 | 7 | export default previewerDemo; 8 | -------------------------------------------------------------------------------- /src/previews/components/timePicker/time-picker.tsx: -------------------------------------------------------------------------------- 1 | import { TimePicker } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ; 6 | 7 | const componentDemo: ComponentDemo = { 8 | demo: , 9 | tokens: ['colorPrimary'], 10 | key: 'default', 11 | }; 12 | 13 | export default componentDemo; 14 | -------------------------------------------------------------------------------- /src/previews/components/timeline/danger.tsx: -------------------------------------------------------------------------------- 1 | import { Timeline } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 | 7 | 8 | Create a services site 2015-09-01 9 | 10 | 11 | Solve initial network problems 2015-09-01 12 | 13 | Technical testing 2015-09-01 14 | 15 | Network problems being solved 2015-09-01 16 | 17 | 18 | ); 19 | 20 | const componentDemo: ComponentDemo = { 21 | demo: , 22 | tokens: ['colorError'], 23 | key: 'danger', 24 | }; 25 | 26 | export default componentDemo; 27 | -------------------------------------------------------------------------------- /src/previews/components/timeline/index.ts: -------------------------------------------------------------------------------- 1 | import danger from './danger'; 2 | import success from './success'; 3 | import Default from './timeline'; 4 | 5 | import type { ComponentDemo } from '../../../interface'; 6 | 7 | const previewerDemo: ComponentDemo[] = [Default, danger, success]; 8 | 9 | export default previewerDemo; 10 | -------------------------------------------------------------------------------- /src/previews/components/timeline/success.tsx: -------------------------------------------------------------------------------- 1 | import { Timeline } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 | 7 | 8 | Create a services site 2015-09-01 9 | 10 | 11 | Solve initial network problems 2015-09-01 12 | 13 | Technical testing 2015-09-01 14 | 15 | Network problems being solved 2015-09-01 16 | 17 | 18 | ); 19 | 20 | const componentDemo: ComponentDemo = { 21 | demo: , 22 | tokens: ['colorSuccess'], 23 | key: 'success', 24 | }; 25 | 26 | export default componentDemo; 27 | -------------------------------------------------------------------------------- /src/previews/components/timeline/timeline.tsx: -------------------------------------------------------------------------------- 1 | import { Timeline } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 | 7 | Create a services site 2015-09-01 8 | Solve initial network problems 2015-09-01 9 | Technical testing 2015-09-01 10 | {/*Network problems being solved 2015-09-01*/} 11 | 12 | ); 13 | 14 | const componentDemo: ComponentDemo = { 15 | demo: , 16 | tokens: ['colorPrimary', 'colorText', 'colorSplit', 'colorBgContainer'], 17 | key: 'default', 18 | }; 19 | 20 | export default componentDemo; 21 | -------------------------------------------------------------------------------- /src/previews/components/tooltip/index.ts: -------------------------------------------------------------------------------- 1 | import Demo from './tooltip'; 2 | 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const previewerDemo: ComponentDemo[] = [Demo]; 6 | 7 | export default previewerDemo; 8 | -------------------------------------------------------------------------------- /src/previews/components/tooltip/tooltip.tsx: -------------------------------------------------------------------------------- 1 | import { Tooltip } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const Demo = () => ( 6 |
7 | 8 | Tooltip will show on mouse enter. 9 |
10 | ); 11 | const componentDemo: ComponentDemo = { 12 | demo: , 13 | tokens: ['colorBgSpotlight', 'colorTextLightSolid'], 14 | key: 'default', 15 | }; 16 | 17 | export default componentDemo; 18 | -------------------------------------------------------------------------------- /src/previews/components/transfer/danger.tsx: -------------------------------------------------------------------------------- 1 | import { Transfer } from 'antd'; 2 | import type { Key} from 'react'; 3 | import React, { useState } from 'react'; 4 | 5 | import type { ComponentDemo } from '../../../interface'; 6 | 7 | import mockData from './data'; 8 | 9 | const initialTargetKeys = mockData 10 | .filter((item) => +item.key > 10) 11 | .map((item) => item.key); 12 | 13 | const Demo = () => { 14 | const [targetKeys, setTargetKeys] = useState(initialTargetKeys); 15 | const [selectedKeys, setSelectedKeys] = useState([]); 16 | const onScroll = () => {}; 17 | return ( 18 | { 25 | setTargetKeys(nextTargetKeys); 26 | }} 27 | onSelectChange={(sourceSelectedKeys, targetSelectedKeys) => { 28 | setSelectedKeys([...sourceSelectedKeys, ...targetSelectedKeys]); 29 | }} 30 | onScroll={onScroll} 31 | render={(item) => item.title} 32 | /> 33 | ); 34 | }; 35 | 36 | const componentDemo: ComponentDemo = { 37 | demo: , 38 | tokens: ['colorError'], 39 | key: 'danger', 40 | }; 41 | 42 | export default componentDemo; 43 | -------------------------------------------------------------------------------- /src/previews/components/transfer/data.ts: -------------------------------------------------------------------------------- 1 | const mockData: any[] = []; 2 | for (let i = 0; i < 20; i++) { 3 | mockData.push({ 4 | key: i.toString(), 5 | title: `content${i + 1}`, 6 | description: `description of content${i + 1}`, 7 | }); 8 | } 9 | export default mockData; 10 | -------------------------------------------------------------------------------- /src/previews/components/transfer/disabled.tsx: -------------------------------------------------------------------------------- 1 | import { Transfer } from 'antd'; 2 | import type { Key} from 'react'; 3 | import React, { useState } from 'react'; 4 | 5 | import type { ComponentDemo } from '../../../interface'; 6 | 7 | const mockData: any[] = []; 8 | for (let i = 0; i < 20; i++) { 9 | mockData.push({ 10 | key: i.toString(), 11 | title: `content${i + 1}`, 12 | description: `description of content${i + 1}`, 13 | }); 14 | } 15 | 16 | const initialTargetKeys = mockData 17 | .filter((item) => +item.key > 10) 18 | .map((item) => item.key); 19 | 20 | const Demo = () => { 21 | const [targetKeys, setTargetKeys] = useState(initialTargetKeys); 22 | const [selectedKeys, setSelectedKeys] = useState([]); 23 | const onScroll = () => {}; 24 | return ( 25 | { 32 | setTargetKeys(nextTargetKeys); 33 | }} 34 | onSelectChange={(sourceSelectedKeys, targetSelectedKeys) => { 35 | setSelectedKeys([...sourceSelectedKeys, ...targetSelectedKeys]); 36 | }} 37 | onScroll={onScroll} 38 | render={(item) => item.title} 39 | /> 40 | ); 41 | }; 42 | 43 | const componentDemo: ComponentDemo = { 44 | demo: , 45 | tokens: ['colorBgContainerDisabled'], 46 | key: 'disabled', 47 | }; 48 | 49 | export default componentDemo; 50 | -------------------------------------------------------------------------------- /src/previews/components/transfer/index.ts: -------------------------------------------------------------------------------- 1 | import danger from './danger'; 2 | import disabled from './disabled'; 3 | import Default from './transfer'; 4 | import warning from './warning'; 5 | 6 | import type { ComponentDemo } from '../../../interface'; 7 | 8 | const previewerDemo: ComponentDemo[] = [Default, warning, danger, disabled]; 9 | 10 | export default previewerDemo; 11 | -------------------------------------------------------------------------------- /src/previews/components/transfer/transfer.tsx: -------------------------------------------------------------------------------- 1 | import { Transfer } from 'antd'; 2 | import type { Key} from 'react'; 3 | import React, { useState } from 'react'; 4 | 5 | import type { ComponentDemo } from '../../../interface'; 6 | import mockData from './data'; 7 | 8 | const initialTargetKeys = mockData 9 | .filter((item) => +item.key > 10) 10 | .map((item) => item.key); 11 | 12 | const Demo = () => { 13 | const [targetKeys, setTargetKeys] = useState(initialTargetKeys); 14 | const [selectedKeys, setSelectedKeys] = useState(['1', '2']); 15 | const onScroll = () => {}; 16 | return ( 17 | { 23 | setTargetKeys(nextTargetKeys); 24 | }} 25 | onSelectChange={(sourceSelectedKeys, targetSelectedKeys) => { 26 | setSelectedKeys([...sourceSelectedKeys, ...targetSelectedKeys]); 27 | }} 28 | onScroll={onScroll} 29 | render={(item) => item.title} 30 | /> 31 | ); 32 | }; 33 | 34 | const componentDemo: ComponentDemo = { 35 | demo: , 36 | tokens: [ 37 | 'controlItemBgActiveHover', 38 | 'controlItemBgActive', 39 | 'colorBgContainer', 40 | ], 41 | key: 'default', 42 | }; 43 | 44 | export default componentDemo; 45 | -------------------------------------------------------------------------------- /src/previews/components/transfer/warning.tsx: -------------------------------------------------------------------------------- 1 | import { Transfer } from 'antd'; 2 | import type { Key} from 'react'; 3 | import React, { useState } from 'react'; 4 | 5 | import type { ComponentDemo } from '../../../interface'; 6 | 7 | const mockData: any[] = []; 8 | for (let i = 0; i < 20; i++) { 9 | mockData.push({ 10 | key: i.toString(), 11 | title: `content${i + 1}`, 12 | description: `description of content${i + 1}`, 13 | }); 14 | } 15 | 16 | const initialTargetKeys = mockData 17 | .filter((item) => +item.key > 10) 18 | .map((item) => item.key); 19 | 20 | const Demo = () => { 21 | const [targetKeys, setTargetKeys] = useState(initialTargetKeys); 22 | const [selectedKeys, setSelectedKeys] = useState([]); 23 | const onScroll = () => {}; 24 | return ( 25 | { 32 | setTargetKeys(nextTargetKeys); 33 | }} 34 | onSelectChange={(sourceSelectedKeys, targetSelectedKeys) => { 35 | setSelectedKeys([...sourceSelectedKeys, ...targetSelectedKeys]); 36 | }} 37 | onScroll={onScroll} 38 | render={(item) => item.title} 39 | /> 40 | ); 41 | }; 42 | 43 | const componentDemo: ComponentDemo = { 44 | demo: , 45 | tokens: ['colorWarning'], 46 | key: 'warning', 47 | }; 48 | 49 | export default componentDemo; 50 | -------------------------------------------------------------------------------- /src/previews/components/tree/disabled.tsx: -------------------------------------------------------------------------------- 1 | import { Tree } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const treeData = [ 6 | { 7 | title: 'parent 1', 8 | key: '0-0', 9 | children: [ 10 | { 11 | title: 'parent 1-0', 12 | key: '0-0-0', 13 | disabled: true, 14 | children: [ 15 | { title: 'leaf', key: '0-0-0-0', disableCheckbox: true }, 16 | { title: 'leaf', key: '0-0-0-1' }, 17 | ], 18 | }, 19 | { 20 | title: 'parent 1-1', 21 | key: '0-0-1', 22 | children: [ 23 | { 24 | title: sss, 25 | key: '0-0-1-0', 26 | }, 27 | ], 28 | }, 29 | ], 30 | }, 31 | ]; 32 | const Demo = () => { 33 | return ( 34 | 42 | ); 43 | }; 44 | 45 | const componentDemo: ComponentDemo = { 46 | demo: , 47 | tokens: ['colorTextDisabled', 'colorBgContainerDisabled'], 48 | key: 'disabled', 49 | }; 50 | 51 | export default componentDemo; 52 | -------------------------------------------------------------------------------- /src/previews/components/tree/index.ts: -------------------------------------------------------------------------------- 1 | import disabled from './disabled'; 2 | import Demo from './tree'; 3 | 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const previewerDemo: ComponentDemo[] = [Demo, disabled]; 7 | 8 | export default previewerDemo; 9 | -------------------------------------------------------------------------------- /src/previews/components/tree/tree.tsx: -------------------------------------------------------------------------------- 1 | import { Tree } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const treeData = [ 6 | { 7 | title: 'parent 1', 8 | key: '0-0', 9 | children: [ 10 | { 11 | title: 'parent 1-0', 12 | key: '0-0-0', 13 | disabled: true, 14 | children: [ 15 | { title: 'leaf', key: '0-0-0-0', disableCheckbox: true }, 16 | { title: 'leaf', key: '0-0-0-1' }, 17 | ], 18 | }, 19 | { 20 | title: 'parent 1-1', 21 | key: '0-0-1', 22 | children: [ 23 | { 24 | title: sss, 25 | key: '0-0-1-0', 26 | }, 27 | ], 28 | }, 29 | ], 30 | }, 31 | ]; 32 | const Demo = () => { 33 | return ( 34 | 41 | ); 42 | }; 43 | 44 | const componentDemo: ComponentDemo = { 45 | demo: , 46 | tokens: ['colorPrimary', 'controlOutline', 'colorBgContainer'], 47 | key: 'default', 48 | }; 49 | 50 | export default componentDemo; 51 | -------------------------------------------------------------------------------- /src/previews/components/treeSelect/disabled.tsx: -------------------------------------------------------------------------------- 1 | import { TreeSelect as _TreeSelect } from 'antd'; 2 | import React, { useState } from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { TreeNode, _InternalPanelDoNotUseOrYouWillBeFired: TreeSelect } = 6 | _TreeSelect; 7 | 8 | const Demo = () => { 9 | const [value, setValue] = useState(undefined); 10 | const onChange = () => { 11 | setValue(value); 12 | }; 13 | return ( 14 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | ); 36 | }; 37 | 38 | const componentDemo: ComponentDemo = { 39 | demo: , 40 | tokens: ['colorTextDisabled', 'colorBgContainerDisabled'], 41 | key: 'disabled', 42 | }; 43 | 44 | export default componentDemo; 45 | -------------------------------------------------------------------------------- /src/previews/components/treeSelect/index.ts: -------------------------------------------------------------------------------- 1 | import disabled from './disabled'; 2 | import Default from './tree-select'; 3 | 4 | import type { ComponentDemo } from '../../../interface'; 5 | 6 | const previewerDemo: ComponentDemo[] = [Default, disabled]; 7 | 8 | export default previewerDemo; 9 | -------------------------------------------------------------------------------- /src/previews/components/treeSelect/tree-select.tsx: -------------------------------------------------------------------------------- 1 | import { TreeSelect as _TreeSelect } from 'antd'; 2 | import React, { useState } from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { TreeNode, _InternalPanelDoNotUseOrYouWillBeFired: TreeSelect } = 6 | _TreeSelect; 7 | 8 | const Demo = () => { 9 | const [value, setValue] = useState(undefined); 10 | const onChange = () => { 11 | setValue(value); 12 | }; 13 | return ( 14 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | ); 35 | }; 36 | 37 | const componentDemo: ComponentDemo = { 38 | demo: , 39 | tokens: [ 40 | 'colorPrimary', 41 | 'colorPrimaryActive', 42 | 'controlOutline', 43 | 'colorBgElevated', 44 | 'colorBgContainer', 45 | ], 46 | key: 'default', 47 | }; 48 | 49 | export default componentDemo; 50 | -------------------------------------------------------------------------------- /src/previews/components/typography/Heading4.tsx: -------------------------------------------------------------------------------- 1 | import { Typography } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { Title } = Typography; 6 | 7 | const Demo = () => Heading 4; 8 | 9 | const componentDemo: ComponentDemo = { 10 | demo: , 11 | tokens: ['fontSizeHeading4'], 12 | key: 'heading4', 13 | }; 14 | 15 | export default componentDemo; 16 | -------------------------------------------------------------------------------- /src/previews/components/typography/error.tsx: -------------------------------------------------------------------------------- 1 | import { Typography } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { Title, Text } = Typography; 6 | 7 | const Demo = () => ( 8 |
9 | 10 | Error Title 11 | 12 | error Text 13 |
14 | ); 15 | 16 | const componentDemo: ComponentDemo = { 17 | demo: , 18 | tokens: ['colorError', 'colorErrorHover', 'colorErrorActive'], 19 | key: 'error', 20 | }; 21 | 22 | export default componentDemo; 23 | -------------------------------------------------------------------------------- /src/previews/components/typography/index.tsx: -------------------------------------------------------------------------------- 1 | import error from './error'; 2 | import Heading4 from './Heading4'; 3 | import success from './success'; 4 | import TypographyDemo from './typography'; 5 | import warning from './warning'; 6 | 7 | import type { ComponentDemo } from '../../../interface'; 8 | 9 | const previewerDemo: ComponentDemo[] = [ 10 | TypographyDemo, 11 | Heading4, 12 | error, 13 | warning, 14 | success, 15 | ]; 16 | 17 | export default previewerDemo; 18 | -------------------------------------------------------------------------------- /src/previews/components/typography/success.tsx: -------------------------------------------------------------------------------- 1 | import { Typography } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { Title, Text } = Typography; 6 | 7 | const Demo = () => ( 8 |
9 | 10 | Success Title 11 | 12 | success Text 13 |
14 | ); 15 | 16 | const componentDemo: ComponentDemo = { 17 | demo: , 18 | tokens: ['colorSuccess'], 19 | key: 'success', 20 | }; 21 | 22 | export default componentDemo; 23 | -------------------------------------------------------------------------------- /src/previews/components/typography/typography.tsx: -------------------------------------------------------------------------------- 1 | import { Typography } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { Title, Paragraph, Text, Link } = Typography; 6 | const Demo = () => ( 7 | 8 | 《故乡》 9 | ——鲁迅 10 | 11 | 深蓝的天空中挂着一轮金黄的圆月 12 | ,下面是海边的沙地,都种着一望无际的碧绿的西瓜,其间有一个十一二岁的少年,项带银圈,手捏一柄钢叉, 13 | 向一匹猹尽力的刺去 14 | ,那猹却将身一扭,反从他的胯下逃走了。 15 | 16 | 17 |
    18 |
  • 19 | 狂人日记 20 |
  • 21 |
  • 22 | 呐喊 23 |
  • 24 |
  • 25 | 彷徨 26 |
  • 27 |
28 |
29 |
30 | ); 31 | 32 | const componentDemo: ComponentDemo = { 33 | demo: , 34 | tokens: ['colorSuccess'], 35 | key: 'default', 36 | }; 37 | 38 | export default componentDemo; 39 | -------------------------------------------------------------------------------- /src/previews/components/typography/warning.tsx: -------------------------------------------------------------------------------- 1 | import { Typography } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { Title, Text } = Typography; 6 | 7 | const Demo = () => ( 8 |
9 | 10 | Error Title 11 | 12 | error Text 13 |
14 | ); 15 | 16 | const componentDemo: ComponentDemo = { 17 | demo: , 18 | tokens: ['colorWarning'], 19 | key: 'warning', 20 | }; 21 | 22 | export default componentDemo; 23 | -------------------------------------------------------------------------------- /src/previews/components/typography/warningText.tsx: -------------------------------------------------------------------------------- 1 | import { Typography } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { Text } = Typography; 6 | 7 | const Demo = () => ( 8 |
9 | Warning Title 10 |
11 | ); 12 | 13 | const componentDemo: ComponentDemo = { 14 | demo: , 15 | tokens: ['colorWarning'], 16 | key: 'warning', 17 | }; 18 | 19 | export default componentDemo; 20 | -------------------------------------------------------------------------------- /src/previews/components/typography/warningTitle.tsx: -------------------------------------------------------------------------------- 1 | import { Typography } from 'antd'; 2 | import React from 'react'; 3 | import type { ComponentDemo } from '../../../interface'; 4 | 5 | const { Title } = Typography; 6 | 7 | const Demo = () => ( 8 |
9 | 10 | Warning Text 11 | 12 |
13 | ); 14 | 15 | const componentDemo: ComponentDemo = { 16 | demo: , 17 | tokens: ['colorWarning'], 18 | key: 'warning', 19 | }; 20 | 21 | export default componentDemo; 22 | -------------------------------------------------------------------------------- /src/previews/components/upload/avatar.tsx: -------------------------------------------------------------------------------- 1 | import { PlusOutlined } from '@ant-design/icons'; 2 | import { Upload } from 'antd'; 3 | import React from 'react'; 4 | 5 | import type { ComponentDemo } from '../../../interface'; 6 | 7 | const Demo = () => ( 8 |
9 | 16 |
17 | 18 |
Upload
19 |
20 |
21 |
22 | ); 23 | 24 | const componentDemo: ComponentDemo = { 25 | demo: , 26 | tokens: ['colorFillAlter'], 27 | key: 'avatar', 28 | }; 29 | 30 | export default componentDemo; 31 | -------------------------------------------------------------------------------- /src/previews/components/upload/danger.tsx: -------------------------------------------------------------------------------- 1 | import { UploadOutlined } from '@ant-design/icons'; 2 | import { Button, Upload } from 'antd'; 3 | import React from 'react'; 4 | 5 | import type { ComponentDemo } from '../../../interface'; 6 | 7 | const Demo = () => ( 8 |
9 | 20 | 21 | 22 | 33 | 34 | 35 |
36 | ); 37 | 38 | const componentDemo: ComponentDemo = { 39 | demo: , 40 | tokens: ['colorError', 'colorErrorBg'], 41 | key: 'danger', 42 | }; 43 | 44 | export default componentDemo; 45 | -------------------------------------------------------------------------------- /src/previews/components/upload/index.ts: -------------------------------------------------------------------------------- 1 | import avatar from './avatar'; 2 | import danger from './danger'; 3 | import Default from './upload'; 4 | 5 | import type { ComponentDemo } from '../../../interface'; 6 | 7 | const previewerDemo: ComponentDemo[] = [Default, danger, avatar]; 8 | 9 | export default previewerDemo; 10 | -------------------------------------------------------------------------------- /src/previews/components/upload/upload.tsx: -------------------------------------------------------------------------------- 1 | import { UploadOutlined } from '@ant-design/icons'; 2 | import type { UploadProps } from 'antd'; 3 | import { Button, message, Upload } from 'antd'; 4 | import React from 'react'; 5 | 6 | import type { ComponentDemo } from '../../../interface'; 7 | 8 | const props: UploadProps = { 9 | name: 'file', 10 | action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76', 11 | headers: { authorization: 'authorization-text' }, 12 | onChange(info) { 13 | if (info.file.status === 'done') { 14 | message.success(`${info.file.name} file uploaded successfully`); 15 | } else if (info.file.status === 'error') { 16 | message.error(`${info.file.name} file upload failed.`); 17 | } 18 | }, 19 | }; 20 | const Demo = () => ( 21 | 22 | 23 | 24 | ); 25 | 26 | const componentDemo: ComponentDemo = { 27 | demo: , 28 | tokens: ['colorPrimary', 'colorPrimaryHover', 'colorPrimaryActive'], 29 | key: 'upload', 30 | }; 31 | 32 | export default componentDemo; 33 | -------------------------------------------------------------------------------- /src/previews/overviews/Error.tsx: -------------------------------------------------------------------------------- 1 | import { Flexbox } from '@arvinxu/layout-kit'; 2 | import { Card } from 'antd'; 3 | import React from 'react'; 4 | 5 | import Alert from '../components/alert/error'; 6 | import Badge from '../components/badge/badge'; 7 | import Button from '../components/button/dangerButton'; 8 | import Dropdown from '../components/dropdown/dropdownError'; 9 | import Menu from '../components/menu/menuDanger'; 10 | import Message from '../components/message/error'; 11 | import Notification from '../components/notification/error'; 12 | import Progress from '../components/progress/danger'; 13 | import Tag from '../components/tag/error'; 14 | import Timeline from '../components/timeline/danger'; 15 | import Upload from '../components/upload/danger'; 16 | 17 | export const Error = ({ id }: { id?: string }) => { 18 | return ( 19 | 20 | 21 | 22 | 28 | {Button.demo} 29 |
{Tag.demo}
30 | {Badge.demo} 31 |
32 | {Alert.demo} 33 |
34 | 35 | {Message.demo} 36 | {Progress.demo} 37 | 38 |
39 | 40 |
{Notification.demo}
41 |
{Timeline.demo}
42 |
43 | 44 | {Menu.demo} 45 |
{Upload.demo}
46 | {Dropdown.demo} 47 |
48 |
49 | ); 50 | }; 51 | -------------------------------------------------------------------------------- /src/previews/overviews/Primary.tsx: -------------------------------------------------------------------------------- 1 | import { Card, Space } from 'antd'; 2 | import React from 'react'; 3 | 4 | import Button from '../components/button/button-icon'; 5 | import Checkbox from '../components/checkbox/checkbox'; 6 | import Menu from '../components/menu/menu'; 7 | import Pagination from '../components/pagination/outline'; 8 | import Popconfirm from '../components/popconfirm/popconfirm'; 9 | import RadioButton from '../components/radio/button'; 10 | import Radio from '../components/radio/radio'; 11 | import SelectTag from '../components/select/selectTag'; 12 | import Steps from '../components/steps/steps'; 13 | import Switch from '../components/switch/switch'; 14 | import Table from '../components/table/table'; 15 | import Tabs from '../components/tabs/tabs'; 16 | import Timeline from '../components/timeline/timeline'; 17 | 18 | export const Primary = ({ id }: { id?: string }) => { 19 | return ( 20 | 21 | 22 | 23 | {Menu.demo} 24 | 25 | 26 | 27 |
{Button.demo}
28 |
29 | {Radio.demo} 30 | {Checkbox.demo} 31 | {Switch.demo} 32 |
33 |
{RadioButton.demo}
34 | {Tabs.demo} 35 |
36 | {SelectTag.demo} 37 |
38 | {Pagination.demo} 39 |
{Steps.demo}
40 | 41 | {Popconfirm.demo} 42 | {Timeline.demo} 43 | 44 |
45 |
46 | {Table.demo} 47 |
48 |
49 | ); 50 | }; 51 | -------------------------------------------------------------------------------- /src/previews/overviews/Success.tsx: -------------------------------------------------------------------------------- 1 | import { Card } from 'antd'; 2 | import React from 'react'; 3 | 4 | import Alert from '../components/alert/success'; 5 | import Input from '../components/input/success'; 6 | import Message from '../components/message/success'; 7 | import Notification from '../components/notification/success'; 8 | import Progress from '../components/progress/success'; 9 | import Result from '../components/result/success'; 10 | import Tag from '../components/tag/success'; 11 | import Timeline from '../components/timeline/success'; 12 | 13 | import { Flexbox } from '@arvinxu/layout-kit'; 14 | 15 | export const Success = ({ id }: { id?: string }) => { 16 | return ( 17 | 18 | 19 | 20 | 21 |
{Tag.demo}
22 | {Input.demo} 23 |
24 | {Alert.demo} 25 |
26 | 27 | {Message.demo} 28 | {Progress.demo} 29 | 30 |
31 | 32 |
{Notification.demo}
33 |
{Timeline.demo}
34 |
35 | {Result.demo} 36 |
37 | ); 38 | }; 39 | -------------------------------------------------------------------------------- /src/previews/overviews/Warning.tsx: -------------------------------------------------------------------------------- 1 | import { Card } from 'antd'; 2 | import React from 'react'; 3 | 4 | import Alert from '../components/alert/warning'; 5 | import Badge from '../components/badge/warning'; 6 | import Input from '../components/input/warning'; 7 | import Message from '../components/message/warning'; 8 | import Modal from '../components/modal/warning'; 9 | import Notification from '../components/notification/warning'; 10 | import Popconfirm from '../components/popconfirm/popconfirm'; 11 | import Result from '../components/result/warning'; 12 | import Tag from '../components/tag/warning'; 13 | import Text from '../components/typography/warningText'; 14 | import Title from '../components/typography/warningTitle'; 15 | 16 | import { Flexbox } from '@arvinxu/layout-kit'; 17 | 18 | export const Warning = ({ id }: { id?: string }) => { 19 | return ( 20 | 21 | 22 | 23 | 24 |
{Title.demo}
25 |
{Input.demo}
26 |
27 | {Alert.demo} 28 |
29 | 30 | {Message.demo} 31 | {Popconfirm.demo} 32 | 33 | {Badge.demo} 34 | {Tag.demo} 35 | {Text.demo} 36 | 37 | 38 |
39 | 40 |
{Notification.demo}
41 |
{Modal.demo}
42 |
43 | {Result.demo} 44 |
45 | ); 46 | }; 47 | -------------------------------------------------------------------------------- /src/previews/overviews/index.ts: -------------------------------------------------------------------------------- 1 | export * from './Error'; 2 | export * from './Primary'; 3 | export * from './Success'; 4 | export * from './Warning'; 5 | -------------------------------------------------------------------------------- /src/token-panel-pro/InputNumberPlus.tsx: -------------------------------------------------------------------------------- 1 | import { InputNumber, Slider } from 'antd'; 2 | import type { FC } from 'react'; 3 | import React from 'react'; 4 | 5 | export type InputNumberPlusProps = { 6 | value?: number; 7 | onChange?: (value: number | null) => void; 8 | min?: number; 9 | max?: number; 10 | style?: React.CSSProperties; 11 | }; 12 | 13 | const InputNumberPlus: FC = ({ 14 | value, 15 | onChange, 16 | min, 17 | max, 18 | style, 19 | }) => { 20 | return ( 21 |
22 | 29 | 36 |
37 | ); 38 | }; 39 | 40 | export default InputNumberPlus; 41 | -------------------------------------------------------------------------------- /src/token-panel-pro/ResetTokenButton.tsx: -------------------------------------------------------------------------------- 1 | import { Typography } from 'antd'; 2 | import type { FC } from 'react'; 3 | import React from 'react'; 4 | import type { MutableTheme } from '../interface'; 5 | import { useLocale } from '../locale'; 6 | 7 | export type ResetTokenButtonProps = { 8 | theme: MutableTheme; 9 | tokenName: string; 10 | style?: React.CSSProperties; 11 | }; 12 | const ResetTokenButton: FC = ({ 13 | theme, 14 | tokenName, 15 | style, 16 | }) => { 17 | const locale = useLocale(); 18 | const showReset = (theme.config.token as any)?.[tokenName]; 19 | return ( 20 |
21 | theme.onAbort?.(['token', tokenName])} 29 | > 30 | {locale.reset} 31 | 32 |
33 | ); 34 | }; 35 | 36 | export default ResetTokenButton; 37 | -------------------------------------------------------------------------------- /src/utils/classifyToken.ts: -------------------------------------------------------------------------------- 1 | import type { GlobalToken } from 'antd/es/theme/interface'; 2 | import type { TokenValue } from '../interface'; 3 | 4 | function defineTokenType(types: T[]) { 5 | return types; 6 | } 7 | 8 | export const TOKEN_SORTS = defineTokenType([ 9 | 'seed', 10 | 'colorCommon', 11 | 'colorText', 12 | 'colorBg', 13 | 'colorFill', 14 | 'colorSplit', 15 | 'font', 16 | 'radius', 17 | 'space', 18 | 'screen', 19 | 'line', 20 | 'motion', 21 | 'control', 22 | 'others', 23 | ]); 24 | 25 | export type TokenType = typeof TOKEN_SORTS[number]; 26 | 27 | export function getTypeOfToken(tokenName: string): TokenType { 28 | if (tokenName.startsWith('color')) { 29 | if ( 30 | tokenName.startsWith('colorLink') || 31 | tokenName.startsWith('colorText') || 32 | tokenName.startsWith('colorIcon') || 33 | tokenName.startsWith('colorPlaceholder') || 34 | tokenName.startsWith('colorIcon') 35 | ) { 36 | return 'colorText'; 37 | } 38 | if ( 39 | tokenName.startsWith('colorBg') || 40 | tokenName.startsWith('colorPopupBg') 41 | ) { 42 | return 'colorBg'; 43 | } 44 | if ( 45 | tokenName.startsWith('colorBorder') || 46 | tokenName.startsWith('colorSplit') 47 | ) { 48 | return 'colorSplit'; 49 | } 50 | if (tokenName.startsWith('colorFill')) { 51 | return 'colorFill'; 52 | } 53 | return 'colorCommon'; 54 | } 55 | if (tokenName.startsWith('font')) { 56 | return 'font'; 57 | } 58 | if (tokenName.startsWith('screen')) { 59 | return 'screen'; 60 | } 61 | if (tokenName.startsWith('line')) { 62 | return 'line'; 63 | } 64 | if (tokenName.startsWith('motion')) { 65 | return 'motion'; 66 | } 67 | if (tokenName.startsWith('borderRadius')) { 68 | return 'radius'; 69 | } 70 | if (tokenName.startsWith('control')) { 71 | return 'control'; 72 | } 73 | if (tokenName.startsWith('margin') || tokenName.startsWith('padding')) { 74 | return 'space'; 75 | } 76 | return 'others'; 77 | } 78 | 79 | export const classifyToken = ( 80 | token: Record, 81 | ): Record => { 82 | const groupedToken: Record = {}; 83 | Object.keys(token || {}) 84 | .sort((a, b) => a.localeCompare(b)) 85 | .forEach((key) => { 86 | const type = getTypeOfToken(key as keyof GlobalToken); 87 | if (!groupedToken[type]) { 88 | groupedToken[type] = []; 89 | } 90 | groupedToken[type].push(key); 91 | }); 92 | return groupedToken; 93 | }; 94 | -------------------------------------------------------------------------------- /src/utils/constants.ts: -------------------------------------------------------------------------------- 1 | export const HIGHLIGHT_COLOR = '#FF5500'; 2 | -------------------------------------------------------------------------------- /src/utils/deepUpdateObj.ts: -------------------------------------------------------------------------------- 1 | const deepUpdateObj = (obj: any, path: string[], value: any): any => { 2 | if (path.length === 0) { 3 | return obj; 4 | } 5 | if (path.length === 1) { 6 | if (value === null || value === undefined) { 7 | const newObj = { ...obj }; 8 | delete newObj[path[0]]; 9 | return newObj; 10 | } 11 | return { 12 | ...obj, 13 | [path[0]]: value, 14 | }; 15 | } 16 | 17 | const pathValue = deepUpdateObj(obj[path[0]] ?? {}, path.slice(1), value); 18 | if ( 19 | pathValue === null || 20 | pathValue === undefined || 21 | Object.keys(pathValue).length === 0 22 | ) { 23 | const newObj = { ...obj }; 24 | delete newObj[path[0]]; 25 | return newObj; 26 | } 27 | return { 28 | ...obj, 29 | [path[0]]: pathValue, 30 | }; 31 | }; 32 | 33 | export default deepUpdateObj; 34 | -------------------------------------------------------------------------------- /src/utils/getColorBgImg.ts: -------------------------------------------------------------------------------- 1 | const getColorBgImg = (dark?: boolean) => { 2 | return dark 3 | ? 'url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAIAAAD8GO2jAAAABGdBTUEAALGPC/xhBQAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAIKADAAQAAAABAAAAIAAAAACPTkDJAAAAZUlEQVRIDe2VMQoAMAgDa9/g/1/oIzrpZBCh2dLFkkoDF0Fz99OdiOjks+2/7S8fRRmMMIVoRGSoYzvvqF8ZIMKlC1GhQBc6IkPzq32QmdAzkEGihpWOSPsAss8HegYySNSw0hE9WQ4StafZFqkAAAAASUVORK5CYII=)' 4 | : 'url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABGdBTUEAALGPC/xhBQAAAFpJREFUWAntljEKADAIA23p6v//qQ+wfUEcCu1yriEgp0FHRJSJcnehmmWm1Dv/lO4HIg1AAAKjTqm03ea88zMCCEDgO4HV5bS757f+7wRoAAIQ4B9gByAAgQ3pfiDmXmAeEwAAAABJRU5ErkJggg==)'; 5 | }; 6 | 7 | export default getColorBgImg; 8 | -------------------------------------------------------------------------------- /src/utils/getDesignToken.ts: -------------------------------------------------------------------------------- 1 | import type { ThemeConfig } from 'antd/es/config-provider/context'; 2 | import type { GlobalToken, MapToken } from 'antd/es/theme/interface'; 3 | import defaultMap from 'antd/es/theme/themes/default'; 4 | import seed from 'antd/es/theme/themes/seed'; 5 | import formatToken from 'antd/es/theme/util/alias'; 6 | 7 | export default function getDesignToken(config: ThemeConfig = {}): GlobalToken { 8 | const seedToken = { ...seed, ...config.token }; 9 | const mapFn = config.algorithm ?? defaultMap; 10 | const mapToken = Array.isArray(mapFn) 11 | ? mapFn.reduce( 12 | (result, fn) => fn(seedToken, result), 13 | undefined as any, 14 | ) 15 | : mapFn(seedToken); 16 | const mergedMapToken = { 17 | ...mapToken, 18 | ...config.components, 19 | override: config.token ?? {}, 20 | }; 21 | return formatToken(mergedMapToken); 22 | } 23 | -------------------------------------------------------------------------------- /src/utils/getValueByPath.ts: -------------------------------------------------------------------------------- 1 | export default function getValueByPath(obj: any, path: string[]): any { 2 | if (!obj) { 3 | return undefined; 4 | } 5 | return path.reduce((prev, key) => { 6 | if (prev) { 7 | return prev[key]; 8 | } 9 | return undefined; 10 | }, obj); 11 | } 12 | -------------------------------------------------------------------------------- /src/utils/isColor.ts: -------------------------------------------------------------------------------- 1 | export default function isColor(str: string) { 2 | return ( 3 | typeof str === 'string' && (str.startsWith('rgb') || str.startsWith('#')) 4 | ); 5 | } 6 | -------------------------------------------------------------------------------- /src/utils/makeStyle.tsx: -------------------------------------------------------------------------------- 1 | import type { CSSInterpolation } from '@ant-design/cssinjs'; 2 | import { useStyleRegister } from '@ant-design/cssinjs'; 3 | import { ConfigProvider, theme as antdTheme } from 'antd'; 4 | import type { GlobalToken } from 'antd/es/theme/interface'; 5 | import { useContext } from 'react'; 6 | 7 | const { ConfigContext } = ConfigProvider; 8 | 9 | export type ThemeEditorToken = GlobalToken & { 10 | rootCls: string; 11 | componentCls: string; 12 | headerHeight: number; 13 | }; 14 | 15 | const makeStyle = 16 | ( 17 | path: string, 18 | styleFn: (token: ThemeEditorToken) => CSSInterpolation, 19 | ): (( 20 | prefixCls?: string, 21 | ) => string) => 22 | (prefixCls) => { 23 | const { theme, token, hashId } = antdTheme.useToken(); 24 | const { getPrefixCls } = useContext(ConfigContext); 25 | const rootCls = getPrefixCls(); 26 | 27 | useStyleRegister( 28 | { theme: theme as any, hashId, token, path: [path, prefixCls || ''] }, 29 | () => 30 | styleFn({ 31 | ...token, 32 | rootCls: `.${rootCls}`, 33 | componentCls: `.${prefixCls}`, 34 | headerHeight: 56, 35 | }), 36 | ) 37 | 38 | return hashId; 39 | }; 40 | 41 | export default makeStyle; 42 | -------------------------------------------------------------------------------- /src/utils/parse-config.ts: -------------------------------------------------------------------------------- 1 | import type { ThemeConfig } from 'antd'; 2 | import { theme } from 'antd'; 3 | 4 | export type Algorithm = 'dark' | 'compact'; 5 | 6 | export interface PlainThemeConfig extends Omit { 7 | algorithm?: Algorithm | Algorithm[]; 8 | } 9 | 10 | export const algorithmMap: { 11 | [key in Algorithm]: typeof theme.darkAlgorithm; 12 | } = { 13 | dark: theme.darkAlgorithm, 14 | compact: theme.compactAlgorithm, 15 | }; 16 | 17 | export const getAlgorithmString = (algorithm: typeof theme.darkAlgorithm) => { 18 | return Object.entries(algorithmMap).find( 19 | ([, value]) => value === algorithm, 20 | )?.[0] as Algorithm; 21 | }; 22 | 23 | export const parsePlainConfig = (config: ThemeConfig): PlainThemeConfig => { 24 | const { algorithm, ...rest } = config; 25 | if (!algorithm) return rest; 26 | 27 | const parsedAlgorithms = Array.isArray(algorithm) 28 | ? algorithm.map(getAlgorithmString) 29 | : getAlgorithmString(algorithm); 30 | return { 31 | ...rest, 32 | algorithm: parsedAlgorithms, 33 | }; 34 | }; 35 | 36 | export const parseThemeConfig = (config: PlainThemeConfig): ThemeConfig => { 37 | const { algorithm, ...rest } = config; 38 | if (!algorithm) return rest; 39 | 40 | const parsedAlgorithms = Array.isArray(algorithm) 41 | ? algorithm.map((item) => algorithmMap[item]).filter(Boolean) 42 | : algorithmMap[algorithm]; 43 | return { 44 | ...rest, 45 | algorithm: parsedAlgorithms, 46 | }; 47 | }; 48 | -------------------------------------------------------------------------------- /src/utils/statistic.ts: -------------------------------------------------------------------------------- 1 | import tokenStatistic from 'antd/es/version/token.json'; 2 | 3 | const tokenRelatedComponents: { 4 | [key in string]?: string[]; 5 | } = {}; 6 | 7 | const getRelatedComponentsSingle = (token: string): string[] => { 8 | if (!tokenRelatedComponents[token]) { 9 | tokenRelatedComponents[token] = Object.entries(tokenStatistic) 10 | .filter(([, tokens]) => { 11 | return (tokens.global as string[]).includes(token); 12 | }) 13 | .map(([component]) => component); 14 | } 15 | return tokenRelatedComponents[token] ?? []; 16 | }; 17 | 18 | export const getRelatedComponents = (token: string | string[]): string[] => { 19 | const mergedTokens = Array.isArray(token) ? token : [token]; 20 | return Array.from( 21 | new Set( 22 | mergedTokens.reduce((result, item) => { 23 | return result.concat(getRelatedComponentsSingle(item)); 24 | }, []), 25 | ), 26 | ); 27 | }; 28 | 29 | export const getComponentToken = (component: string) => 30 | (tokenStatistic as any)[component]; 31 | -------------------------------------------------------------------------------- /tests/TokenInput.test.tsx: -------------------------------------------------------------------------------- 1 | import { fireEvent, render } from '@testing-library/react'; 2 | import React from 'react'; 3 | import TokenInput from '../src/TokenInput'; 4 | 5 | describe('TokenInput', () => { 6 | it('reset btn should display correctly', () => { 7 | const { container } = render(); 8 | expect( 9 | container.querySelector('.ant-input-group-addon > span > button'), 10 | ).toBeFalsy(); 11 | fireEvent.change(container.querySelector('input')!, { 12 | target: { value: 'newVal' }, 13 | }); 14 | 15 | expect( 16 | container.querySelector('.ant-input-group-addon > span > button'), 17 | ).toBeTruthy(); 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /tests/utils.test.tsx: -------------------------------------------------------------------------------- 1 | import { render } from '@testing-library/react'; 2 | import { ConfigProvider, theme } from 'antd'; 3 | import { getDesignToken } from 'antd-token-previewer'; 4 | import type { ThemeConfig } from 'antd/es/config-provider/context'; 5 | import React from 'react'; 6 | import getValueByPath from '../src/utils/getValueByPath'; 7 | 8 | const { useToken, darkAlgorithm } = theme; 9 | 10 | describe('Utils', () => { 11 | describe('getValueByPath', () => { 12 | it('should work', () => { 13 | const obj = { 14 | a: { 15 | b: { 16 | c: 'c', 17 | }, 18 | }, 19 | }; 20 | expect(getValueByPath(obj, ['a', 'b', 'c'])).toBe('c'); 21 | }); 22 | 23 | it('should return null when path is not exist', () => { 24 | expect(getValueByPath({}, ['a', 'b'])).toBeUndefined(); 25 | }); 26 | 27 | it('null object should return null', () => { 28 | expect(getValueByPath(null, ['a', 'b'])).toBeUndefined(); 29 | }); 30 | }); 31 | 32 | it('getDesignToken should be consistent with useToken', () => { 33 | const themeConfig: ThemeConfig = { 34 | token: { 35 | colorPrimary: '#f5f5', 36 | colorLink: '#66ccff', 37 | }, 38 | algorithm: darkAlgorithm, 39 | }; 40 | let tokenFromHook; 41 | 42 | const Component = () => { 43 | const { token } = useToken(); 44 | tokenFromHook = token; 45 | delete (tokenFromHook as any)._hashId; 46 | delete (tokenFromHook as any)._tokenKey; 47 | return null; 48 | }; 49 | 50 | render( 51 | 52 | 53 | , 54 | ); 55 | expect(getDesignToken(themeConfig)).toStrictEqual(tokenFromHook); 56 | }); 57 | }); 58 | -------------------------------------------------------------------------------- /tests/utils/setup.js: -------------------------------------------------------------------------------- 1 | if (!window.matchMedia) { 2 | Object.defineProperty(global.window, 'matchMedia', { 3 | value: jest.fn((query) => ({ 4 | matches: query.includes('max-width'), 5 | addListener: jest.fn(), 6 | removeListener: jest.fn(), 7 | })), 8 | }); 9 | } 10 | -------------------------------------------------------------------------------- /tests/utils/setupAfterEnv.ts: -------------------------------------------------------------------------------- 1 | jest.mock('antd', () => { 2 | const antd = jest.requireActual('antd'); 3 | antd.theme.defaultConfig.hashed = false; 4 | 5 | return antd; 6 | }); 7 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "module": "ESNext", 5 | "moduleResolution": "node", 6 | "baseUrl": "./", 7 | "lib": ["dom", "es2017"], 8 | "jsx": "react", 9 | "strict": true, 10 | "esModuleInterop": true, 11 | "experimentalDecorators": true, 12 | "emitDecoratorMetadata": true, 13 | "resolveJsonModule": true, 14 | "skipLibCheck": true, 15 | "declaration": true, 16 | "paths": { 17 | "antd-token-previewer": ["src/index.tsx"] 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /type.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.css'; 2 | 3 | declare module '*.less'; 4 | --------------------------------------------------------------------------------