import { BugOutlined, EyeOutlined } from '@ant-design/icons'; import { TinyColor } from '@ctrl/tinycolor'; import { Button, Select, Checkbox, Drawer, Form, Input, InputNumber, Space } from 'antd'; import * as React from 'react'; import { useState } from 'react'; import { useIntl } from 'react-intl'; import type { SeedToken } from '../../../../../components/theme'; import { PresetColors } from '../../../../../components/theme/interface'; import defaultSeedToken from '../../../../../components/theme/themes/seed'; import Diff from './Diff'; import Preview from './Preview'; export interface ThemeConfigProps { componentName: string; defaultToken: SeedToken; onChangeTheme: (theme: SeedToken) => void; } export default function DynamicTheme({ onChangeTheme, defaultToken, componentName, }: ThemeConfigProps) { const { formatMessage } = useIntl(); const [visible, setVisible] = React.useState(false); const [previewVisible, setPreviewVisible] = React.useState(false); const [form] = Form.useForm(); const [showDiff, setShowDiff] = useState(false); const keys = Object.keys(defaultSeedToken); const onFinish = (nextToken: SeedToken) => { onChangeTheme(nextToken); }; return ( <> {/* FIXME: need to be removed before published */}
setVisible(true)} > Dynamic Theme
{ setVisible(false); }} title={formatMessage({ id: 'app.theme.switch.dynamic' })} extra={ setShowDiff(e.target.checked)}> Diff } destroyOnClose >
; } const rules: any[] = [{ required: true }]; const originColor = new TinyColor(originValue); if (originValueType === 'string' && originColor.isValid) { rules.push({ validator: async (_: any, value: string) => { if (!new TinyColor(value).isValid) { throw new Error('Invalidate color type'); } }, }); } return ( {node} ); })} Bind Style on hash className
setPreviewVisible(false)} /> ); }