diff --git a/components/config-provider/demo/theme.md b/components/config-provider/demo/theme.md index ecc9d7a484..fc1d3d42a3 100644 --- a/components/config-provider/demo/theme.md +++ b/components/config-provider/demo/theme.md @@ -1,7 +1,7 @@ ## zh-CN -通过 css variable 修改全局主题色(你可以切换到组件页面查看更详细的样式展示),不支持 IE。自动生成的变量可能会根据设计调整,请勿直接依赖。详细配置请[点击查看](/docs/react/customize-theme-variable)。 +通过 `theme` 修改主题。 ## en-US -Modify global theme color by css variable which IE not support. Css variable depends on the design, it may adjust so please do not directly use it. You can go to other components page for more detail style. [Check this](/docs/react/customize-theme-variable) to view detail. +Modify theme by `theme` prop. diff --git a/components/config-provider/demo/theme.tsx b/components/config-provider/demo/theme.tsx index 37e304ead7..08f8eea60c 100644 --- a/components/config-provider/demo/theme.tsx +++ b/components/config-provider/demo/theme.tsx @@ -1,651 +1,46 @@ -import React, { useState } from 'react'; -import { - ClockCircleOutlined, - DownOutlined, - MailOutlined, - SettingOutlined, -} from '@ant-design/icons'; -import type { SpaceProps, TreeSelectProps } from 'antd'; -import { - Alert, - Button, - Card, - Checkbox, - Col, - ConfigProvider, - DatePicker, - Divider, - Dropdown, - Form, - Input, - InputNumber, - Mentions, - Menu, - Pagination, - Progress, - Radio, - Row, - Select, - Slider, - Space, - Spin, - Steps, - Switch, - Table, - Tabs, - Tag, - Timeline, - TimePicker, - Transfer, - Tree, - TreeSelect, - Typography, -} from 'antd'; +import React from 'react'; +import { Button, ConfigProvider, Form, InputNumber } from 'antd'; import { SketchPicker } from 'react-color'; -const SplitSpace: React.FC = props => ( - } size={4} {...props} /> -); - -const menuItems = [ - { - key: 'mail', - icon: , - label: 'Mail', - }, - { - key: 'SubMenu', - icon: , - label: 'Submenu', - children: [ - { - type: 'group', - label: 'Item 1', - children: [ - { - key: 'setting:1', - label: 'Option 1', - }, - { - key: 'setting:2', - label: 'Option 2', - }, - ], - }, - ], - }, -]; - -const inputProps = { - style: { width: 128 }, +type ThemeData = { + borderRadius: number; + colorPrimary: string; }; -const selectProps = { - ...inputProps, - options: [ - { value: 'light', label: 'Light' }, - { value: 'bamboo', label: 'Bamboo' }, - { value: 'little', label: 'Little' }, - ], +const defaultData: ThemeData = { + borderRadius: 6, + colorPrimary: '#1677ff', }; -const treeData = [ - { - value: 'little', - key: 'little', - label: 'Little', - title: 'Little', - children: [ - { value: 'light', key: 'light', label: 'Light', title: 'Light' }, - { value: 'bamboo', key: 'bamboo', label: 'Bamboo', title: 'Bamboo' }, - ], - }, -]; +export default () => { + const [form] = Form.useForm(); -const treeSelectProps: TreeSelectProps = { - ...inputProps, - treeCheckable: true, - maxTagCount: 'responsive', - treeData, -}; - -const carTabListNoTitle = [ - { - key: 'article', - tab: 'article', - }, - { - key: 'app', - tab: 'app', - }, - { - key: 'project', - tab: 'project', - }, -]; - -const MyTransfer = () => { - const mockData = []; - for (let i = 0; i < 20; i++) { - mockData.push({ - key: i.toString(), - title: `content${i + 1}`, - description: `description of content${i + 1}`, - }); - } + const [data, setData] = React.useState(defaultData); return ( - item.title} - /> + +
{ + setData({ ...nextData, colorPrimary: nextData.colorPrimary.hex }); + }} + name="theme" + initialValues={defaultData} + labelCol={{ span: 4 }} + wrapperCol={{ span: 20 }} + > + + + + + + + + + +
+
); }; - -const App: React.FC = () => { - const [color, setColor] = useState({ - primaryColor: '#1890ff', - errorColor: '#ff4d4f', - warningColor: '#faad14', - successColor: '#52c41a', - infoColor: '#1890ff', - }); - - const onColorChange = (nextColor: Partial) => { - const mergedNextColor = { - ...color, - ...nextColor, - }; - setColor(mergedNextColor); - ConfigProvider.config({ - theme: mergedNextColor, - }); - }; - - return ( - - - - {/* Primary Color */} - { - onColorChange({ - primaryColor: hex, - }); - }} - /> - - var(`--ant-primary-color`) - - {/* Error Color */} - { - onColorChange({ - errorColor: hex, - }); - }} - /> - - var(`--ant-error-color`) - - {/* Warning Color */} - { - onColorChange({ - warningColor: hex, - }); - }} - /> - - var(`--ant-warning-color`) - - {/* Success Color */} - { - onColorChange({ - successColor: hex, - }); - }} - /> - - var(`--ant-success-color`) - - {/* Info Color */} - { - onColorChange({ - infoColor: hex, - }); - }} - /> - - var(`--ant-info-color`) - - - - - } style={{ width: '100%' }} size={0}> - {/* Primary Button */} - - - - - - - - - {/* Danger Button */} - - - - - - - - - {/* Ghost Button */} - - - - - - - - - - {/* Typography */} - - Text (success) - Text(warning) - Text(danger) - - Link - - Text - - {/* Dropdown */} - - e.preventDefault()}> - - Hover me - - - - - - {/* Spin */} - - - - {/* Menu - horizontal */} - - - - - - - - - - {/* Menu - vertical */} - - - - - - - - - - {/* Pagination */} - - - {/* Steps */} - - - {/* Steps - dot */} - - - {/* Form - Input */} -
- - - - - - - - - - - - - - - - - -
- - {/* Form - Select */} -
- - - - - - - - -