55 | >;
56 | children?: React.ReactNode;
57 | }
58 |
59 | export interface IconComponent extends React.FC
{
60 | createFromIconfontCN: typeof createFromIconfontCN;
61 | getTwoToneColor: typeof getTwoToneColor;
62 | setTwoToneColor: typeof setTwoToneColor;
63 | }
64 |
65 | const iconsMap: Record = allIcons;
66 |
67 | const LegacyTypeIcon: React.FC = props => {
68 | const { type, theme } = props;
69 |
70 | if (theme) {
71 | const themeInName = getThemeFromTypeName(type);
72 | warning(
73 | !themeInName || theme === themeInName,
74 | 'Icon',
75 | `The icon name '${type}' already specify a theme '${themeInName}',` +
76 | ` the 'theme' prop '${theme}' will be ignored.`,
77 | );
78 | }
79 | const computedType = withThemeSuffix(
80 | removeTypeTheme(alias(type)),
81 | theme || 'outlined',
82 | );
83 | const targetIconComponent = iconsMap[computedType];
84 | warning(
85 | targetIconComponent,
86 | 'Icon',
87 | `The icon name '${type}'${
88 | theme ? `with ${theme}` : ''
89 | } doesn't exist, please check it at https://ant.design/components/icon`,
90 | );
91 |
92 | return targetIconComponent
93 | ? React.createElement(targetIconComponent, props)
94 | : null;
95 | };
96 |
97 | const Icon: IconComponent = props => {
98 | const { type, component, children } = props;
99 |
100 | upgradeMessage('Icon');
101 |
102 | warning(
103 | Boolean(type || component || children),
104 | 'Icon',
105 | 'Should have `type` prop or `component` prop or `children`.',
106 | );
107 |
108 | if (component || children) {
109 | return ;
110 | }
111 |
112 | if (typeof type === 'string') {
113 | return ;
114 | }
115 |
116 | return ;
117 | };
118 |
119 | Icon.createFromIconfontCN = createFromIconfontCN;
120 | Icon.getTwoToneColor = getTwoToneColor;
121 | Icon.setTwoToneColor = setTwoToneColor;
122 |
123 | export default Icon;
124 |
--------------------------------------------------------------------------------
/src/icon/utils.ts:
--------------------------------------------------------------------------------
1 | import camelCase from 'lodash.camelcase';
2 | import upperFirst from 'lodash.upperfirst';
3 | import type { ThemeType } from './index';
4 | import warning from '../_util/warning';
5 |
6 | // These props make sure that the SVG behaviours like general text.
7 | // Reference: https://blog.prototypr.io/align-svg-icons-to-text-and-say-goodbye-to-font-icons-d44b3d7b26b4
8 | export const svgBaseProps = {
9 | width: '1em',
10 | height: '1em',
11 | fill: 'currentColor',
12 | 'aria-hidden': true,
13 | focusable: 'false',
14 | };
15 |
16 | // moved from https://github.com/ant-design/ant-design/blob/master/components/icon/utils.ts
17 | const fillTester = /-fill$/;
18 | const outlineTester = /-o$/;
19 | const twoToneTester = /-twotone$/;
20 |
21 | export function getThemeFromTypeName(type: string): ThemeType | null {
22 | let result: ThemeType | null = null;
23 | if (fillTester.test(type)) {
24 | result = 'filled';
25 | } else if (outlineTester.test(type)) {
26 | result = 'outlined';
27 | } else if (twoToneTester.test(type)) {
28 | result = 'twoTone';
29 | }
30 | return result;
31 | }
32 |
33 | export function removeTypeTheme(type: string) {
34 | return type
35 | .replace(fillTester, '')
36 | .replace(outlineTester, '')
37 | .replace(twoToneTester, '');
38 | }
39 |
40 | const themeMap: { [key in ThemeType]: string } = {
41 | filled: 'filled',
42 | outlined: 'outlined', // default theme
43 | twoTone: 'twoTone',
44 | };
45 |
46 | export function withThemeSuffix(type: string, theme: ThemeType) {
47 | const result = upperFirst(camelCase(type));
48 | const realTheme = upperFirst(themeMap[theme]);
49 |
50 | if (theme !== 'outlined' && !realTheme) {
51 | warning(false, 'Icon', `This icon '${type}' has unknown theme '${theme}'`);
52 | }
53 |
54 | return result + realTheme;
55 | }
56 |
57 | // For alias or compatibility
58 | export function alias(type: string) {
59 | let newType = type;
60 | switch (type) {
61 | case 'cross':
62 | newType = 'close';
63 | break;
64 | // https://github.com/ant-design/ant-design/issues/13007
65 | case 'interation':
66 | newType = 'interaction';
67 | break;
68 | // https://github.com/ant-design/ant-design/issues/16810
69 | case 'canlendar':
70 | newType = 'calendar';
71 | break;
72 | // https://github.com/ant-design/ant-design/issues/17448
73 | case 'colum-height':
74 | newType = 'column-height';
75 | break;
76 | default:
77 | }
78 | warning(
79 | newType === type,
80 | 'Icon',
81 | `Icon '${type}' was a typo and is now deprecated, please use '${newType}' instead.`,
82 | );
83 | return newType;
84 | }
85 |
--------------------------------------------------------------------------------
/src/index.tsx:
--------------------------------------------------------------------------------
1 | export { default as Comment } from './comment';
2 | export { default as Form } from './form';
3 | export { default as Icon } from './icon';
4 | export { darkAlgorithm, defaultAlgorithm, defaultTheme, darkTheme } from './theme';
5 | export { default as convertLegacyToken } from './theme/convertLegacyToken';
6 |
--------------------------------------------------------------------------------
/src/theme/convertLegacyToken.ts:
--------------------------------------------------------------------------------
1 | // Source:
2 | // https://github.com/ant-design/ant-design/blob/2c9fbc8f0c714c9de27fc2f54712acb69ac1abd8/components/style/themes/default.less
3 | import type { MapToken } from 'antd/lib/theme/interface';
4 | import formatToken from 'antd/lib/theme/util/alias';
5 |
6 | export default function convertLegacyToken(mapToken: MapToken) {
7 | const token = formatToken(mapToken as any);
8 |
9 | const raw = {
10 | theme: 'default',
11 | 'ant-prefix': 'ant',
12 | 'html-selector': 'html',
13 |
14 | // -------- Colors -----------
15 | // >>> Primary
16 | 'primary-color': token.colorPrimary,
17 | 'primary-color-hover': token.colorPrimaryHover,
18 | 'primary-color-active': token.colorPrimaryActive,
19 | 'primary-color-outline': 'fade(@primary-color, @outline-fade)',
20 | 'processing-color': token.colorPrimary,
21 |
22 | // >>> Info
23 | 'info-color': token.colorInfo,
24 | 'info-color-deprecated-bg': token.colorInfoBg,
25 | 'info-color-deprecated-border': token.colorInfoBorder,
26 |
27 | // >>> Success
28 | 'success-color': token.colorSuccess,
29 | 'success-color-hover': token.colorSuccessBgHover,
30 | 'success-color-active': token.colorSuccessActive,
31 | 'success-color-outline': 'fade(@success-color, @outline-fade)',
32 | 'success-color-deprecated-bg': token.colorSuccessBg,
33 | 'success-color-deprecated-border': token.colorSuccessBorder,
34 |
35 | // >>> Warning
36 | 'warning-color': token.colorWarning,
37 | 'warning-color-hover': token.colorWarningHover,
38 | 'warning-color-active': token.colorWarningActive,
39 | 'warning-color-outline': 'fade(@warning-color, @outline-fade)',
40 | 'warning-color-deprecated-bg': token.colorWarningBg,
41 | 'warning-color-deprecated-border': token.colorWarningBorder,
42 |
43 | // >>> Error
44 | 'error-color': token.colorError,
45 | 'error-color-hover': token.colorErrorHover,
46 | 'error-color-active': token.colorErrorActive,
47 | 'error-color-outline': 'fade(@error-color, @outline-fade)',
48 | 'error-color-deprecated-bg': token.colorErrorBg,
49 | 'error-color-deprecated-border': token.colorErrorBorder,
50 |
51 | 'highlight-color': token.colorHighlight,
52 | 'normal-color': '#d9d9d9',
53 | white: token.colorWhite,
54 | black: '#000',
55 |
56 | // Color used by default to control hover and active backgrounds and for
57 | // alert info backgrounds.
58 | 'primary-1': token.colorPrimaryBg,
59 | 'primary-2': token.colorPrimaryBgHover,
60 | 'primary-3': token.colorPrimaryBorder,
61 | 'primary-4': token.colorPrimaryBorderHover,
62 | 'primary-5': token.colorPrimaryHover,
63 | 'primary-6': token.colorPrimary,
64 | 'primary-7': token.colorPrimaryActive,
65 | 'primary-8': token.colorPrimaryTextHover,
66 | 'primary-9': token.colorPrimaryText,
67 | 'primary-10': token.colorPrimaryTextActive,
68 |
69 | // Base Scaffolding Variables
70 | // ---
71 | // Background color for ``
72 | 'body-background': token.colorBgBase,
73 |
74 | // Base background color for most components
75 | 'component-background': token.colorBgContainer,
76 |
77 | // Popover background color
78 | 'popover-background': token.colorBgElevated,
79 | 'popover-customize-border-color': token.colorSplit,
80 | 'font-family': token.fontFamily,
81 | 'code-family': "'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace",
82 | 'text-color': token.colorText,
83 | 'text-color-secondary': token.colorTextSecondary,
84 | 'text-color-inverse': token.colorWhite,
85 | 'icon-color': token.colorIcon,
86 | 'icon-color-hover': token.colorIconHover,
87 | 'heading-color': token.colorTextHeading,
88 | 'text-color-dark': 'fade(@white, 85%)',
89 | 'text-color-secondary-dark': 'fade(@white, 65%)',
90 | 'text-selection-bg': token.colorPrimary,
91 | 'font-variant-base': 'tabular-nums',
92 | 'font-feature-settings-base': 'tnum',
93 | 'font-size-base': token.fontSize,
94 | 'font-size-lg': token.fontSizeLG,
95 | 'font-size-sm': token.fontSizeSM,
96 | 'heading-1-size': token.fontSizeHeading1,
97 | 'heading-2-size': token.fontSizeHeading2,
98 | 'heading-3-size': token.fontSizeHeading3,
99 | 'heading-4-size': token.fontSizeHeading4,
100 | 'heading-5-size': token.fontSizeHeading5,
101 |
102 | // https://github.com/ant-design/ant-design/issues/20210
103 | 'line-height-base': token.lineHeight,
104 | 'border-radius-base': token.borderRadius,
105 | 'border-radius-sm': token.borderRadiusSM,
106 |
107 | // control border
108 | 'control-border-radius': token.borderRadius,
109 |
110 | // arrow border
111 | 'arrow-border-radius': token.borderRadiusSM, // 2px;
112 |
113 | // vertical paddings
114 | 'padding-lg': token.paddingLG,
115 | 'padding-md': token.padding,
116 | 'padding-sm': token.paddingSM,
117 | 'padding-xs': token.paddingXS,
118 | 'padding-xss': token.paddingXXS,
119 |
120 | // vertical padding for all form controls
121 | 'control-padding-horizontal': token.paddingSM, //@padding-sm;
122 | 'control-padding-horizontal-sm': token.paddingXS, // @padding-xs;
123 |
124 | // vertical margins
125 | 'margin-lg': token.marginLG,
126 | 'margin-md': token.margin,
127 | 'margin-sm': token.marginSM,
128 | 'margin-xs': token.marginXS,
129 | 'margin-xss': token.marginXXS,
130 |
131 | // height rules
132 | 'height-base': token.controlHeight,
133 | 'height-lg': token.controlHeightLG,
134 | 'height-sm': token.controlHeightSM,
135 |
136 | // The background colors for active and hover states for things like
137 | // list items or table cells.
138 | 'item-active-bg': token.controlItemBgActive,
139 | 'item-hover-bg': token.controlItemBgHover,
140 |
141 | // ICONFONT
142 | 'iconfont-css-prefix': 'anticon',
143 |
144 | // LINK
145 | 'link-color': token.colorLink,
146 | 'link-hover-color': token.colorLinkHover,
147 | 'link-active-color': token.colorLinkActive,
148 | 'link-decoration': 'none',
149 | 'link-hover-decoration': 'none',
150 | 'link-focus-decoration': 'none',
151 | 'link-focus-outline': 0,
152 |
153 | // Animation
154 | 'ease-base-out': token.motionEaseOut,
155 | 'ease-base-in': 'cubic-bezier(0.9, 0, 0.3, 0.7)',
156 | 'ease-out': token.motionEaseOut,
157 | 'ease-in': 'cubic-bezier(0.55, 0.055, 0.675, 0.19)',
158 | 'ease-in-out': token.motionEaseInOut,
159 | 'ease-out-back': token.motionEaseOutBack,
160 | 'ease-in-back': 'cubic-bezier(0.71, -0.46, 0.88, 0.6)',
161 | 'ease-in-out-back': 'cubic-bezier(0.71, -0.46, 0.29, 1.46)',
162 | 'ease-out-circ': token.motionEaseOutCirc,
163 | 'ease-in-circ': 'cubic-bezier(0.6, 0.04, 0.98, 0.34)',
164 | 'ease-in-out-circ': token.motionEaseInOutCirc,
165 | 'ease-out-quint': token.motionEaseOutQuint,
166 | 'ease-in-quint': token.motionEaseInQuint,
167 | 'ease-in-out-quint': 'cubic-bezier(0.86, 0, 0.07, 1)',
168 |
169 | // Border color
170 | 'border-color-base': token.colorBorder,
171 | 'border-color-split': token.colorSplit,
172 | 'border-color-inverse': token.colorWhite,
173 | 'border-width-base': token.lineWidth,
174 | 'border-style-base': 'solid',
175 |
176 | // Outline
177 | 'outline-blur-size': 0,
178 | 'outline-width': token.controlOutlineWidth,
179 | 'outline-color': token.controlOutline,
180 | 'outline-fade': '20%',
181 | 'background-color-light': 'hsv(0, 0, 98%)', // background of header and selected item
182 | 'background-color-base': 'hsv(0, 0, 96%)', // Default grey background color
183 |
184 | // Disabled states
185 | 'disabled-color': token.colorTextDisabled,
186 | 'disabled-bg': token.colorBgContainerDisabled,
187 | 'disabled-active-bg': token.colorBgContainerDisabled, // tint(@black, 90%);
188 | 'disabled-color-dark': 'fade(#fff, 35%)',
189 |
190 | // Shadow
191 | 'shadow-color': 'rgba(0, 0, 0, 0.15)',
192 | 'shadow-color-inverse': token.colorBgContainer,
193 | 'box-shadow-base': token.boxShadow,
194 | 'shadow-1-up': (token as any).boxShadowDrawerUp,
195 | 'shadow-1-down': (token as any).boxShadowDrawerDown,
196 | 'shadow-1-left': (token as any).boxShadowDrawerLeft,
197 | 'shadow-1-right': (token as any).boxShadowDrawerRight,
198 | 'shadow-2': token.boxShadowSecondary,
199 |
200 | // ==========================================================================
201 | // == Components ==
202 | // ==========================================================================
203 | // Buttons
204 | 'btn-font-weight': '400',
205 | 'btn-border-radius-base': '@border-radius-base',
206 | 'btn-border-radius-sm': '@border-radius-base',
207 | 'btn-border-width': '@border-width-base',
208 | 'btn-border-style': '@border-style-base',
209 | 'btn-shadow': '0 2px 0 rgba(0, 0, 0, 0.015)',
210 | 'btn-primary-shadow': '0 2px 0 rgba(0, 0, 0, 0.045)',
211 | 'btn-text-shadow': '0 -1px 0 rgba(0, 0, 0, 0.12)',
212 |
213 | 'btn-primary-color': '#fff',
214 | 'btn-primary-bg': '@primary-color',
215 |
216 | 'btn-default-color': '@text-color',
217 | 'btn-default-bg': '@component-background',
218 | 'btn-default-border': '@border-color-base',
219 |
220 | 'btn-danger-color': '#fff',
221 | 'btn-danger-bg': '@error-color',
222 | 'btn-danger-border': '@error-color',
223 |
224 | 'btn-disable-color': '@disabled-color',
225 | 'btn-disable-bg': '@disabled-bg',
226 | 'btn-disable-border': '@border-color-base',
227 |
228 | 'btn-default-ghost-color': '@component-background',
229 | 'btn-default-ghost-bg': 'transparent',
230 | 'btn-default-ghost-border': '@component-background',
231 |
232 | 'btn-font-size-lg': '@font-size-lg',
233 | 'btn-font-size-sm': '@font-size-base',
234 | 'btn-padding-horizontal-base': '@padding-md - 1px',
235 | 'btn-padding-horizontal-lg': '@btn-padding-horizontal-base',
236 | 'btn-padding-horizontal-sm': '@padding-xs - 1px',
237 |
238 | 'btn-height-base': '@height-base',
239 | 'btn-height-lg': '@height-lg',
240 | 'btn-height-sm': '@height-sm',
241 |
242 | 'btn-line-height': '@line-height-base',
243 |
244 | 'btn-circle-size': '@btn-height-base',
245 | 'btn-circle-size-lg': '@btn-height-lg',
246 | 'btn-circle-size-sm': '@btn-height-sm',
247 |
248 | 'btn-square-size': '@btn-height-base',
249 | 'btn-square-size-lg': '@btn-height-lg',
250 | 'btn-square-size-sm': '@btn-height-sm',
251 | 'btn-square-only-icon-size': '@font-size-base + 2px',
252 | 'btn-square-only-icon-size-sm': '@font-size-base',
253 | 'btn-square-only-icon-size-lg': '@btn-font-size-lg + 2px',
254 |
255 | 'btn-group-border': '@primary-5',
256 |
257 | 'btn-link-hover-bg': 'transparent',
258 | 'btn-text-hover-bg': 'rgba(0, 0, 0, 0.018)',
259 |
260 | // Checkbox
261 | 'checkbox-size': '16px',
262 | 'checkbox-color': '@primary-color',
263 | 'checkbox-check-color': '#fff',
264 | 'checkbox-check-bg': '@checkbox-check-color',
265 | 'checkbox-border-width': '@border-width-base',
266 | 'checkbox-border-radius': '@border-radius-base',
267 | 'checkbox-group-item-margin-right': '8px',
268 |
269 | // Descriptions
270 | 'descriptions-bg': '#fafafa',
271 | 'descriptions-title-margin-bottom': '20px',
272 | 'descriptions-default-padding': '@padding-md @padding-lg',
273 | 'descriptions-middle-padding': '@padding-sm @padding-lg',
274 | 'descriptions-small-padding': '@padding-xs @padding-md',
275 | 'descriptions-item-padding-bottom': '@padding-md',
276 | 'descriptions-item-trailing-colon': 'true',
277 | 'descriptions-item-label-colon-margin-right': '8px',
278 | 'descriptions-item-label-colon-margin-left': '2px',
279 | 'descriptions-extra-color': '@text-color',
280 |
281 | // Divider
282 | 'divider-text-padding': '1em',
283 | 'divider-orientation-margin': '5%',
284 | 'divider-color': 'rgba(0, 0, 0, 6%)',
285 | 'divider-vertical-gutter': '8px',
286 |
287 | // Dropdown
288 | 'dropdown-selected-color': '@primary-color',
289 | 'dropdown-menu-submenu-disabled-bg': '@component-background',
290 | 'dropdown-selected-bg': '@item-active-bg',
291 |
292 | // Empty
293 | 'empty-font-size': '@font-size-base',
294 |
295 | // Radio
296 | 'radio-size': '16px',
297 | 'radio-top': '0.2em',
298 | 'radio-border-width': '1px',
299 | 'radio-dot-size': '@radio-size - 8px',
300 | 'radio-dot-color': '@primary-color',
301 | 'radio-dot-disabled-color': 'fade(@black, 20%)',
302 | 'radio-solid-checked-color': '@component-background',
303 |
304 | // Radio buttons
305 | 'radio-button-bg': '@btn-default-bg',
306 | 'radio-button-checked-bg': '@btn-default-bg',
307 | 'radio-button-color': '@btn-default-color',
308 | 'radio-button-hover-color': '@primary-5',
309 | 'radio-button-active-color': '@primary-7',
310 | 'radio-button-padding-horizontal': '@padding-md - 1px',
311 | 'radio-disabled-button-checked-bg': '@disabled-active-bg',
312 | 'radio-disabled-button-checked-color': '@disabled-color',
313 | 'radio-wrapper-margin-right': '8px',
314 |
315 | // Media queries breakpoints
316 | // @screen-xs and @screen-xs-min is not used in Grid
317 | // smallest break point is @screen-md
318 | 'screen-xs': '480px',
319 | 'screen-xs-min': '@screen-xs',
320 | // 👆 Extra small screen / phone
321 |
322 | // 👇 Small screen / tablet
323 | 'screen-sm': '576px',
324 | 'screen-sm-min': '@screen-sm',
325 |
326 | // Medium screen / desktop
327 | 'screen-md': '768px',
328 | 'screen-md-min': '@screen-md',
329 |
330 | // Large screen / wide desktop
331 | 'screen-lg': '992px',
332 | 'screen-lg-min': '@screen-lg',
333 |
334 | // Extra large screen / full hd
335 | 'screen-xl': '1200px',
336 | 'screen-xl-min': '@screen-xl',
337 |
338 | // Extra extra large screen / large desktop
339 | 'screen-xxl': '1600px',
340 | 'screen-xxl-min': '@screen-xxl',
341 |
342 | // provide a maximum
343 | 'screen-xs-max': '(@screen-sm-min - 1px)',
344 | 'screen-sm-max': '(@screen-md-min - 1px)',
345 | 'screen-md-max': '(@screen-lg-min - 1px)',
346 | 'screen-lg-max': '(@screen-xl-min - 1px)',
347 | 'screen-xl-max': '(@screen-xxl-min - 1px)',
348 |
349 | // Grid system
350 | 'grid-columns': '24',
351 |
352 | // Layout
353 | 'layout-body-background': '#f0f2f5',
354 | 'layout-header-background': '#001529',
355 | 'layout-header-height': '64px',
356 | 'layout-header-padding': '0 50px',
357 | 'layout-header-color': '@text-color',
358 | 'layout-footer-padding': '24px 50px',
359 | 'layout-footer-background': '@layout-body-background',
360 | 'layout-sider-background': '@layout-header-background',
361 | 'layout-trigger-height': '48px',
362 | 'layout-trigger-background': '#002140',
363 | 'layout-trigger-color': '#fff',
364 | 'layout-zero-trigger-width': '36px',
365 | 'layout-zero-trigger-height': '42px',
366 | // Layout light theme
367 | 'layout-sider-background-light': '#fff',
368 | 'layout-trigger-background-light': '#fff',
369 | 'layout-trigger-color-light': '@text-color',
370 |
371 | // z-index list, order by `z-index`
372 | 'zindex-badge': 'auto',
373 | 'zindex-table-fixed': '2',
374 | 'zindex-affix': '10',
375 | 'zindex-back-top': '10',
376 | 'zindex-picker-panel': '10',
377 | 'zindex-popup-close': '10',
378 | 'zindex-modal': '1000',
379 | 'zindex-modal-mask': '1000',
380 | 'zindex-message': '1010',
381 | 'zindex-notification': '1010',
382 | 'zindex-popover': '1030',
383 | 'zindex-dropdown': '1050',
384 | 'zindex-picker': '1050',
385 | 'zindex-popoconfirm': '1060',
386 | 'zindex-tooltip': '1070',
387 | 'zindex-image': '1080',
388 |
389 | // Animation
390 | 'animation-duration-slow': '0.3s', // Modal
391 | 'animation-duration-base': '0.2s',
392 | 'animation-duration-fast': '0.1s', // Tooltip
393 |
394 | //CollapsePanel
395 | 'collapse-panel-border-radius': '@border-radius-base',
396 |
397 | //Dropdown
398 | 'dropdown-menu-bg': '@component-background',
399 | 'dropdown-vertical-padding': '5px',
400 | 'dropdown-edge-child-vertical-padding': '4px',
401 | 'dropdown-font-size': '@font-size-base',
402 | 'dropdown-line-height': '22px',
403 |
404 | // Form
405 | // ---
406 | 'label-required-color': '@highlight-color',
407 | 'label-color': '@heading-color',
408 | 'form-warning-input-bg': '@input-bg',
409 | 'form-item-margin-bottom': '24px',
410 | 'form-item-trailing-colon': 'true',
411 | 'form-vertical-label-padding': '0 0 8px',
412 | 'form-vertical-label-margin': '0',
413 | 'form-item-label-font-size': '@font-size-base',
414 | 'form-item-label-height': '@input-height-base',
415 | 'form-item-label-colon-margin-right': '8px',
416 | 'form-item-label-colon-margin-left': '2px',
417 | 'form-error-input-bg': '@input-bg',
418 |
419 | // Input
420 | // ---
421 | 'input-height-base': '@height-base',
422 | 'input-height-lg': '@height-lg',
423 | 'input-height-sm': '@height-sm',
424 | 'input-padding-horizontal': '@control-padding-horizontal - 1px',
425 | 'input-padding-horizontal-base': '@input-padding-horizontal',
426 | 'input-padding-horizontal-sm': '@control-padding-horizontal-sm - 1px',
427 | 'input-padding-horizontal-lg': '@input-padding-horizontal',
428 | 'input-padding-vertical-base': `max(
429 | (round(((@input-height-base - @font-size-base * @line-height-base) / 2) * 10) / 10) -
430 | @border-width-base,
431 | 3px
432 | )`,
433 | 'input-padding-vertical-sm': `max(
434 | (round(((@input-height-sm - @font-size-base * @line-height-base) / 2) * 10) / 10) -
435 | @border-width-base,
436 | 0
437 | )`,
438 | 'input-padding-vertical-lg': `(
439 | ceil(((@input-height-lg - @font-size-lg * @line-height-base) / 2) * 10) / 10
440 | ) - @border-width-base`,
441 | 'input-placeholder-color': 'hsv(0, 0, 75%)',
442 | 'input-color': '@text-color',
443 | 'input-icon-color': '@input-color',
444 | 'input-border-color': '@border-color-base',
445 | 'input-bg': '@component-background',
446 | 'input-number-hover-border-color': '@input-hover-border-color',
447 | 'input-number-handler-active-bg': '#f4f4f4',
448 | 'input-number-handler-hover-bg': '@primary-5',
449 | 'input-number-handler-bg': '@component-background',
450 | 'input-number-handler-border-color': '@border-color-base',
451 | 'input-addon-bg': '@background-color-light',
452 | 'input-hover-border-color': '@primary-5',
453 | 'input-disabled-bg': '@disabled-bg',
454 | 'input-outline-offset': '0 0',
455 | 'input-icon-hover-color': 'fade(@black, 85%)',
456 | 'input-disabled-color': '@disabled-color',
457 |
458 | // Mentions
459 | // ---
460 | 'mentions-dropdown-bg': '@component-background',
461 | 'mentions-dropdown-menu-item-hover-bg': '@mentions-dropdown-bg',
462 |
463 | // Select
464 | // ---
465 | 'select-border-color': '@border-color-base',
466 | 'select-item-selected-color': '@text-color',
467 | 'select-item-selected-font-weight': '600',
468 | 'select-dropdown-bg': '@component-background',
469 | 'select-item-selected-bg': '@primary-1',
470 | 'select-item-active-bg': '@item-hover-bg',
471 | 'select-dropdown-vertical-padding': '@dropdown-vertical-padding',
472 | 'select-dropdown-font-size': '@dropdown-font-size',
473 | 'select-dropdown-line-height': '@dropdown-line-height',
474 | 'select-dropdown-height': '32px',
475 | 'select-background': '@component-background',
476 | 'select-clear-background': '@select-background',
477 | 'select-selection-item-bg': '@background-color-base',
478 | 'select-selection-item-border-color': '@border-color-split',
479 | 'select-single-item-height-lg': '40px',
480 | 'select-multiple-item-height': '@input-height-base - @input-padding-vertical-base * 2', // Normal 24px
481 | 'select-multiple-item-height-lg': '32px',
482 | 'select-multiple-item-spacing-half': 'ceil((@input-padding-vertical-base / 2))',
483 | 'select-multiple-disabled-background': '@input-disabled-bg',
484 | 'select-multiple-item-disabled-color': '#bfbfbf',
485 | 'select-multiple-item-disabled-border-color': '@select-border-color',
486 |
487 | // Cascader
488 | // ---
489 | 'cascader-bg': '@component-background',
490 | 'cascader-item-selected-bg': '@primary-1',
491 | 'cascader-menu-bg': '@component-background',
492 | 'cascader-menu-border-color-split': '@border-color-split',
493 |
494 | // Cascader
495 | // ----
496 | 'cascader-dropdown-vertical-padding': '@dropdown-vertical-padding',
497 | 'cascader-dropdown-edge-child-vertical-padding': '@dropdown-edge-child-vertical-padding',
498 | 'cascader-dropdown-font-size': '@dropdown-font-size',
499 | 'cascader-dropdown-line-height': '@dropdown-line-height',
500 |
501 | // Anchor
502 | // ---
503 | 'anchor-bg': 'transparent',
504 | 'anchor-border-color': '@border-color-split',
505 | 'anchor-link-top': '4px',
506 | 'anchor-link-left': '16px',
507 | 'anchor-link-padding': '@anchor-link-top 0 @anchor-link-top @anchor-link-left',
508 |
509 | // Tooltip
510 | // ---
511 | // Tooltip max width
512 | 'tooltip-max-width': '250px',
513 | // Tooltip text color
514 | 'tooltip-color': '#fff',
515 | // Tooltip background color
516 | 'tooltip-bg': 'rgba(0, 0, 0, 0.75)',
517 | // Tooltip arrow width
518 | 'tooltip-arrow-width': '8px * sqrt(2)',
519 | // Tooltip distance with trigger
520 | 'tooltip-distance': '@tooltip-arrow-width - 1px + 4px',
521 | // Tooltip arrow color
522 | 'tooltip-arrow-color': '@tooltip-bg',
523 | 'tooltip-border-radius': '@border-radius-base',
524 |
525 | // Popover
526 | // ---
527 | // Popover body background color
528 | 'popover-bg': '@component-background',
529 | // Popover text color
530 | 'popover-color': '@text-color',
531 | // Popover maximum width
532 | 'popover-min-width': '177px',
533 | 'popover-min-height': '32px',
534 | // Popover arrow width
535 | 'popover-arrow-width': '@tooltip-arrow-width',
536 | // Popover arrow color
537 | 'popover-arrow-color': '@popover-bg',
538 | // Popover outer arrow width
539 | // Popover outer arrow color
540 | 'popover-arrow-outer-color': '@popover-bg',
541 | // Popover distance with trigger
542 | 'popover-distance': '@popover-arrow-width + 4px',
543 | 'popover-padding-horizontal': '@padding-md',
544 |
545 | // Modal
546 | // --
547 | 'modal-header-padding-vertical': '@padding-md',
548 | 'modal-header-padding-horizontal': '@padding-lg',
549 | 'modal-body-padding': '@padding-lg',
550 | 'modal-header-bg': '@component-background',
551 | 'modal-header-padding': '@modal-header-padding-vertical @modal-header-padding-horizontal',
552 | 'modal-header-border-width': '@border-width-base',
553 | 'modal-header-border-style': '@border-style-base',
554 | 'modal-header-title-line-height': '22px',
555 | 'modal-header-title-font-size': '@font-size-lg',
556 | 'modal-header-border-color-split': '@border-color-split',
557 | 'modal-header-close-size':
558 | '@modal-header-title-line-height + 2 * @modal-header-padding-vertical',
559 | 'modal-content-bg': '@component-background',
560 | 'modal-heading-color': '@heading-color',
561 | 'modal-close-color': '@text-color-secondary',
562 | 'modal-footer-bg': 'transparent',
563 | 'modal-footer-border-color-split': '@border-color-split',
564 | 'modal-footer-border-style': '@border-style-base',
565 | 'modal-footer-padding-vertical': '10px',
566 | 'modal-footer-padding-horizontal': '16px',
567 | 'modal-footer-border-width': '@border-width-base',
568 | 'modal-mask-bg': 'fade(@black, 45%)',
569 | 'modal-confirm-body-padding': '32px 32px 24px',
570 | 'modal-confirm-title-font-size': '@font-size-lg',
571 | 'modal-border-radius': '@border-radius-base',
572 |
573 | // Progress
574 | // --
575 | 'progress-default-color': '@processing-color',
576 | 'progress-remaining-color': '@background-color-base',
577 | 'progress-info-text-color': '@progress-text-color',
578 | 'progress-radius': '100px',
579 | 'progress-steps-item-bg': '#f3f3f3',
580 | 'progress-text-font-size': '1em',
581 | 'progress-text-color': '@text-color', // This is for circle text color, should be renamed better
582 | 'progress-circle-text-font-size': '1em',
583 | // Menu
584 | // ---
585 | 'menu-inline-toplevel-item-height': '40px',
586 | 'menu-item-height': '40px',
587 | 'menu-item-group-height': '@line-height-base',
588 | 'menu-collapsed-width': '80px',
589 | 'menu-bg': '@component-background',
590 | 'menu-popup-bg': '@component-background',
591 | 'menu-item-color': '@text-color',
592 | 'menu-inline-submenu-bg': '@background-color-light',
593 | 'menu-highlight-color': '@primary-color',
594 | 'menu-highlight-danger-color': '@error-color',
595 | 'menu-item-active-bg': '@primary-1',
596 | 'menu-item-active-danger-bg': '@red-1',
597 | 'menu-item-active-border-width': '3px',
598 | 'menu-item-group-title-color': '@text-color-secondary',
599 | 'menu-item-vertical-margin': '4px',
600 | 'menu-item-font-size': '@font-size-base',
601 | 'menu-item-boundary-margin': '8px',
602 | 'menu-item-padding-horizontal': '20px',
603 | 'menu-item-padding': '0 @menu-item-padding-horizontal',
604 | 'menu-horizontal-line-height': '46px',
605 | 'menu-icon-margin-right': '10px',
606 | 'menu-icon-size': '@menu-item-font-size',
607 | 'menu-icon-size-lg': '@font-size-lg',
608 | 'menu-item-group-title-font-size': '@menu-item-font-size',
609 |
610 | // dark theme
611 | 'menu-dark-color': '@text-color-secondary-dark',
612 | 'menu-dark-danger-color': '@error-color',
613 | 'menu-dark-bg': '@layout-header-background',
614 | 'menu-dark-arrow-color': '#fff',
615 | 'menu-dark-inline-submenu-bg': '#000c17',
616 | 'menu-dark-highlight-color': '#fff',
617 | 'menu-dark-item-active-bg': '@primary-color',
618 | 'menu-dark-item-active-danger-bg': '@error-color',
619 | 'menu-dark-selected-item-icon-color': '@white',
620 | 'menu-dark-selected-item-text-color': '@white',
621 | 'menu-dark-item-hover-bg': 'transparent',
622 | // Spin
623 | // ---
624 | 'spin-dot-size-sm': '14px',
625 | 'spin-dot-size': '20px',
626 | 'spin-dot-size-lg': '32px',
627 |
628 | // Table
629 | // --
630 | 'table-bg': '@component-background',
631 | 'table-header-bg': '@background-color-light',
632 | 'table-header-color': '@heading-color',
633 | 'table-header-sort-bg': '@background-color-base',
634 | 'table-body-sort-bg': '#fafafa',
635 | 'table-row-hover-bg': '@background-color-light',
636 | 'table-selected-row-color': 'inherit',
637 | 'table-selected-row-bg': '@primary-1',
638 | 'table-body-selected-sort-bg': '@table-selected-row-bg',
639 | 'table-selected-row-hover-bg': 'darken(@table-selected-row-bg, 2%)',
640 | 'table-expanded-row-bg': '#fbfbfb',
641 | 'table-padding-vertical': '16px',
642 | 'table-padding-horizontal': '16px',
643 | 'table-padding-vertical-md': '(@table-padding-vertical * 3 / 4)',
644 | 'table-padding-horizontal-md': '(@table-padding-horizontal / 2)',
645 | 'table-padding-vertical-sm': '(@table-padding-vertical / 2)',
646 | 'table-padding-horizontal-sm': '(@table-padding-horizontal / 2)',
647 | 'table-border-color': '@border-color-split',
648 | 'table-border-radius-base': '@border-radius-base',
649 | 'table-footer-bg': '@background-color-light',
650 | 'table-footer-color': '@heading-color',
651 | 'table-header-bg-sm': '@table-header-bg',
652 | 'table-font-size': '@font-size-base',
653 | 'table-font-size-md': '@table-font-size',
654 | 'table-font-size-sm': '@table-font-size',
655 | 'table-header-cell-split-color': 'rgba(0, 0, 0, 0.06)',
656 | // Sorter
657 | // Legacy: `table-header-sort-active-bg` is used for hover not real active
658 | 'table-header-sort-active-bg': 'rgba(0, 0, 0, 0.04)',
659 | 'table-fixed-header-sort-active-bg': 'hsv(0, 0, 96%)',
660 |
661 | // Filter
662 | 'table-header-filter-active-bg': 'rgba(0, 0, 0, 0.04)',
663 | 'table-filter-btns-bg': 'inherit',
664 | 'table-filter-dropdown-bg': '@component-background',
665 | 'table-expand-icon-bg': '@component-background',
666 | 'table-selection-column-width': '32px',
667 | // Sticky
668 | 'table-sticky-scroll-bar-bg': 'fade(#000, 35%)',
669 | 'table-sticky-scroll-bar-radius': '4px',
670 |
671 | // Tag
672 | // --
673 | 'tag-border-radius': '@border-radius-base',
674 | 'tag-default-bg': '@background-color-light',
675 | 'tag-default-color': '@text-color',
676 | 'tag-font-size': '@font-size-sm',
677 | 'tag-line-height': '20px',
678 |
679 | // TimePicker
680 | // ---
681 | 'picker-bg': '@component-background',
682 | 'picker-basic-cell-hover-color': '@item-hover-bg',
683 | 'picker-basic-cell-active-with-range-color': '@primary-1',
684 | 'picker-basic-cell-hover-with-range-color': 'lighten(@primary-color, 35%)',
685 | 'picker-basic-cell-disabled-bg': 'rgba(0, 0, 0, 0.04)',
686 | 'picker-border-color': '@border-color-split',
687 | 'picker-date-hover-range-border-color': 'lighten(@primary-color, 20%)',
688 | 'picker-date-hover-range-color': '@picker-basic-cell-hover-with-range-color',
689 | 'picker-time-panel-column-width': '56px',
690 | 'picker-time-panel-column-height': '224px',
691 | 'picker-time-panel-cell-height': '28px',
692 | 'picker-panel-cell-height': '24px',
693 | 'picker-panel-cell-width': '36px',
694 | 'picker-text-height': '40px',
695 | 'picker-panel-without-time-cell-height': '66px',
696 |
697 | // Calendar
698 | // ---
699 | 'calendar-bg': '@component-background',
700 | 'calendar-input-bg': '@input-bg',
701 | 'calendar-border-color': '@border-color-inverse',
702 | 'calendar-item-active-bg': '@item-active-bg',
703 | 'calendar-column-active-bg': 'fade(@calendar-item-active-bg, 20%)',
704 | 'calendar-full-bg': '@calendar-bg',
705 | 'calendar-full-panel-bg': '@calendar-full-bg',
706 |
707 | // Carousel
708 | // ---
709 | 'carousel-dot-width': '16px',
710 | 'carousel-dot-height': '3px',
711 | 'carousel-dot-active-width': '24px',
712 |
713 | // Badge
714 | // ---
715 | 'badge-height': '20px',
716 | 'badge-height-sm': '14px',
717 | 'badge-dot-size': '6px',
718 | 'badge-font-size': '@font-size-sm',
719 | 'badge-font-size-sm': '@font-size-sm',
720 | 'badge-font-weight': 'normal',
721 | 'badge-status-size': '6px',
722 | 'badge-text-color': '@component-background',
723 | 'badge-color': '@highlight-color',
724 |
725 | // Rate
726 | // ---
727 | 'rate-star-color': '@yellow-6',
728 | 'rate-star-bg': '@border-color-split',
729 | 'rate-star-size': '20px',
730 | 'rate-star-hover-scale': 'scale(1.1)',
731 |
732 | // Card
733 | // ---
734 | 'card-head-color': '@heading-color',
735 | 'card-head-background': 'transparent',
736 | 'card-head-font-size': '@font-size-lg',
737 | 'card-head-font-size-sm': '@font-size-base',
738 | 'card-head-padding': '16px',
739 | 'card-head-padding-sm': '(@card-head-padding / 2)',
740 | 'card-head-height': '48px',
741 | 'card-head-height-sm': '36px',
742 | 'card-inner-head-padding': '12px',
743 | 'card-padding-base': '24px',
744 | 'card-padding-base-sm': '(@card-padding-base / 2)',
745 | 'card-actions-background': '@component-background',
746 | 'card-actions-li-margin': '12px 0',
747 | 'card-skeleton-bg': '#cfd8dc',
748 | 'card-background': '@component-background',
749 | 'card-shadow': `0 1px 2px -2px rgba(0, 0, 0, 0.16), 0 3px 6px 0 rgba(0, 0, 0, 0.12),
750 | 0 5px 12px 4px rgba(0, 0, 0, 0.09)`,
751 | 'card-radius': '@border-radius-base',
752 | 'card-head-tabs-margin-bottom': '-17px',
753 | 'card-head-extra-color': '@text-color',
754 |
755 | // Comment
756 | // ---
757 | 'comment-bg': 'inherit',
758 | 'comment-padding-base': '@padding-md 0',
759 | 'comment-nest-indent': '44px',
760 | 'comment-font-size-base': '@font-size-base',
761 | 'comment-font-size-sm': '@font-size-sm',
762 | 'comment-author-name-color': '@text-color-secondary',
763 | 'comment-author-time-color': '#ccc',
764 | 'comment-action-color': '@text-color-secondary',
765 | 'comment-action-hover-color': '#595959',
766 | 'comment-actions-margin-bottom': 'inherit',
767 | 'comment-actions-margin-top': '@margin-sm',
768 | 'comment-content-detail-p-margin-bottom': 'inherit',
769 |
770 | // Tabs
771 | // ---
772 | 'tabs-card-head-background': '@background-color-light',
773 | 'tabs-card-height': '40px',
774 | 'tabs-card-active-color': '@primary-color',
775 | 'tabs-card-horizontal-padding': `(
776 | (@tabs-card-height - floor(@font-size-base * @line-height-base)) / 2
777 | ) - @border-width-base @padding-md`,
778 | 'tabs-card-horizontal-padding-sm': '6px @padding-md',
779 | 'tabs-card-horizontal-padding-lg': '7px @padding-md 6px',
780 | 'tabs-title-font-size': '@font-size-base',
781 | 'tabs-title-font-size-lg': '@font-size-lg',
782 | 'tabs-title-font-size-sm': '@font-size-base',
783 | 'tabs-ink-bar-color': '@primary-color',
784 | 'tabs-bar-margin': '0 0 @margin-md 0',
785 | 'tabs-horizontal-gutter': '32px',
786 | 'tabs-horizontal-margin': '0 0 0 @tabs-horizontal-gutter',
787 | 'tabs-horizontal-margin-rtl': '0 0 0 32px',
788 | 'tabs-horizontal-padding': '@padding-sm 0',
789 | 'tabs-horizontal-padding-lg': '@padding-md 0',
790 | 'tabs-horizontal-padding-sm': '@padding-xs 0',
791 | 'tabs-vertical-padding': '@padding-xs @padding-lg',
792 | 'tabs-vertical-margin': '@margin-md 0 0 0',
793 | 'tabs-scrolling-size': '32px',
794 | 'tabs-highlight-color': '@primary-color',
795 | 'tabs-hover-color': '@primary-5',
796 | 'tabs-active-color': '@primary-7',
797 | 'tabs-card-gutter': '2px',
798 | 'tabs-card-tab-active-border-top': '2px solid transparent',
799 |
800 | // BackTop
801 | // ---
802 | 'back-top-color': '#fff',
803 | 'back-top-bg': '@text-color-secondary',
804 | 'back-top-hover-bg': '@text-color',
805 |
806 | // Avatar
807 | // ---
808 | 'avatar-size-base': '32px',
809 | 'avatar-size-lg': '40px',
810 | 'avatar-size-sm': '24px',
811 | 'avatar-font-size-base': '18px',
812 | 'avatar-font-size-lg': '24px',
813 | 'avatar-font-size-sm': '14px',
814 | 'avatar-bg': '#ccc',
815 | 'avatar-color': '#fff',
816 | 'avatar-border-radius': '@border-radius-base',
817 | 'avatar-group-overlapping': '-8px',
818 | 'avatar-group-space': '3px',
819 | 'avatar-group-border-color': '#fff',
820 |
821 | // Switch
822 | // ---
823 | 'switch-height': '22px',
824 | 'switch-sm-height': '16px',
825 | 'switch-min-width': '44px',
826 | 'switch-sm-min-width': '28px',
827 | 'switch-disabled-opacity': '0.4',
828 | 'switch-color': '@primary-color',
829 | 'switch-bg': '@component-background',
830 | 'switch-shadow-color': 'fade(#00230b, 20%)',
831 | 'switch-padding': '2px',
832 | 'switch-inner-margin-min': 'ceil(@switch-height * 0.3)',
833 | 'switch-inner-margin-max': 'ceil(@switch-height * 1.1)',
834 | 'switch-sm-inner-margin-min': 'ceil(@switch-sm-height * 0.3)',
835 | 'switch-sm-inner-margin-max': 'ceil(@switch-sm-height * 1.1)',
836 |
837 | // Pagination
838 | // ---
839 | 'pagination-item-bg': '@component-background',
840 | 'pagination-item-size': '@height-base',
841 | 'pagination-item-size-sm': '24px',
842 | 'pagination-font-family': '@font-family',
843 | 'pagination-font-weight-active': '500',
844 | 'pagination-item-bg-active': '@component-background',
845 | 'pagination-item-link-bg': '@component-background',
846 | 'pagination-item-disabled-color-active': '@disabled-color',
847 | 'pagination-item-disabled-bg-active': '@disabled-active-bg',
848 | 'pagination-item-input-bg': '@component-background',
849 | 'pagination-mini-options-size-changer-top': '0px',
850 |
851 | // PageHeader
852 | // ---
853 | 'page-header-padding': '@padding-lg',
854 | 'page-header-padding-vertical': '@padding-md',
855 | 'page-header-padding-breadcrumb': '@padding-sm',
856 | 'page-header-content-padding-vertical': '@padding-sm',
857 | 'page-header-back-color': '#000',
858 | 'page-header-ghost-bg': 'inherit',
859 | 'page-header-heading-title': '@heading-4-size',
860 | 'page-header-heading-sub-title': '14px',
861 | 'page-header-tabs-tab-font-size': '16px',
862 |
863 | // Breadcrumb
864 | // ---
865 | 'breadcrumb-base-color': '@text-color-secondary',
866 | 'breadcrumb-last-item-color': '@text-color',
867 | 'breadcrumb-font-size': '@font-size-base',
868 | 'breadcrumb-icon-font-size': '@font-size-base',
869 | 'breadcrumb-link-color': '@text-color-secondary',
870 | 'breadcrumb-link-color-hover': '@text-color',
871 | 'breadcrumb-separator-color': '@text-color-secondary',
872 | 'breadcrumb-separator-margin': '0 @padding-xs',
873 |
874 | // Slider
875 | // ---
876 | 'slider-margin': '10px 6px 10px',
877 | 'slider-rail-background-color': '@background-color-base',
878 | 'slider-rail-background-color-hover': '#e1e1e1',
879 | 'slider-track-background-color': '@primary-3',
880 | 'slider-track-background-color-hover': '@primary-4',
881 | 'slider-handle-border-width': '2px',
882 | 'slider-handle-background-color': '@component-background',
883 | 'slider-handle-color': '@primary-3',
884 | 'slider-handle-color-hover': '@primary-4',
885 | 'slider-handle-color-focus': 'tint(@primary-color, 20%)',
886 | 'slider-handle-color-focus-shadow': 'fade(@primary-color, 12%)',
887 | 'slider-handle-color-tooltip-open': '@primary-color',
888 | 'slider-handle-size': '14px',
889 | 'slider-handle-margin-top': '-5px',
890 | 'slider-handle-margin-left': '-5px',
891 | 'slider-handle-shadow': '0',
892 | 'slider-dot-border-color': '@border-color-split',
893 | 'slider-dot-border-color-active': 'tint(@primary-color, 50%)',
894 | 'slider-disabled-color': '@disabled-color',
895 | 'slider-disabled-background-color': '@component-background',
896 |
897 | // Tree
898 | // ---
899 | 'tree-bg': '@component-background',
900 | 'tree-title-height': '24px',
901 | 'tree-child-padding': '18px',
902 | 'tree-directory-selected-color': '#fff',
903 | 'tree-directory-selected-bg': '@primary-color',
904 | 'tree-node-hover-bg': '@item-hover-bg',
905 | 'tree-node-selected-bg': '@primary-2',
906 |
907 | // Collapse
908 | // ---
909 | 'collapse-header-padding': '@padding-sm @padding-md',
910 | 'collapse-header-padding-extra': '40px',
911 | 'collapse-header-bg': '@background-color-light',
912 | 'collapse-content-padding': '@padding-md',
913 | 'collapse-content-bg': '@component-background',
914 | 'collapse-header-arrow-left': '16px',
915 |
916 | // Skeleton
917 | // ---
918 | 'skeleton-color': 'rgba(190, 190, 190, 0.2)',
919 | 'skeleton-to-color': 'shade(@skeleton-color, 5%)',
920 | 'skeleton-paragraph-margin-top': '28px',
921 | 'skeleton-paragraph-li-margin-top': '@margin-md',
922 | 'skeleton-paragraph-li-height': '16px',
923 | 'skeleton-title-height': '16px',
924 | 'skeleton-title-paragraph-margin-top': '@margin-lg',
925 |
926 | // Transfer
927 | // ---
928 | 'transfer-header-height': '40px',
929 | 'transfer-item-height': '@height-base',
930 | 'transfer-disabled-bg': '@disabled-bg',
931 | 'transfer-list-height': '200px',
932 | 'transfer-item-hover-bg': '@item-hover-bg',
933 | 'transfer-item-selected-hover-bg': 'darken(@item-active-bg, 2%)',
934 | 'transfer-item-padding-vertical': '6px',
935 | 'transfer-list-search-icon-top': '12px',
936 |
937 | // Message
938 | // ---
939 | 'message-notice-content-padding': '10px 16px',
940 | 'message-notice-content-bg': '@component-background',
941 | // Motion
942 | // ---
943 | 'wave-animation-width': '6px',
944 |
945 | // Alert
946 | // ---
947 | 'alert-success-border-color': token.colorSuccessBorder,
948 | 'alert-success-bg-color': token.colorSuccessBg,
949 | 'alert-success-icon-color': token.colorSuccess,
950 | 'alert-info-border-color': token.colorInfoBorder,
951 | 'alert-info-bg-color': token.colorInfoBg,
952 | 'alert-info-icon-color': token.colorInfo,
953 | 'alert-warning-border-color': token.colorWarningBorder,
954 | 'alert-warning-bg-color': token.colorWarningBg,
955 | 'alert-warning-icon-color': token.colorWarning,
956 | 'alert-error-border-color': token.colorErrorBorder,
957 | 'alert-error-bg-color': token.colorErrorBg,
958 | 'alert-error-icon-color': '@error-color',
959 | 'alert-message-color': '@heading-color',
960 | 'alert-text-color': '@text-color',
961 | 'alert-close-color': '@text-color-secondary',
962 | 'alert-close-hover-color': '@icon-color-hover',
963 | 'alert-padding-vertical': '@padding-xs',
964 | 'alert-padding-horizontal': '@padding-md - 1px',
965 | 'alert-no-icon-padding-vertical': '@padding-xs',
966 | 'alert-with-description-no-icon-padding-vertical': '@padding-md - 1px',
967 | 'alert-with-description-padding-vertical': '@padding-md - 1px',
968 | 'alert-with-description-padding': `@alert-with-description-padding-vertical 15px
969 | @alert-with-description-no-icon-padding-vertical @alert-with-description-icon-size`,
970 | 'alert-icon-top': '8px + @font-size-base * (@line-height-base / 2) - (@font-size-base / 2)',
971 | 'alert-with-description-icon-size': '24px',
972 |
973 | // List
974 | // ---
975 | 'list-header-background': 'transparent',
976 | 'list-footer-background': 'transparent',
977 | 'list-empty-text-padding': '@padding-md',
978 | 'list-item-padding': '@padding-sm 0',
979 | 'list-item-padding-sm': '@padding-xs @padding-md',
980 | 'list-item-padding-lg': '16px 24px',
981 | 'list-item-meta-margin-bottom': '@padding-md',
982 | 'list-item-meta-avatar-margin-right': '@padding-md',
983 | 'list-item-meta-title-margin-bottom': '@padding-sm',
984 | 'list-customize-card-bg': '@component-background',
985 | 'list-item-meta-description-font-size': '@font-size-base',
986 |
987 | // Statistic
988 | // ---
989 | 'statistic-title-font-size': '@font-size-base',
990 | 'statistic-content-font-size': '24px',
991 | 'statistic-unit-font-size': '24px',
992 | 'statistic-font-family': '@font-family',
993 |
994 | // Drawer
995 | // ---
996 | 'drawer-header-padding': '@padding-md @padding-lg',
997 | 'drawer-body-padding': '@padding-lg',
998 | 'drawer-bg': '@component-background',
999 | 'drawer-footer-padding-vertical': '@modal-footer-padding-vertical',
1000 | 'drawer-footer-padding-horizontal': '@modal-footer-padding-horizontal',
1001 | 'drawer-header-close-size': '56px',
1002 | 'drawer-title-font-size': '@font-size-lg',
1003 | 'drawer-title-line-height': '22px',
1004 |
1005 | // Timeline
1006 | // ---
1007 | 'timeline-width': '2px',
1008 | 'timeline-color': '@border-color-split',
1009 | 'timeline-dot-border-width': '2px',
1010 | 'timeline-dot-color': '@primary-color',
1011 | 'timeline-dot-bg': '@component-background',
1012 | 'timeline-item-padding-bottom': '20px',
1013 |
1014 | // Typography
1015 | // ---
1016 | 'typography-title-font-weight': '600',
1017 | 'typography-title-margin-top': '1.2em',
1018 | 'typography-title-margin-bottom': '0.5em',
1019 |
1020 | // Upload
1021 | // ---
1022 | 'upload-actions-color': '@text-color-secondary',
1023 |
1024 | // Steps
1025 | // ---
1026 | 'process-tail-color': '@border-color-split',
1027 | 'steps-nav-arrow-color': 'fade(@black, 25%)',
1028 | 'steps-background': '@component-background',
1029 | 'steps-icon-size': '32px',
1030 | 'steps-icon-custom-size': '@steps-icon-size',
1031 | 'steps-icon-custom-top': '0px',
1032 | 'steps-icon-custom-font-size': '24px',
1033 | 'steps-icon-top': '-0.5px',
1034 | 'steps-icon-font-size': '@font-size-lg',
1035 | 'steps-icon-margin': '0 8px 0 0',
1036 | 'steps-title-line-height': '@height-base',
1037 | 'steps-small-icon-size': '24px',
1038 | 'steps-small-icon-margin': '0 8px 0 0',
1039 | 'steps-dot-size': '8px',
1040 | 'steps-dot-top': '2px',
1041 | 'steps-current-dot-size': '10px',
1042 | 'steps-description-max-width': '140px',
1043 | 'steps-nav-content-max-width': 'auto',
1044 | 'steps-vertical-icon-width': '16px',
1045 | 'steps-vertical-tail-width': '16px',
1046 | 'steps-vertical-tail-width-sm': '12px',
1047 |
1048 | // Notification
1049 | // ---
1050 | 'notification-bg': '@component-background',
1051 | 'notification-padding-vertical': '16px',
1052 | 'notification-padding-horizontal': '24px',
1053 |
1054 | // Result
1055 | // ---
1056 | 'result-title-font-size': '24px',
1057 | 'result-subtitle-font-size': '@font-size-base',
1058 | 'result-icon-font-size': '72px',
1059 | 'result-extra-margin': '24px 0 0 0',
1060 |
1061 | // Image
1062 | // ---
1063 | 'image-size-base': '48px',
1064 | 'image-font-size-base': '24px',
1065 | 'image-bg': '#f5f5f5',
1066 | 'image-color': '#fff',
1067 | 'image-mask-font-size': '16px',
1068 | 'image-preview-operation-size': '18px',
1069 | 'image-preview-operation-color': '@text-color-dark',
1070 | 'image-preview-operation-disabled-color': 'fade(@image-preview-operation-color, 25%)',
1071 |
1072 | // Segmented
1073 | // ---
1074 | 'segmented-bg': 'fade(@black, 4%)',
1075 | 'segmented-hover-bg': 'fade(@black, 6%)',
1076 | 'segmented-selected-bg': '@white',
1077 | 'segmented-label-color': 'fade(@black, 65%)',
1078 | 'segmented-label-hover-color': '#262626',
1079 | } as const;
1080 |
1081 | // Fill colors. e.g. '@red-1', '@yellow-6'
1082 | Object.keys(token).forEach((key: any) => {
1083 | if (key !== key.toLowerCase()) {
1084 | return;
1085 | }
1086 |
1087 | const value = token[key];
1088 | if (typeof value === 'string') {
1089 | raw[key] = value;
1090 | }
1091 | });
1092 |
1093 | // Convert to string
1094 | const returnData: Record = {} as any;
1095 |
1096 | Object.keys(raw).forEach(key => {
1097 | const value = raw[key];
1098 |
1099 | if (typeof value === 'function') {
1100 | returnData[key] = value(raw);
1101 | } else if (typeof value === 'number' && !key.includes('line-height')) {
1102 | returnData[key] = `${value}px`;
1103 | } else {
1104 | returnData[key] = `${value}`;
1105 | }
1106 | });
1107 |
1108 | return returnData;
1109 | }
1110 |
--------------------------------------------------------------------------------
/src/theme/dark.ts:
--------------------------------------------------------------------------------
1 | import type { DerivativeFunc } from '@ant-design/cssinjs';
2 | import { generate } from '@ant-design/colors';
3 | import genColorMapToken from './genColorMapToken';
4 | import type { GenerateColorMap, GenerateNeutralColorMap } from 'antd/lib/theme/themes/ColorMap';
5 | import type { MapToken, SeedToken } from 'antd/lib/theme/interface';
6 | import { theme } from 'antd';
7 | import { TinyColor } from '@ctrl/tinycolor';
8 |
9 | const { darkAlgorithm } = theme;
10 |
11 | export const getAlphaColor = (baseColor: string, alpha: number) =>
12 | new TinyColor(baseColor).setAlpha(alpha).toRgbString();
13 |
14 | export const getSolidColor = (baseColor: string, brightness: number) => {
15 | const instance = new TinyColor(baseColor);
16 | return instance.lighten(brightness).toHexString();
17 | };
18 |
19 | const generateColorPalettes: GenerateColorMap = (baseColor: string) => {
20 | const colors = generate(baseColor, { theme: 'dark' });
21 | return {
22 | 1: colors[0],
23 | 2: colors[1],
24 | 3: colors[2],
25 | 4: colors[3],
26 | 5: colors[6],
27 | 6: colors[5],
28 | 7: colors[4],
29 | 8: colors[6],
30 | 9: colors[5],
31 | 10: colors[4],
32 | };
33 | };
34 |
35 | const generateNeutralColorPalettes: GenerateNeutralColorMap = (
36 | bgBaseColor: string,
37 | textBaseColor: string,
38 | ) => {
39 | const colorBgBase = bgBaseColor || '#000';
40 | const colorTextBase = textBaseColor || '#fff';
41 |
42 | return {
43 | colorBgBase,
44 | colorTextBase,
45 | colorBgBlur: 'transparent',
46 |
47 | colorText: getAlphaColor(colorTextBase, 0.85),
48 | colorTextSecondary: getAlphaColor(colorTextBase, 0.45), // Different from v5
49 | colorTextTertiary: getAlphaColor(colorTextBase, 0.45),
50 | colorTextQuaternary: getAlphaColor(colorTextBase, 0.25),
51 |
52 | colorFill: getAlphaColor(colorTextBase, 0.18),
53 | colorFillSecondary: getAlphaColor(colorTextBase, 0.12),
54 | colorFillTertiary: getAlphaColor(colorTextBase, 0.08),
55 | colorFillQuaternary: getAlphaColor(colorTextBase, 0.04),
56 |
57 | colorBgElevated: getSolidColor(colorBgBase, 12),
58 | colorBgContainer: getSolidColor(colorBgBase, 8),
59 | colorBgLayout: getSolidColor(colorBgBase, 0),
60 | colorBgSpotlight: getSolidColor(colorBgBase, 26),
61 |
62 | colorBorder: getSolidColor(colorBgBase, 26),
63 | colorBorderSecondary: getSolidColor(colorBgBase, 19),
64 | colorSplit: getAlphaColor(colorTextBase, 0.12),
65 |
66 | colorBgSolid: getAlphaColor(colorTextBase, 0.95),
67 | colorBgSolidHover: getAlphaColor(colorTextBase, 1),
68 | colorBgSolidActive: getAlphaColor(colorTextBase, 0.9),
69 | };
70 | };
71 |
72 | const derivative: DerivativeFunc = (token, mapToken) => {
73 | const mergedMapToken = mapToken ?? darkAlgorithm(token);
74 |
75 | return {
76 | ...mergedMapToken,
77 |
78 | // Colors
79 | ...genColorMapToken(mapToken ?? token, {
80 | generateColorPalettes,
81 | generateNeutralColorPalettes,
82 | }),
83 | };
84 | };
85 |
86 | export default derivative;
87 |
--------------------------------------------------------------------------------
/src/theme/default.ts:
--------------------------------------------------------------------------------
1 | import type { DerivativeFunc } from '@ant-design/cssinjs';
2 | import { generate } from '@ant-design/colors';
3 | import genColorMapToken from './genColorMapToken';
4 | import { theme } from 'antd';
5 | import type { GenerateColorMap, GenerateNeutralColorMap } from 'antd/lib/theme/themes/ColorMap';
6 | import type { MapToken, SeedToken } from 'antd/lib/theme/interface';
7 | import { TinyColor } from '@ctrl/tinycolor';
8 |
9 | const { defaultAlgorithm } = theme;
10 |
11 | export const getAlphaColor = (baseColor: string, alpha: number) =>
12 | new TinyColor(baseColor).setAlpha(alpha).toRgbString();
13 |
14 | export const getSolidColor = (baseColor: string, brightness: number) => {
15 | const instance = new TinyColor(baseColor);
16 | return instance.darken(brightness).toHexString();
17 | };
18 |
19 | export const generateColorPalettes: GenerateColorMap = (baseColor: string) => {
20 | const colors = generate(baseColor);
21 | return {
22 | 1: colors[0],
23 | 2: colors[1],
24 | 3: colors[2],
25 | 4: colors[3],
26 | 5: colors[4],
27 | 6: colors[5],
28 | 7: colors[6],
29 | 8: colors[4],
30 | 9: colors[5],
31 | 10: colors[6],
32 | };
33 | };
34 |
35 | const generateNeutralColorPalettes: GenerateNeutralColorMap = (
36 | bgBaseColor: string,
37 | textBaseColor: string,
38 | ) => {
39 | const colorBgBase = bgBaseColor || '#fff';
40 | const colorTextBase = textBaseColor || '#000';
41 |
42 | return {
43 | colorBgBase,
44 | colorTextBase,
45 | colorBgBlur: 'transparent',
46 |
47 | colorText: getAlphaColor(colorTextBase, 0.85),
48 | colorTextSecondary: getAlphaColor(colorTextBase, 0.45), // Different from v5
49 | colorTextTertiary: getAlphaColor(colorTextBase, 0.45),
50 | colorTextQuaternary: getAlphaColor(colorTextBase, 0.25),
51 |
52 | colorFill: getAlphaColor(colorTextBase, 0.06),
53 | colorFillSecondary: getAlphaColor(colorTextBase, 0.04),
54 | colorFillTertiary: getAlphaColor(colorTextBase, 0.03),
55 | colorFillQuaternary: getAlphaColor(colorTextBase, 0.02),
56 |
57 | colorBgLayout: getSolidColor(colorBgBase, 4),
58 | colorBgContainer: getSolidColor(colorBgBase, 0),
59 | colorBgElevated: getSolidColor(colorBgBase, 0),
60 | colorBgSpotlight: getAlphaColor(colorTextBase, 0.85),
61 |
62 | colorBorder: getSolidColor(colorBgBase, 15),
63 | colorBorderSecondary: getSolidColor(colorBgBase, 6),
64 | colorSplit: getAlphaColor(colorTextBase, 0.06),
65 |
66 | colorBgSolid: getAlphaColor(colorTextBase, 1),
67 | colorBgSolidHover: getAlphaColor(colorTextBase, 0.75),
68 | colorBgSolidActive: getAlphaColor(colorTextBase, 0.95),
69 | };
70 | };
71 |
72 | const derivative: DerivativeFunc = (token, mapToken) => {
73 | const mergedMapToken = mapToken ?? defaultAlgorithm(token);
74 |
75 | return {
76 | ...mergedMapToken,
77 |
78 | // Colors
79 | ...genColorMapToken(mapToken ?? token, {
80 | generateColorPalettes,
81 | generateNeutralColorPalettes,
82 | }),
83 | };
84 | };
85 |
86 | export default derivative;
87 |
--------------------------------------------------------------------------------
/src/theme/genColorMapToken.ts:
--------------------------------------------------------------------------------
1 | import { TinyColor } from '@ctrl/tinycolor';
2 | import type { GenerateColorMap, GenerateNeutralColorMap } from 'antd/lib/theme/themes/ColorMap';
3 | import type { ColorMapToken, SeedToken } from 'antd/lib/theme/interface';
4 |
5 | interface PaletteGenerators {
6 | generateColorPalettes: GenerateColorMap;
7 | generateNeutralColorPalettes: GenerateNeutralColorMap;
8 | }
9 |
10 | export default function genColorMapToken(
11 | seed: SeedToken,
12 | { generateColorPalettes, generateNeutralColorPalettes }: PaletteGenerators,
13 | ): ColorMapToken {
14 | const {
15 | colorSuccess: colorSuccessBase,
16 | colorWarning: colorWarningBase,
17 | colorError: colorErrorBase,
18 | colorInfo: colorInfoBase,
19 | colorPrimary: colorPrimaryBase,
20 | colorBgBase,
21 | colorTextBase,
22 | } = seed;
23 |
24 | const primaryColors = generateColorPalettes(colorPrimaryBase);
25 | const successColors = generateColorPalettes(colorSuccessBase);
26 | const warningColors = generateColorPalettes(colorWarningBase);
27 | const errorColors = generateColorPalettes(colorErrorBase);
28 | const infoColors = generateColorPalettes(colorInfoBase);
29 | const neutralColors = generateNeutralColorPalettes(colorBgBase, colorTextBase);
30 |
31 | return {
32 | ...neutralColors,
33 |
34 | colorLink: primaryColors[6],
35 | colorLinkHover: primaryColors[4],
36 | colorLinkActive: primaryColors[7],
37 |
38 | colorPrimaryBg: primaryColors[1],
39 | colorPrimaryBgHover: primaryColors[2],
40 | colorPrimaryBorder: primaryColors[3],
41 | colorPrimaryBorderHover: primaryColors[4],
42 | colorPrimaryHover: primaryColors[5],
43 | colorPrimary: primaryColors[6],
44 | colorPrimaryActive: primaryColors[7],
45 | colorPrimaryTextHover: primaryColors[8],
46 | colorPrimaryText: primaryColors[9],
47 | colorPrimaryTextActive: primaryColors[10],
48 |
49 | colorSuccessBg: successColors[1],
50 | colorSuccessBgHover: successColors[2],
51 | colorSuccessBorder: successColors[3],
52 | colorSuccessBorderHover: successColors[4],
53 | colorSuccessHover: successColors[5],
54 | colorSuccess: successColors[6],
55 | colorSuccessActive: successColors[7],
56 | colorSuccessTextHover: successColors[8],
57 | colorSuccessText: successColors[9],
58 | colorSuccessTextActive: successColors[10],
59 |
60 | colorErrorBg: errorColors[1],
61 | colorErrorBgHover: errorColors[2],
62 | colorErrorBgFilledHover: new TinyColor(errorColors[1])
63 | .mix(new TinyColor(errorColors[3]), 50)
64 | .toHexString(),
65 | colorErrorBorder: errorColors[3],
66 | colorErrorBgActive: errorColors[3],
67 | colorErrorBorderHover: errorColors[4],
68 | colorErrorHover: errorColors[5],
69 | colorError: errorColors[6],
70 | colorErrorActive: errorColors[7],
71 | colorErrorTextHover: errorColors[8],
72 | colorErrorText: errorColors[9],
73 | colorErrorTextActive: errorColors[10],
74 |
75 | colorWarningBg: warningColors[1],
76 | colorWarningBgHover: warningColors[2],
77 | colorWarningBorder: warningColors[3],
78 | colorWarningBorderHover: warningColors[4],
79 | colorWarningHover: warningColors[5],
80 | colorWarning: warningColors[6],
81 | colorWarningActive: warningColors[7],
82 | colorWarningTextHover: warningColors[8],
83 | colorWarningText: warningColors[9],
84 | colorWarningTextActive: warningColors[10],
85 |
86 | colorInfoBg: infoColors[1],
87 | colorInfoBgHover: infoColors[2],
88 | colorInfoBorder: infoColors[3],
89 | colorInfoBorderHover: infoColors[4],
90 | colorInfoHover: infoColors[5],
91 | colorInfo: infoColors[6],
92 | colorInfoActive: infoColors[7],
93 | colorInfoTextHover: infoColors[8],
94 | colorInfoText: infoColors[9],
95 | colorInfoTextActive: infoColors[10],
96 |
97 | colorBgMask: new TinyColor('#000').setAlpha(0.45).toRgbString(),
98 | colorWhite: '#fff',
99 | };
100 | }
101 |
--------------------------------------------------------------------------------
/src/theme/index.ts:
--------------------------------------------------------------------------------
1 | import type { ThemeConfig } from 'antd/lib/config-provider/context';
2 | import defaultAlgorithm from './default';
3 | import darkAlgorithm from './dark';
4 |
5 | export { defaultAlgorithm, darkAlgorithm };
6 |
7 | const v4Token: ThemeConfig = {
8 | token: { borderRadius: 2, colorPrimary: '#1890ff', wireframe: true },
9 | }
10 |
11 | export const defaultTheme: ThemeConfig = {
12 | ...v4Token,
13 | algorithm: defaultAlgorithm,
14 | components: {
15 | Menu: {
16 | itemBorderRadius: 0,
17 | subMenuItemBorderRadius: 0,
18 | itemHoverColor: '#1890ff',
19 | itemSelectedColor: '#1890ff',
20 | itemSelectedBg: '#e6f7ff',
21 | activeBarWidth: 3,
22 | itemMarginInline: 0,
23 | itemHoverBg: 'transparent',
24 | },
25 | },
26 | }
27 |
28 | export const darkTheme: ThemeConfig = {
29 | ...v4Token,
30 | algorithm: darkAlgorithm,
31 | components: {
32 | Menu: {
33 | itemBorderRadius: 0,
34 | subMenuItemBorderRadius: 0,
35 | itemHoverColor: 'transparent',
36 | itemSelectedColor: '#1890ff',
37 | itemSelectedBg: '#111b26',
38 | activeBarWidth: 3,
39 | itemMarginInline: 0,
40 | itemHoverBg: 'transparent',
41 | },
42 | },
43 | }
44 |
--------------------------------------------------------------------------------
/tests/Comment.test.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConfigProvider } from 'antd';
3 | import { Comment } from '../src';
4 | import { render } from '@testing-library/react';
5 |
6 | describe('Comment', () => {
7 | it('no hash', () => {
8 | const { container } = render(
9 |
14 |
15 | ,
16 | );
17 | expect(container).toMatchSnapshot();
18 | });
19 | });
20 |
--------------------------------------------------------------------------------
/tests/Form.test.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { ConfigProvider } from 'antd';
3 | import { Form } from '../src';
4 | import { render } from '@testing-library/react';
5 |
6 | describe('Form', () => {
7 | it('no hash', () => {
8 | const { container } = render(
9 |
14 |
15 | ,
16 | );
17 | expect(container).toMatchSnapshot();
18 | });
19 | });
20 |
--------------------------------------------------------------------------------
/tests/Icon.test.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { Icon } from '../src';
3 | import { render } from '@testing-library/react';
4 |
5 | describe('Form', () => {
6 | it('work', () => {
7 | const { container } = render( );
8 | expect(container).toMatchSnapshot();
9 | });
10 | });
11 |
--------------------------------------------------------------------------------
/tests/__mocks__/rc-trigger.js:
--------------------------------------------------------------------------------
1 | import * as React from 'react';
2 | import Trigger from 'rc-trigger/lib/mock';
3 |
4 | export default React.forwardRef((props, ref) => {
5 | return ;
6 | });
7 |
--------------------------------------------------------------------------------
/tests/__mocks__/rc-virtual-list.js:
--------------------------------------------------------------------------------
1 | import List from 'rc-virtual-list/lib/mock';
2 |
3 | export default List;
4 |
--------------------------------------------------------------------------------
/tests/__snapshots__/Comment.test.tsx.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`Comment no hash 1`] = `
4 |
5 |
20 |
21 | `;
22 |
--------------------------------------------------------------------------------
/tests/__snapshots__/Form.test.tsx.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`Form no hash 1`] = `
4 |
5 |
8 |
9 | `;
10 |
--------------------------------------------------------------------------------
/tests/__snapshots__/Icon.test.tsx.snap:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://goo.gl/fbAQLP
2 |
3 | exports[`Form work 1`] = `
4 |
5 |
11 |
20 |
23 |
24 |
25 |
26 | `;
27 |
--------------------------------------------------------------------------------
/tests/less.test.tsx:
--------------------------------------------------------------------------------
1 | import { theme } from 'antd';
2 | import { render as lessRender } from 'less';
3 | import { render } from '@testing-library/react';
4 | import { updateCSS } from 'rc-util/lib/Dom/dynamicCSS';
5 | import { convertLegacyToken } from '../src';
6 |
7 | const { defaultAlgorithm, defaultConfig } = theme;
8 |
9 | async function renderLess(lessStr: string, vars: Record) {
10 | return new Promise((resolve, reject) => {
11 | lessRender(
12 | lessStr,
13 | {
14 | javascriptEnabled: true,
15 | modifyVars: vars,
16 | },
17 | (e, output) => {
18 | if (e) {
19 | reject(e);
20 | return;
21 | }
22 |
23 | resolve(output.css.trim());
24 | },
25 | );
26 | });
27 | }
28 |
29 | describe('Less', () => {
30 | afterEach(() => {
31 | const styles = Array.from(document.querySelectorAll('style'));
32 | styles.forEach(style => {
33 | style.parentNode?.removeChild(style);
34 | });
35 | });
36 |
37 | it('work', async () => {
38 | const mapToken = defaultAlgorithm(defaultConfig.token);
39 | const legacyToken = convertLegacyToken(mapToken);
40 |
41 | // Value exist check
42 | expect(legacyToken['line-height-base']).toEqual(`${mapToken.lineHeight}`);
43 | expect(legacyToken['border-radius-base']).toEqual(`${mapToken.borderRadius}px`);
44 |
45 | // Less compile check
46 | const css = await renderLess(
47 | `
48 | @my-prefix-cls: ~'@{ant-prefix}-my';
49 |
50 | .@{my-prefix-cls} {
51 | color: @primary-color;
52 | }
53 | `,
54 | legacyToken,
55 | );
56 |
57 | updateCSS(css, 'ant-my');
58 | const { container } = render(
);
59 |
60 | expect(container.querySelector('p')).toHaveStyle({
61 | color: mapToken.colorPrimary,
62 | });
63 | });
64 | });
65 |
--------------------------------------------------------------------------------
/tests/setupAfterEnv.ts:
--------------------------------------------------------------------------------
1 | import '@testing-library/jest-dom';
2 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "esnext",
4 | "moduleResolution": "node",
5 | "baseUrl": "./",
6 | "jsx": "preserve",
7 | "declaration": true,
8 | "skipLibCheck": true,
9 | "esModuleInterop": true,
10 | "paths": {
11 | "@/*": ["src/*"],
12 | "@@/*": ["src/.umi/*"],
13 | "@ant-design/compatible": ["src/index.tsx"]
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/typings.d.ts:
--------------------------------------------------------------------------------
1 | declare module '*.css';
2 | declare module '*.less';
3 |
--------------------------------------------------------------------------------