mirror of
https://github.com/ant-design/ant-design.git
synced 2026-02-09 19:09:21 +08:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1cc97c90e | ||
|
|
06a4287d73 | ||
|
|
37a3ef15d8 | ||
|
|
b22a7108cf | ||
|
|
67305c0ace | ||
|
|
4ab542e7c3 | ||
|
|
07f0db2ddc | ||
|
|
2e51288638 | ||
|
|
258573ab93 | ||
|
|
3c9bb681e7 | ||
|
|
3e0b56dacf | ||
|
|
7d35e112ae | ||
|
|
6e55573b5c | ||
|
|
0e4f60dd01 | ||
|
|
0b55335da9 | ||
|
|
40c0bd6bb1 | ||
|
|
98614197cb | ||
|
|
8fd30ab4a2 | ||
|
|
e05aa23faa | ||
|
|
050d1dfa42 |
@@ -1,7 +1,7 @@
|
||||
import React, { useMemo } from 'react';
|
||||
import type { MenuProps } from 'antd';
|
||||
import { Flex, Tag, version } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { clsx } from 'clsx';
|
||||
import { useFullSidebarData, useSidebarData } from 'dumi';
|
||||
|
||||
@@ -33,7 +33,7 @@ const getTagColor = (val?: string) => {
|
||||
}
|
||||
};
|
||||
|
||||
const useStyle = createStyles(({ css, cssVar }) => ({
|
||||
const styles = createStaticStyles(({ css, cssVar }) => ({
|
||||
link: css`
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -62,7 +62,6 @@ interface MenuItemLabelProps {
|
||||
}
|
||||
|
||||
const MenuItemLabelWithTag: React.FC<MenuItemLabelProps> = (props) => {
|
||||
const { styles } = useStyle();
|
||||
const { before, after, link, title, subtitle, search, tag, className } = props;
|
||||
|
||||
const [locale] = useLocale(locales);
|
||||
|
||||
@@ -49,7 +49,8 @@ const useStyle = createStyles(({ cssVar, css, cx }) => {
|
||||
max-width: 100%;
|
||||
margin-inline: auto;
|
||||
box-sizing: border-box;
|
||||
column-gap: calc(${cssVar.paddingMD} * 2);
|
||||
column-gap: ${cssVar.paddingMD};
|
||||
padding: 0 ${cssVar.padding};
|
||||
align-items: stretch;
|
||||
text-align: start;
|
||||
min-height: 178px;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import * as React from 'react';
|
||||
import { Typography } from 'antd';
|
||||
import { createStyles, useTheme } from 'antd-style';
|
||||
import { createStaticStyles, useTheme } from 'antd-style';
|
||||
import { clsx } from 'clsx';
|
||||
|
||||
import SiteContext from '../../../theme/slots/SiteContext';
|
||||
import GroupMaskLayer from './GroupMaskLayer';
|
||||
|
||||
const useStyle = createStyles(({ css, cssVar }) => ({
|
||||
const styles = createStaticStyles(({ css, cssVar }) => ({
|
||||
box: css`
|
||||
position: relative;
|
||||
transition: all ${cssVar.motionDurationSlow};
|
||||
@@ -46,7 +46,6 @@ export interface GroupProps {
|
||||
const Group: React.FC<React.PropsWithChildren<GroupProps>> = (props) => {
|
||||
const { id, title, titleColor, description, children, decoration, background, collapse } = props;
|
||||
const token = useTheme();
|
||||
const { styles } = useStyle();
|
||||
const { isMobile } = React.use(SiteContext);
|
||||
return (
|
||||
<div style={{ backgroundColor: background }} className={styles.box}>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React from 'react';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { clsx } from 'clsx';
|
||||
|
||||
const useStyle = createStyles(({ css }) => ({
|
||||
const classNames = createStaticStyles(({ css }) => ({
|
||||
siteMask: css`
|
||||
z-index: 1;
|
||||
position: relative;
|
||||
@@ -19,11 +19,10 @@ export interface GroupMaskLayerProps {
|
||||
|
||||
const GroupMaskLayer: React.FC<React.PropsWithChildren<GroupMaskLayerProps>> = (props) => {
|
||||
const { children, className, style, onMouseMove, onMouseEnter, onMouseLeave } = props;
|
||||
const { styles } = useStyle();
|
||||
return (
|
||||
<div
|
||||
style={style}
|
||||
className={clsx(className, styles.siteMask)}
|
||||
className={clsx(className, classNames.siteMask)}
|
||||
onMouseMove={onMouseMove}
|
||||
onMouseEnter={onMouseEnter}
|
||||
onMouseLeave={onMouseLeave}
|
||||
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
Button,
|
||||
Checkbox,
|
||||
ColorPicker,
|
||||
ConfigProvider,
|
||||
Dropdown,
|
||||
Input,
|
||||
message,
|
||||
@@ -17,9 +18,11 @@ import {
|
||||
Switch,
|
||||
Tooltip,
|
||||
} from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import type { ConfigProviderProps } from 'antd';
|
||||
|
||||
import useLocale from '../../../../hooks/useLocale';
|
||||
|
||||
import Tilt from './Tilt';
|
||||
|
||||
const { _InternalPanelDoNotUseOrYouWillBeFired: ModalPanel } = Modal;
|
||||
@@ -71,7 +74,7 @@ const locales = {
|
||||
},
|
||||
};
|
||||
|
||||
const useStyle = createStyles(({ cssVar, css }) => {
|
||||
const styles = createStaticStyles(({ cssVar, css }) => {
|
||||
const gap = cssVar.padding;
|
||||
return {
|
||||
holder: css`
|
||||
@@ -103,118 +106,123 @@ const useStyle = createStyles(({ cssVar, css }) => {
|
||||
`,
|
||||
};
|
||||
});
|
||||
interface ComponentsBlockProps {
|
||||
config: ConfigProviderProps;
|
||||
}
|
||||
|
||||
const ComponentsBlock: React.FC = () => {
|
||||
const ComponentsBlock: React.FC<ComponentsBlockProps> = (props) => {
|
||||
const [locale] = useLocale(locales);
|
||||
const { styles } = useStyle();
|
||||
const { config } = props;
|
||||
|
||||
return (
|
||||
<Tilt options={{ max: 4, glare: false, scale: 0.98 }} className={styles.holder}>
|
||||
<ModalPanel title="Ant Design" width="100%">
|
||||
{locale.text}
|
||||
</ModalPanel>
|
||||
<Alert title={locale.infoText} type="info" />
|
||||
{/* Line */}
|
||||
<div className={styles.flex}>
|
||||
<ColorPicker style={{ flex: 'none' }} />
|
||||
<div style={{ flex: 'none' }}>
|
||||
<Space.Compact>
|
||||
<Button>{locale.dropdown}</Button>
|
||||
<Dropdown
|
||||
menu={{
|
||||
items: Array.from({ length: 5 }).map((_, index) => ({
|
||||
key: `opt${index}`,
|
||||
label: `${locale.option} ${index}`,
|
||||
})),
|
||||
}}
|
||||
>
|
||||
<Button icon={<DownOutlined />} />
|
||||
</Dropdown>
|
||||
</Space.Compact>
|
||||
<ConfigProvider {...config}>
|
||||
<Tilt options={{ max: 4, glare: false, scale: 0.98 }} className={styles.holder}>
|
||||
<ModalPanel title="Ant Design" width="100%">
|
||||
{locale.text}
|
||||
</ModalPanel>
|
||||
<Alert title={locale.infoText} type="info" />
|
||||
{/* Line */}
|
||||
<div className={styles.flex}>
|
||||
<ColorPicker style={{ flex: 'none' }} />
|
||||
<div style={{ flex: 'none' }}>
|
||||
<Space.Compact>
|
||||
<Button>{locale.dropdown}</Button>
|
||||
<Dropdown
|
||||
menu={{
|
||||
items: Array.from({ length: 5 }).map((_, index) => ({
|
||||
key: `opt${index}`,
|
||||
label: `${locale.option} ${index}`,
|
||||
})),
|
||||
}}
|
||||
>
|
||||
<Button icon={<DownOutlined />} />
|
||||
</Dropdown>
|
||||
</Space.Compact>
|
||||
</div>
|
||||
<Select
|
||||
style={{ flex: 'auto' }}
|
||||
mode="multiple"
|
||||
maxTagCount="responsive"
|
||||
defaultValue={[{ value: 'apple' }, { value: 'banana' }]}
|
||||
options={[
|
||||
{ value: 'apple', label: locale.apple },
|
||||
{ value: 'banana', label: locale.banana },
|
||||
{ value: 'orange', label: locale.orange },
|
||||
{ value: 'watermelon', label: locale.watermelon },
|
||||
]}
|
||||
/>
|
||||
<Input style={{ flex: 'none', width: 120 }} />
|
||||
</div>
|
||||
<Select
|
||||
style={{ flex: 'auto' }}
|
||||
mode="multiple"
|
||||
maxTagCount="responsive"
|
||||
defaultValue={[{ value: 'apple' }, { value: 'banana' }]}
|
||||
options={[
|
||||
{ value: 'apple', label: locale.apple },
|
||||
{ value: 'banana', label: locale.banana },
|
||||
{ value: 'orange', label: locale.orange },
|
||||
{ value: 'watermelon', label: locale.watermelon },
|
||||
<Progress
|
||||
style={{ margin: 0 }}
|
||||
percent={100}
|
||||
strokeColor={{ '0%': '#108ee9', '100%': '#87d068' }}
|
||||
/>
|
||||
<Progress style={{ margin: 0 }} percent={33} status="exception" />
|
||||
<Steps
|
||||
current={1}
|
||||
items={[
|
||||
{ title: locale.finished },
|
||||
{ title: locale.inProgress },
|
||||
{ title: locale.waiting },
|
||||
]}
|
||||
/>
|
||||
<Input style={{ flex: 'none', width: 120 }} />
|
||||
</div>
|
||||
<Progress
|
||||
style={{ margin: 0 }}
|
||||
percent={100}
|
||||
strokeColor={{ '0%': '#108ee9', '100%': '#87d068' }}
|
||||
/>
|
||||
<Progress style={{ margin: 0 }} percent={33} status="exception" />
|
||||
<Steps
|
||||
current={1}
|
||||
items={[
|
||||
{ title: locale.finished },
|
||||
{ title: locale.inProgress },
|
||||
{ title: locale.waiting },
|
||||
]}
|
||||
/>
|
||||
{/* Line */}
|
||||
<div className={styles.block}>
|
||||
<Slider
|
||||
style={{ marginInline: 20 }}
|
||||
range
|
||||
marks={{
|
||||
0: '0°C',
|
||||
26: '26°C',
|
||||
37: '37°C',
|
||||
100: {
|
||||
style: { color: '#f50' },
|
||||
label: <strong>100°C</strong>,
|
||||
},
|
||||
}}
|
||||
defaultValue={[26, 37]}
|
||||
/>
|
||||
</div>
|
||||
{/* Line */}
|
||||
<div className={styles.flex}>
|
||||
<Button className={styles.ptg_20} type="primary">
|
||||
{locale.primary}
|
||||
</Button>
|
||||
<Button className={styles.ptg_20} type="primary" danger>
|
||||
{locale.danger}
|
||||
</Button>
|
||||
<Button className={styles.ptg_20}>{locale.default}</Button>
|
||||
<Button className={styles.ptg_20} type="dashed">
|
||||
{locale.dashed}
|
||||
</Button>
|
||||
<Button className={styles.ptg_20} icon={<AntDesignOutlined />}>
|
||||
{locale.icon}
|
||||
</Button>
|
||||
</div>
|
||||
{/* Line */}
|
||||
<div className={styles.block}>
|
||||
<div className={styles.flex}>
|
||||
<Switch
|
||||
className={styles.ptg_none}
|
||||
defaultChecked
|
||||
checkedChildren={<CheckOutlined />}
|
||||
unCheckedChildren={<CloseOutlined />}
|
||||
/>
|
||||
<Checkbox.Group
|
||||
className={styles.ptg_none}
|
||||
options={[locale.apple, locale.banana, locale.orange]}
|
||||
defaultValue={[locale.apple]}
|
||||
{/* Line */}
|
||||
<div className={styles.block}>
|
||||
<Slider
|
||||
style={{ marginInline: 20 }}
|
||||
range
|
||||
marks={{
|
||||
0: '0°C',
|
||||
26: '26°C',
|
||||
37: '37°C',
|
||||
100: {
|
||||
style: { color: '#f50' },
|
||||
label: <strong>100°C</strong>,
|
||||
},
|
||||
}}
|
||||
defaultValue={[26, 37]}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<InternalMessage content={locale.release} type="success" />
|
||||
</div>
|
||||
<InternalTooltip title={locale.hello} placement="topLeft" className={styles.noMargin} />
|
||||
<Alert title="Ant Design love you!" type="success" />
|
||||
</Tilt>
|
||||
{/* Line */}
|
||||
<div className={styles.flex}>
|
||||
<Button className={styles.ptg_20} type="primary">
|
||||
{locale.primary}
|
||||
</Button>
|
||||
<Button className={styles.ptg_20} type="primary" danger>
|
||||
{locale.danger}
|
||||
</Button>
|
||||
<Button className={styles.ptg_20}>{locale.default}</Button>
|
||||
<Button className={styles.ptg_20} type="dashed">
|
||||
{locale.dashed}
|
||||
</Button>
|
||||
<Button className={styles.ptg_20} icon={<AntDesignOutlined />}>
|
||||
{locale.icon}
|
||||
</Button>
|
||||
</div>
|
||||
{/* Line */}
|
||||
<div className={styles.block}>
|
||||
<div className={styles.flex}>
|
||||
<Switch
|
||||
className={styles.ptg_none}
|
||||
defaultChecked
|
||||
checkedChildren={<CheckOutlined />}
|
||||
unCheckedChildren={<CloseOutlined />}
|
||||
/>
|
||||
<Checkbox.Group
|
||||
className={styles.ptg_none}
|
||||
options={[locale.apple, locale.banana, locale.orange]}
|
||||
defaultValue={[locale.apple]}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<InternalMessage content={locale.release} type="success" />
|
||||
</div>
|
||||
<InternalTooltip title={locale.hello} placement="topLeft" className={styles.noMargin} />
|
||||
<Alert title="Ant Design love you!" type="success" />
|
||||
</Tilt>
|
||||
</ConfigProvider>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -1,15 +1,21 @@
|
||||
import React, { Suspense, use } from 'react';
|
||||
import { Flex, Typography } from 'antd';
|
||||
import React, { Suspense, use, useState } from 'react';
|
||||
import { Button, Flex, Typography } from 'antd';
|
||||
import type { ConfigProviderProps, ThemeConfig } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { clsx } from 'clsx';
|
||||
import { useLocation } from 'dumi';
|
||||
|
||||
import { DarkContext } from '../../../../hooks/useDark';
|
||||
import useLocale from '../../../../hooks/useLocale';
|
||||
import LinkButton from '../../../../theme/common/LinkButton';
|
||||
import PromptDrawer from '../../../../theme/common/ThemeSwitch/PromptDrawer';
|
||||
import ThemeIcon from '../../../../theme/common/ThemeSwitch/ThemeIcon';
|
||||
import SiteContext from '../../../../theme/slots/SiteContext';
|
||||
import type { SiteContextProps } from '../../../../theme/slots/SiteContext';
|
||||
import * as utils from '../../../../theme/utils';
|
||||
import GroupMaskLayer from '../GroupMaskLayer';
|
||||
import { muiComponentConfig, muiDark, muiLight } from './themes/mui';
|
||||
import { shadcnComponentConfig, shadcnDark, shadcnLight } from './themes/shadcn';
|
||||
|
||||
import '../SiteContext';
|
||||
|
||||
@@ -119,64 +125,251 @@ const useStyle = createStyles(({ cssVar, css, cx }, siteConfig: SiteContextProps
|
||||
bottom: 120px;
|
||||
inset-inline-end: ${siteConfig.isMobile ? 0 : '40%'};
|
||||
`,
|
||||
themeBar: css`
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
margin: 24px 0;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
`,
|
||||
themeLabel: css`
|
||||
background: ${cssVar.colorBgElevated};
|
||||
padding: 6px 12px;
|
||||
border-radius: 20px;
|
||||
box-shadow: ${cssVar.boxShadowSecondary};
|
||||
color: ${cssVar.colorText};
|
||||
font-weight: 600;
|
||||
font-size: ${cssVar.fontSizeSM};
|
||||
`,
|
||||
presets: css`
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
`,
|
||||
presetButton: cx(css`
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
border-radius: 14px;
|
||||
background: ${cssVar.colorBgElevated};
|
||||
color: ${cssVar.colorText};
|
||||
cursor: pointer;
|
||||
border: 1px solid transparent;
|
||||
box-shadow: ${cssVar.boxShadowSecondary};
|
||||
transition: all 0.2s ease;
|
||||
font-size: ${cssVar.fontSizeSM};
|
||||
padding: 7px 18px;
|
||||
line-height: 18px;
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
&:hover {
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
`),
|
||||
swatches: css`
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
`,
|
||||
swatch: css`
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
|
||||
`,
|
||||
name: css`
|
||||
margin-left: 10px;
|
||||
text-transform: capitalize;
|
||||
`,
|
||||
};
|
||||
});
|
||||
|
||||
type THEME_MAP = 'antd' | 'shadcn' | 'mui';
|
||||
|
||||
interface Theme {
|
||||
name: THEME_MAP;
|
||||
theme: ThemeConfig;
|
||||
componentsConfig: Partial<ConfigProviderProps>;
|
||||
style?: React.CSSProperties;
|
||||
activeStyle: React.CSSProperties;
|
||||
swatches: string[];
|
||||
}
|
||||
|
||||
const PreviewBanner: React.FC<Readonly<React.PropsWithChildren>> = (props) => {
|
||||
const { updateSiteConfig } = use<SiteContextProps>(SiteContext);
|
||||
const [isMarketDrawerOpen, setIsMarketDrawerOpen] = useState(false);
|
||||
const { children } = props;
|
||||
const [locale] = useLocale(locales);
|
||||
const siteConfig = use(SiteContext);
|
||||
const { styles } = useStyle(siteConfig);
|
||||
const { pathname, search } = useLocation();
|
||||
const isZhCN = utils.isZhCN(pathname);
|
||||
const [theme, setTheme] = useState<THEME_MAP>('antd');
|
||||
const isDark = React.use(DarkContext);
|
||||
|
||||
const themeMap: Record<THEME_MAP, Theme> = {
|
||||
antd: {
|
||||
name: 'antd',
|
||||
theme: {},
|
||||
componentsConfig: {},
|
||||
activeStyle: {
|
||||
border: '1px solid #1677ff',
|
||||
},
|
||||
swatches: ['#1677ff', '#91d5ff', '#f0f5ff'],
|
||||
},
|
||||
shadcn: {
|
||||
name: 'shadcn',
|
||||
theme: isDark ? shadcnDark : shadcnLight,
|
||||
style: {
|
||||
backgroundColor: 'rgba(0, 0, 0, 0.1)',
|
||||
},
|
||||
activeStyle: {
|
||||
border: '1px solid oklch(0.205 0 0)',
|
||||
},
|
||||
componentsConfig: shadcnComponentConfig,
|
||||
swatches: ['oklch(0.205 0 0)', 'oklch(0.556 0 0)', 'rgba(0, 0, 0, 0.05)'],
|
||||
},
|
||||
mui: {
|
||||
name: 'mui',
|
||||
theme: isDark ? muiDark : muiLight,
|
||||
componentsConfig: muiComponentConfig,
|
||||
style: {
|
||||
color: '#fff',
|
||||
backgroundColor: 'rgb(2, 136, 209, 0.5)',
|
||||
},
|
||||
activeStyle: {
|
||||
border: '1px solid rgb(25, 118, 210)',
|
||||
},
|
||||
swatches: ['#1677ff', '#91d5ff', '#f0f5ff'],
|
||||
},
|
||||
};
|
||||
const config: ConfigProviderProps = {
|
||||
theme: themeMap[theme].theme,
|
||||
...themeMap[theme].componentsConfig,
|
||||
};
|
||||
|
||||
return (
|
||||
<GroupMaskLayer>
|
||||
{/* Image Left Top */}
|
||||
<img
|
||||
alt="bg"
|
||||
src="https://gw.alipayobjects.com/zos/bmw-prod/49f963db-b2a8-4f15-857a-270d771a1204.svg"
|
||||
draggable={false}
|
||||
className={clsx(styles.bgImg, styles.bgImgTop)}
|
||||
/>
|
||||
{/* Image Right Top */}
|
||||
<img
|
||||
alt="bg"
|
||||
src="https://gw.alipayobjects.com/zos/bmw-prod/e152223c-bcae-4913-8938-54fda9efe330.svg"
|
||||
draggable={false}
|
||||
className={clsx(styles.bgImg, styles.bgImgBottom)}
|
||||
/>
|
||||
<div
|
||||
className={styles.holder}
|
||||
style={{
|
||||
display: 'flex',
|
||||
flexDirection: 'row',
|
||||
alignItems: 'stretch',
|
||||
justifyContent: 'center',
|
||||
height: 640,
|
||||
position: 'relative',
|
||||
overflow: 'hidden',
|
||||
perspective: 800,
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
flex: 1,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
position: 'relative',
|
||||
zIndex: 1,
|
||||
}}
|
||||
>
|
||||
<img
|
||||
alt="bg"
|
||||
src="https://gw.alipayobjects.com/zos/bmw-prod/49f963db-b2a8-4f15-857a-270d771a1204.svg"
|
||||
draggable={false}
|
||||
className={clsx(styles.bgImg, styles.bgImgTop)}
|
||||
style={{ position: 'absolute', left: 0, top: 0, zIndex: 0 }}
|
||||
/>
|
||||
<div className={styles.mask} />
|
||||
|
||||
<div className={styles.holder}>
|
||||
{/* Mobile not show the component preview */}
|
||||
<Suspense fallback={null}>
|
||||
{siteConfig.isMobile ? null : (
|
||||
<div className={styles.block}>
|
||||
<ComponentsBlock />
|
||||
<Typography className={styles.typography}>
|
||||
<h1>Ant Design</h1>
|
||||
<p>{locale.slogan}</p>
|
||||
</Typography>
|
||||
<div className={styles.themeBar}>
|
||||
<div className={styles.presets}>
|
||||
{Object.keys(themeMap).map((v, i) => {
|
||||
const key = v as THEME_MAP;
|
||||
return (
|
||||
<div
|
||||
key={i}
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
onClick={() => setTheme(themeMap[key].name)}
|
||||
className={clsx(styles.presetButton)}
|
||||
style={{
|
||||
...themeMap[key].style,
|
||||
...(theme === themeMap[key].name ? themeMap[key].activeStyle : {}),
|
||||
}}
|
||||
>
|
||||
<div className={styles.swatches}>
|
||||
{themeMap[key].swatches?.map((s: any) => (
|
||||
<span key={s} className={styles.swatch} style={{ background: s }} />
|
||||
))}
|
||||
</div>
|
||||
<span className={styles.name}>{themeMap[key].name}</span>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
<Button
|
||||
variant="solid"
|
||||
icon={<ThemeIcon />}
|
||||
onClick={() => setIsMarketDrawerOpen(true)}
|
||||
style={{ fontSize: 16 }}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</Suspense>
|
||||
<div className={styles.mask} />
|
||||
<Typography className={styles.typography}>
|
||||
<h1>Ant Design</h1>
|
||||
<p>{locale.slogan}</p>
|
||||
</Typography>
|
||||
<Flex gap="middle" className={styles.btnWrap}>
|
||||
<LinkButton
|
||||
size="large"
|
||||
type="primary"
|
||||
to={utils.getLocalizedPathname('/components/overview/', isZhCN, search)}
|
||||
>
|
||||
{locale.start}
|
||||
</LinkButton>
|
||||
<LinkButton
|
||||
size="large"
|
||||
to={utils.getLocalizedPathname('/docs/spec/introduce/', isZhCN, search)}
|
||||
>
|
||||
{locale.designLanguage}
|
||||
</LinkButton>
|
||||
</Flex>
|
||||
<div className={styles.child}>{children}</div>
|
||||
</div>
|
||||
<Flex gap="middle" className={styles.btnWrap}>
|
||||
<LinkButton
|
||||
size="large"
|
||||
type="primary"
|
||||
to={utils.getLocalizedPathname('/components/overview/', isZhCN, search)}
|
||||
>
|
||||
{locale.start}
|
||||
</LinkButton>
|
||||
<LinkButton
|
||||
size="large"
|
||||
to={utils.getLocalizedPathname('/docs/spec/introduce/', isZhCN, search)}
|
||||
>
|
||||
{locale.designLanguage}
|
||||
</LinkButton>
|
||||
</Flex>
|
||||
<div className={styles.child}>{children}</div>
|
||||
</div>
|
||||
<PromptDrawer
|
||||
open={isMarketDrawerOpen}
|
||||
onClose={() => setIsMarketDrawerOpen(false)}
|
||||
onThemeChange={(nextTheme) => {
|
||||
updateSiteConfig({
|
||||
dynamicTheme: nextTheme,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
<div
|
||||
style={{
|
||||
width: '40%',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
position: 'relative',
|
||||
backgroundColor: isDark ? '#393F4A' : '#f4f8ff',
|
||||
borderRadius: '0 0px 0px 12px',
|
||||
}}
|
||||
>
|
||||
<img
|
||||
alt="bg"
|
||||
src="https://gw.alipayobjects.com/zos/bmw-prod/e152223c-bcae-4913-8938-54fda9efe330.svg"
|
||||
draggable={false}
|
||||
className={clsx(styles.bgImg, styles.bgImgBottom)}
|
||||
style={{ position: 'absolute', right: 0, top: 0, zIndex: 0 }}
|
||||
/>
|
||||
<Suspense fallback={null}>
|
||||
{siteConfig.isMobile ? null : (
|
||||
<div className={styles.block} style={{ position: 'relative', zIndex: 1 }}>
|
||||
<ComponentsBlock config={config} />
|
||||
</div>
|
||||
)}
|
||||
</Suspense>
|
||||
</div>
|
||||
</div>
|
||||
</GroupMaskLayer>
|
||||
);
|
||||
|
||||
244
.dumi/pages/index/components/PreviewBanner/themes/mui.ts
Normal file
244
.dumi/pages/index/components/PreviewBanner/themes/mui.ts
Normal file
@@ -0,0 +1,244 @@
|
||||
import type { ConfigProviderProps, ThemeConfig } from 'antd';
|
||||
import { theme } from 'antd';
|
||||
|
||||
const { darkAlgorithm, defaultAlgorithm } = theme;
|
||||
|
||||
export const mui: ThemeConfig = {
|
||||
token: {
|
||||
colorPrimary: '#1976d2',
|
||||
colorSuccess: '#2e7d32',
|
||||
colorWarning: '#ed6c02',
|
||||
colorError: '#d32f2f',
|
||||
colorInfo: '#0288d1',
|
||||
colorTextBase: '#212121',
|
||||
colorBgBase: '#fafafa',
|
||||
colorPrimaryBg: '#e3f2fd',
|
||||
colorPrimaryBgHover: '#bbdefb',
|
||||
colorPrimaryBorder: '#90caf9',
|
||||
colorPrimaryBorderHover: '#64b5f6',
|
||||
colorPrimaryHover: '#42a5f5',
|
||||
colorPrimaryActive: '#1565c0',
|
||||
colorPrimaryText: '#1976d2',
|
||||
colorPrimaryTextHover: '#42a5f5',
|
||||
colorPrimaryTextActive: '#1565c0',
|
||||
colorSuccessBg: '#e8f5e9',
|
||||
colorSuccessBgHover: '#c8e6c9',
|
||||
colorSuccessBorder: '#a5d6a7',
|
||||
colorSuccessBorderHover: '#81c784',
|
||||
colorSuccessHover: '#4caf50',
|
||||
colorSuccessActive: '#1b5e20',
|
||||
colorSuccessText: '#2e7d32',
|
||||
colorSuccessTextHover: '#4caf50',
|
||||
colorSuccessTextActive: '#1b5e20',
|
||||
colorWarningBg: '#fff3e0',
|
||||
colorWarningBgHover: '#ffe0b2',
|
||||
colorWarningBorder: '#ffcc02',
|
||||
colorWarningBorderHover: '#ffb74d',
|
||||
colorWarningHover: '#ff9800',
|
||||
colorWarningActive: '#e65100',
|
||||
colorWarningText: '#ed6c02',
|
||||
colorWarningTextHover: '#ff9800',
|
||||
colorWarningTextActive: '#e65100',
|
||||
colorErrorBg: '#ffebee',
|
||||
colorErrorBgHover: '#ffcdd2',
|
||||
colorErrorBorder: '#ef9a9a',
|
||||
colorErrorBorderHover: '#e57373',
|
||||
colorErrorHover: '#ef5350',
|
||||
colorErrorActive: '#c62828',
|
||||
colorErrorText: '#d32f2f',
|
||||
colorErrorTextHover: '#ef5350',
|
||||
colorErrorTextActive: '#c62828',
|
||||
colorInfoBg: '#e1f5fe',
|
||||
colorInfoBgHover: '#b3e5fc',
|
||||
colorInfoBorder: '#81d4fa',
|
||||
colorInfoBorderHover: '#4fc3f7',
|
||||
colorInfoHover: '#03a9f4',
|
||||
colorInfoActive: '#01579b',
|
||||
colorInfoText: '#0288d1',
|
||||
colorInfoTextHover: '#03a9f4',
|
||||
colorInfoTextActive: '#01579b',
|
||||
colorText: 'rgba(33, 33, 33, 0.87)',
|
||||
colorTextSecondary: 'rgba(33, 33, 33, 0.6)',
|
||||
colorTextTertiary: 'rgba(33, 33, 33, 0.38)',
|
||||
colorTextQuaternary: 'rgba(33, 33, 33, 0.26)',
|
||||
colorTextDisabled: 'rgba(33, 33, 33, 0.38)',
|
||||
colorBgContainer: '#ffffff',
|
||||
colorBgElevated: '#ffffff',
|
||||
colorBgLayout: '#f5f5f5',
|
||||
colorBgSpotlight: 'rgba(33, 33, 33, 0.85)',
|
||||
colorBgMask: 'rgba(33, 33, 33, 0.5)',
|
||||
colorBorder: '#e0e0e0',
|
||||
colorBorderSecondary: '#eeeeee',
|
||||
borderRadius: 4,
|
||||
borderRadiusXS: 1,
|
||||
borderRadiusSM: 2,
|
||||
borderRadiusLG: 6,
|
||||
padding: 16,
|
||||
paddingSM: 8,
|
||||
paddingLG: 24,
|
||||
margin: 16,
|
||||
marginSM: 8,
|
||||
marginLG: 24,
|
||||
boxShadow:
|
||||
'0px 2px 1px -1px rgba(0,0,0,0.2),0px 1px 1px 0px rgba(0,0,0,0.14),0px 1px 3px 0px rgba(0,0,0,0.12)',
|
||||
boxShadowSecondary:
|
||||
'0px 3px 3px -2px rgba(0,0,0,0.2),0px 3px 4px 0px rgba(0,0,0,0.14),0px 1px 8px 0px rgba(0,0,0,0.12)',
|
||||
},
|
||||
components: {
|
||||
Button: {
|
||||
primaryShadow:
|
||||
'0px 3px 1px -2px rgba(0,0,0,0.2), 0px 2px 2px 0px rgba(0,0,0,0.14), 0px 1px 5px 0px rgba(0,0,0,0.12)',
|
||||
defaultShadow:
|
||||
'0px 3px 1px -2px rgba(0,0,0,0.2), 0px 2px 2px 0px rgba(0,0,0,0.14), 0px 1px 5px 0px rgba(0,0,0,0.12)',
|
||||
dangerShadow:
|
||||
'0px 3px 1px -2px rgba(0,0,0,0.2), 0px 2px 2px 0px rgba(0,0,0,0.14), 0px 1px 5px 0px rgba(0,0,0,0.12)',
|
||||
fontWeight: 500,
|
||||
defaultBorderColor: 'rgba(0, 0, 0, 0.23)',
|
||||
defaultColor: 'rgba(0, 0, 0, 0.87)',
|
||||
defaultBg: '#ffffff',
|
||||
defaultHoverBg: 'rgba(25, 118, 210, 0.04)',
|
||||
defaultHoverBorderColor: 'rgba(0, 0, 0, 0.23)',
|
||||
paddingInline: 16,
|
||||
paddingBlock: 6,
|
||||
contentFontSize: 14,
|
||||
borderRadius: 4,
|
||||
},
|
||||
Alert: {
|
||||
borderRadiusLG: 4,
|
||||
},
|
||||
Modal: {
|
||||
borderRadiusLG: 4,
|
||||
},
|
||||
Progress: {
|
||||
defaultColor: '#1976d2',
|
||||
remainingColor: 'rgba(25, 118, 210, 0.12)',
|
||||
},
|
||||
Steps: {
|
||||
iconSize: 24,
|
||||
},
|
||||
Checkbox: {
|
||||
borderRadiusSM: 2,
|
||||
},
|
||||
Slider: {
|
||||
trackBg: 'rgba(25, 118, 210, 0.26)',
|
||||
trackHoverBg: 'rgba(25, 118, 210, 0.38)',
|
||||
handleSize: 20,
|
||||
handleSizeHover: 20,
|
||||
railSize: 4,
|
||||
},
|
||||
ColorPicker: {
|
||||
borderRadius: 4,
|
||||
},
|
||||
},
|
||||
};
|
||||
export const muiLight: ThemeConfig = {
|
||||
algorithm: defaultAlgorithm,
|
||||
token: mui.token,
|
||||
components: mui.components,
|
||||
};
|
||||
|
||||
export const muiDark: ThemeConfig = {
|
||||
algorithm: darkAlgorithm,
|
||||
token: {
|
||||
...mui.token,
|
||||
},
|
||||
components: {
|
||||
...mui.components,
|
||||
Message: {
|
||||
contentBg: '#212121',
|
||||
contentPadding: '8px 16px',
|
||||
zIndexPopup: 1010,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const muiComponentConfig: Partial<ConfigProviderProps> = {
|
||||
button: {
|
||||
styles: (info) => {
|
||||
const { props } = info;
|
||||
if (props.type === 'primary') {
|
||||
return {
|
||||
root: {
|
||||
backgroundColor: '#1976d2',
|
||||
color: '#ffffff',
|
||||
border: 'none',
|
||||
fontWeight: 500,
|
||||
textTransform: 'uppercase' as const,
|
||||
letterSpacing: '0.02857em',
|
||||
boxShadow:
|
||||
'0px 3px 1px -2px rgba(0,0,0,0.2), 0px 2px 2px 0px rgba(0,0,0,0.14), 0px 1px 5px 0px rgba(0,0,0,0.12)',
|
||||
transition: 'all 0.2s cubic-bezier(0.4, 0, 0.2, 1)',
|
||||
},
|
||||
};
|
||||
}
|
||||
if (props.type === 'default') {
|
||||
return {
|
||||
root: {
|
||||
backgroundColor: '#ffffff',
|
||||
color: 'rgba(0, 0, 0, 0.87)',
|
||||
border: '1px solid rgba(0, 0, 0, 0.23)',
|
||||
fontWeight: 500,
|
||||
textTransform: 'uppercase' as const,
|
||||
letterSpacing: '0.02857em',
|
||||
transition: 'all 0.2s cubic-bezier(0.4, 0, 0.2, 1)',
|
||||
},
|
||||
};
|
||||
}
|
||||
if (props.danger) {
|
||||
return {
|
||||
root: {
|
||||
backgroundColor: '#d32f2f',
|
||||
color: '#ffffff',
|
||||
border: 'none',
|
||||
fontWeight: 500,
|
||||
textTransform: 'uppercase' as const,
|
||||
letterSpacing: '0.02857em',
|
||||
boxShadow:
|
||||
'0px 3px 1px -2px rgba(0,0,0,0.2), 0px 2px 2px 0px rgba(0,0,0,0.14), 0px 1px 5px 0px rgba(0,0,0,0.12)',
|
||||
},
|
||||
};
|
||||
}
|
||||
return {};
|
||||
},
|
||||
},
|
||||
input: {
|
||||
styles: (info) => {
|
||||
const { props } = info;
|
||||
const baseStyle = {
|
||||
root: {
|
||||
borderColor: 'rgba(0, 0, 0, 0.23)',
|
||||
transition: 'all 0.2s cubic-bezier(0.4, 0, 0.2, 1)',
|
||||
},
|
||||
input: {
|
||||
color: 'rgba(0, 0, 0, 0.87)',
|
||||
fontFamily: '"Roboto", "Helvetica", "Arial", sans-serif',
|
||||
},
|
||||
};
|
||||
if (props.status === 'error') {
|
||||
return {
|
||||
...baseStyle,
|
||||
root: {
|
||||
...baseStyle.root,
|
||||
borderColor: '#d32f2f',
|
||||
},
|
||||
};
|
||||
}
|
||||
return baseStyle;
|
||||
},
|
||||
},
|
||||
select: {
|
||||
styles: {
|
||||
root: {
|
||||
borderColor: 'rgba(0, 0, 0, 0.23)',
|
||||
fontFamily: '"Roboto", "Helvetica", "Arial", sans-serif',
|
||||
},
|
||||
popup: {
|
||||
root: {
|
||||
borderRadius: 4,
|
||||
boxShadow:
|
||||
'0px 5px 5px -3px rgba(0,0,0,0.2), 0px 8px 10px 1px rgba(0,0,0,0.14), 0px 3px 14px 2px rgba(0,0,0,0.12)',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
243
.dumi/pages/index/components/PreviewBanner/themes/shadcn.ts
Normal file
243
.dumi/pages/index/components/PreviewBanner/themes/shadcn.ts
Normal file
@@ -0,0 +1,243 @@
|
||||
import type { ConfigProviderProps, ThemeConfig } from 'antd';
|
||||
import { theme } from 'antd';
|
||||
|
||||
const { darkAlgorithm, defaultAlgorithm } = theme;
|
||||
|
||||
export const shadcn: ThemeConfig = {
|
||||
algorithm: defaultAlgorithm,
|
||||
token: {
|
||||
colorPrimary: '#262626',
|
||||
colorSuccess: '#22c55e',
|
||||
colorWarning: '#f97316',
|
||||
colorError: '#ef4444',
|
||||
colorInfo: '#262626',
|
||||
colorTextBase: '#262626',
|
||||
colorBgBase: '#ffffff',
|
||||
colorPrimaryBg: '#f5f5f5',
|
||||
colorPrimaryBgHover: '#e5e5e5',
|
||||
colorPrimaryBorder: '#d4d4d4',
|
||||
colorPrimaryBorderHover: '#a3a3a3',
|
||||
colorPrimaryHover: '#404040',
|
||||
colorPrimaryActive: '#171717',
|
||||
colorPrimaryText: '#262626',
|
||||
colorPrimaryTextHover: '#404040',
|
||||
colorPrimaryTextActive: '#171717',
|
||||
colorSuccessBg: '#f0fdf4',
|
||||
colorSuccessBgHover: '#dcfce7',
|
||||
colorSuccessBorder: '#bbf7d0',
|
||||
colorSuccessBorderHover: '#86efac',
|
||||
colorSuccessHover: '#16a34a',
|
||||
colorSuccessActive: '#15803d',
|
||||
colorSuccessText: '#16a34a',
|
||||
colorSuccessTextHover: '#16a34a',
|
||||
colorSuccessTextActive: '#15803d',
|
||||
colorWarningBg: '#fff7ed',
|
||||
colorWarningBgHover: '#fed7aa',
|
||||
colorWarningBorder: '#fdba74',
|
||||
colorWarningBorderHover: '#fb923c',
|
||||
colorWarningHover: '#ea580c',
|
||||
colorWarningActive: '#c2410c',
|
||||
colorWarningText: '#ea580c',
|
||||
colorWarningTextHover: '#ea580c',
|
||||
colorWarningTextActive: '#c2410c',
|
||||
colorErrorBg: '#fef2f2',
|
||||
colorErrorBgHover: '#fecaca',
|
||||
colorErrorBorder: '#fca5a5',
|
||||
colorErrorBorderHover: '#f87171',
|
||||
colorErrorHover: '#dc2626',
|
||||
colorErrorActive: '#b91c1c',
|
||||
colorErrorText: '#dc2626',
|
||||
colorErrorTextHover: '#dc2626',
|
||||
colorErrorTextActive: '#b91c1c',
|
||||
colorInfoBg: '#f5f5f5',
|
||||
colorInfoBgHover: '#e5e5e5',
|
||||
colorInfoBorder: '#d4d4d4',
|
||||
colorInfoBorderHover: '#a3a3a3',
|
||||
colorInfoHover: '#404040',
|
||||
colorInfoActive: '#171717',
|
||||
colorInfoText: '#262626',
|
||||
colorInfoTextHover: '#404040',
|
||||
colorInfoTextActive: '#171717',
|
||||
colorText: '#262626',
|
||||
colorTextSecondary: '#525252',
|
||||
colorTextTertiary: '#737373',
|
||||
colorTextQuaternary: '#a3a3a3',
|
||||
colorTextDisabled: '#a3a3a3',
|
||||
colorBgContainer: '#ffffff',
|
||||
colorBgElevated: '#ffffff',
|
||||
colorBgLayout: '#fafafa',
|
||||
colorBgSpotlight: 'rgba(38, 38, 38, 0.85)',
|
||||
colorBgMask: 'rgba(38, 38, 38, 0.45)',
|
||||
colorBorder: '#e5e5e5',
|
||||
colorBorderSecondary: '#f5f5f5',
|
||||
borderRadius: 10,
|
||||
borderRadiusXS: 2,
|
||||
borderRadiusSM: 6,
|
||||
borderRadiusLG: 14,
|
||||
padding: 16,
|
||||
paddingSM: 12,
|
||||
paddingLG: 24,
|
||||
margin: 16,
|
||||
marginSM: 12,
|
||||
marginLG: 24,
|
||||
boxShadow: '0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1)',
|
||||
boxShadowSecondary: '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)',
|
||||
},
|
||||
components: {
|
||||
Button: {
|
||||
primaryShadow: 'none',
|
||||
defaultShadow: 'none',
|
||||
dangerShadow: 'none',
|
||||
defaultBorderColor: '#e4e4e7',
|
||||
defaultColor: '#18181b',
|
||||
defaultBg: '#ffffff',
|
||||
defaultHoverBg: '#f4f4f5',
|
||||
defaultHoverBorderColor: '#d4d4d8',
|
||||
defaultHoverColor: '#18181b',
|
||||
defaultActiveBg: '#e4e4e7',
|
||||
defaultActiveBorderColor: '#d4d4d8',
|
||||
borderRadius: 6,
|
||||
},
|
||||
Input: {
|
||||
activeShadow: 'none',
|
||||
hoverBorderColor: '#a1a1aa',
|
||||
activeBorderColor: '#18181b',
|
||||
borderRadius: 6,
|
||||
},
|
||||
Select: {
|
||||
optionSelectedBg: '#f4f4f5',
|
||||
optionActiveBg: '#fafafa',
|
||||
optionSelectedFontWeight: 500,
|
||||
borderRadius: 6,
|
||||
},
|
||||
Alert: {
|
||||
borderRadiusLG: 8,
|
||||
},
|
||||
Modal: {
|
||||
borderRadiusLG: 12,
|
||||
},
|
||||
Progress: {
|
||||
defaultColor: '#18181b',
|
||||
remainingColor: '#f4f4f5',
|
||||
},
|
||||
Steps: {
|
||||
iconSize: 32,
|
||||
},
|
||||
Switch: {
|
||||
trackHeight: 24,
|
||||
trackMinWidth: 44,
|
||||
innerMinMargin: 4,
|
||||
innerMaxMargin: 24,
|
||||
},
|
||||
Checkbox: {
|
||||
borderRadiusSM: 4,
|
||||
},
|
||||
Slider: {
|
||||
trackBg: '#f4f4f5',
|
||||
trackHoverBg: '#e4e4e7',
|
||||
handleSize: 18,
|
||||
handleSizeHover: 20,
|
||||
railSize: 6,
|
||||
},
|
||||
ColorPicker: {
|
||||
borderRadius: 6,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const shadcnLight: ThemeConfig = {
|
||||
algorithm: defaultAlgorithm,
|
||||
token: shadcn.token,
|
||||
components: shadcn.components,
|
||||
};
|
||||
|
||||
export const shadcnDark: ThemeConfig = {
|
||||
algorithm: darkAlgorithm,
|
||||
token: {
|
||||
...shadcn.token,
|
||||
},
|
||||
components: {
|
||||
...shadcn.components,
|
||||
Message: {
|
||||
contentBg: '#212121',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export const shadcnComponentConfig: Partial<ConfigProviderProps> = {
|
||||
button: {
|
||||
styles: (info) => {
|
||||
const { props } = info;
|
||||
if (props.type === 'primary') {
|
||||
return {
|
||||
root: {
|
||||
backgroundColor: '#18181b',
|
||||
color: '#ffffff',
|
||||
border: '1px solid #18181b',
|
||||
fontWeight: 500,
|
||||
transition: 'all 0.2s cubic-bezier(0.4, 0, 0.2, 1)',
|
||||
},
|
||||
};
|
||||
}
|
||||
if (props.type === 'default') {
|
||||
return {
|
||||
root: {
|
||||
backgroundColor: '#ffffff',
|
||||
color: '#18181b',
|
||||
border: '1px solid #e4e4e7',
|
||||
fontWeight: 500,
|
||||
transition: 'all 0.2s cubic-bezier(0.4, 0, 0.2, 1)',
|
||||
},
|
||||
};
|
||||
}
|
||||
if (props.danger) {
|
||||
return {
|
||||
root: {
|
||||
backgroundColor: '#dc2626',
|
||||
color: '#ffffff',
|
||||
border: '1px solid #dc2626',
|
||||
fontWeight: 500,
|
||||
},
|
||||
};
|
||||
}
|
||||
return {};
|
||||
},
|
||||
},
|
||||
input: {
|
||||
styles: (info) => {
|
||||
const { props } = info;
|
||||
const baseStyle = {
|
||||
root: {
|
||||
borderColor: '#e4e4e7',
|
||||
transition: 'all 0.2s cubic-bezier(0.4, 0, 0.2, 1)',
|
||||
},
|
||||
input: {
|
||||
color: '#18181b',
|
||||
},
|
||||
};
|
||||
if (props.status === 'error') {
|
||||
return {
|
||||
...baseStyle,
|
||||
root: {
|
||||
...baseStyle.root,
|
||||
borderColor: '#dc2626',
|
||||
},
|
||||
};
|
||||
}
|
||||
return baseStyle;
|
||||
},
|
||||
},
|
||||
select: {
|
||||
styles: {
|
||||
root: {
|
||||
borderColor: '#e4e4e7',
|
||||
},
|
||||
popup: {
|
||||
root: {
|
||||
borderRadius: 8,
|
||||
boxShadow: '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1)',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useMemo, useState } from 'react';
|
||||
import { CSSMotionList } from '@rc-component/motion';
|
||||
import { createStyles, css } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { clsx } from 'clsx';
|
||||
|
||||
import { COLOR_IMAGES, getClosetColor } from './colorUtil';
|
||||
@@ -10,7 +10,7 @@ export interface BackgroundImageProps {
|
||||
isLight?: boolean;
|
||||
}
|
||||
|
||||
const useStyle = createStyles(({ cssVar }) => ({
|
||||
const styles = createStaticStyles(({ css, cssVar }) => ({
|
||||
image: css`
|
||||
transition: all ${cssVar.motionDurationSlow};
|
||||
position: absolute;
|
||||
@@ -29,7 +29,6 @@ const onHide = () => ({ opacity: 0 });
|
||||
|
||||
const BackgroundImage: React.FC<BackgroundImageProps> = ({ colorPrimary, isLight }) => {
|
||||
const activeColor = useMemo(() => getClosetColor(colorPrimary), [colorPrimary]);
|
||||
const { styles } = useStyle();
|
||||
|
||||
const [keyList, setKeyList] = useState<string[]>([]);
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { ColorPicker, Flex, Input } from 'antd';
|
||||
import type { ColorPickerProps, GetProp } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { generateColor } from 'antd/es/color-picker/util';
|
||||
import { clsx } from 'clsx';
|
||||
|
||||
@@ -9,7 +9,7 @@ import { PRESET_COLORS } from './colorUtil';
|
||||
|
||||
type Color = Extract<GetProp<ColorPickerProps, 'value'>, string | { cleared: any }>;
|
||||
|
||||
const useStyle = createStyles(({ cssVar, css }) => ({
|
||||
const styles = createStaticStyles(({ cssVar, css }) => ({
|
||||
color: css`
|
||||
width: calc(${cssVar.controlHeightLG} / 2);
|
||||
height: calc(${cssVar.controlHeightLG} / 2);
|
||||
@@ -69,8 +69,6 @@ const DebouncedColorPicker: React.FC<React.PropsWithChildren<ThemeColorPickerPro
|
||||
};
|
||||
|
||||
const ThemeColorPicker: React.FC<ThemeColorPickerProps> = ({ value, onChange, id }) => {
|
||||
const { styles } = useStyle();
|
||||
|
||||
const matchColors = React.useMemo(() => {
|
||||
const valueStr = generateColor(value || '').toRgbString();
|
||||
const colors = PRESET_COLORS.map((color) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as React from 'react';
|
||||
import { Flex } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { clsx } from 'clsx';
|
||||
|
||||
import useLocale from '../../../../hooks/useLocale';
|
||||
@@ -32,7 +32,7 @@ const locales = {
|
||||
},
|
||||
};
|
||||
|
||||
const useStyle = createStyles(({ cssVar, css }) => ({
|
||||
const styles = createStaticStyles(({ cssVar, css }) => ({
|
||||
themeCard: css`
|
||||
border-radius: ${cssVar.borderRadius};
|
||||
cursor: pointer;
|
||||
@@ -80,7 +80,6 @@ export interface ThemePickerProps {
|
||||
|
||||
const ThemePicker: React.FC<ThemePickerProps> = (props) => {
|
||||
const { value, id, onChange } = props;
|
||||
const { styles } = useStyle();
|
||||
const [locale] = useLocale(locales);
|
||||
return (
|
||||
<Flex gap="large" wrap>
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
theme,
|
||||
Typography,
|
||||
} from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { generateColor } from 'antd/es/color-picker/util';
|
||||
import { clsx } from 'clsx';
|
||||
import { useLocation } from 'dumi';
|
||||
@@ -92,7 +92,7 @@ const locales = {
|
||||
};
|
||||
|
||||
// ============================= Style =============================
|
||||
const useStyle = createStyles(({ cssVar, css, cx }) => {
|
||||
const styles = createStaticStyles(({ cssVar, css, cx }) => {
|
||||
const { carousel } = getCarouselStyle();
|
||||
const demo = css`
|
||||
overflow: hidden;
|
||||
@@ -345,7 +345,6 @@ function rgbToColorMatrix(color: string) {
|
||||
}
|
||||
|
||||
const Theme: React.FC = () => {
|
||||
const { styles } = useStyle();
|
||||
const [locale, lang] = useLocale(locales);
|
||||
const isZhCN = lang === 'cn';
|
||||
const { search } = useLocation();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { Suspense } from 'react';
|
||||
import { ConfigProvider, theme } from 'antd';
|
||||
import { createStyles, css } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
|
||||
import useLocale from '../../hooks/useLocale';
|
||||
import { DarkContext } from './../../hooks/useDark';
|
||||
@@ -12,7 +12,7 @@ const ComponentsList = React.lazy(() => import('./components/ComponentsList'));
|
||||
const DesignFramework = React.lazy(() => import('./components/DesignFramework'));
|
||||
const Theme = React.lazy(() => import('./components/Theme'));
|
||||
|
||||
const useStyle = createStyles(() => ({
|
||||
const classNames = createStaticStyles(({ css }) => ({
|
||||
image: css`
|
||||
position: absolute;
|
||||
inset-inline-start: 0;
|
||||
@@ -38,7 +38,6 @@ const locales = {
|
||||
|
||||
const Homepage: React.FC = () => {
|
||||
const [locale] = useLocale(locales);
|
||||
const { styles } = useStyle();
|
||||
const { token } = theme.useToken();
|
||||
|
||||
const isDark = React.use(DarkContext);
|
||||
@@ -50,13 +49,6 @@ const Homepage: React.FC = () => {
|
||||
</PreviewBanner>
|
||||
|
||||
<div>
|
||||
{/* 定制主题 */}
|
||||
<ConfigProvider theme={{ algorithm: theme.defaultAlgorithm }}>
|
||||
<Suspense fallback={null}>
|
||||
<Theme />
|
||||
</Suspense>
|
||||
</ConfigProvider>
|
||||
|
||||
{/* 组件列表 */}
|
||||
<Group
|
||||
background={token.colorBgElevated}
|
||||
@@ -70,15 +62,22 @@ const Homepage: React.FC = () => {
|
||||
</Suspense>
|
||||
</Group>
|
||||
|
||||
{/* 定制主题 */}
|
||||
<ConfigProvider theme={{ algorithm: theme.defaultAlgorithm }}>
|
||||
<Suspense fallback={null}>
|
||||
<Theme />
|
||||
</Suspense>
|
||||
</ConfigProvider>
|
||||
|
||||
{/* 设计语言 */}
|
||||
<Group
|
||||
title={locale.designTitle}
|
||||
description={locale.designDesc}
|
||||
background={isDark ? '#393F4A' : '#F5F8FF'}
|
||||
background={isDark ? '#393F4A' : token.colorBgContainer}
|
||||
decoration={
|
||||
<img
|
||||
draggable={false}
|
||||
className={styles.image}
|
||||
className={classNames.image}
|
||||
src="https://gw.alipayobjects.com/zos/bmw-prod/ba37a413-28e6-4be4-b1c5-01be1a0ebb1c.svg"
|
||||
alt="bg"
|
||||
/>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { Suspense } from 'react';
|
||||
import { App, Button, ConfigProvider, Skeleton, version } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { enUS, zhCN } from 'antd-token-previewer';
|
||||
import type { ThemeConfig } from 'antd/es/config-provider/context';
|
||||
import { Helmet } from 'dumi';
|
||||
@@ -9,7 +9,7 @@ import useLocale from '../../hooks/useLocale';
|
||||
|
||||
const ThemeEditor = React.lazy(() => import('antd-token-previewer/lib/ThemeEditor'));
|
||||
|
||||
const useStyle = createStyles(({ css }) => ({
|
||||
const classNames = createStaticStyles(({ css }) => ({
|
||||
editor: css`
|
||||
svg,
|
||||
img {
|
||||
@@ -49,7 +49,6 @@ const ANT_DESIGN_V5_THEME_EDITOR_THEME = `ant-design-v${antdMajor}-theme-editor-
|
||||
const CustomTheme: React.FC = () => {
|
||||
const { message } = App.useApp();
|
||||
const [locale, lang] = useLocale(locales);
|
||||
const { styles } = useStyle();
|
||||
|
||||
const [theme, setTheme] = React.useState<ThemeConfig>(() => {
|
||||
try {
|
||||
@@ -78,7 +77,7 @@ const CustomTheme: React.FC = () => {
|
||||
hideAdvancedSwitcher
|
||||
theme={{ name: 'Custom Theme', key: 'test', config: theme }}
|
||||
style={{ height: 'calc(100vh - 64px)' }}
|
||||
className={styles.editor}
|
||||
className={classNames.editor}
|
||||
onThemeChange={(newTheme) => {
|
||||
setTheme(newTheme.config);
|
||||
}}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React from 'react';
|
||||
import { SoundOutlined } from '@ant-design/icons';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
|
||||
const useStyle = createStyles(({ css, cssVar }) => {
|
||||
const styles = createStaticStyles(({ css, cssVar }) => {
|
||||
return {
|
||||
playBtn: css`
|
||||
display: inline-flex;
|
||||
@@ -30,7 +30,6 @@ interface AudioProps {
|
||||
}
|
||||
|
||||
const AudioControl: React.FC<React.PropsWithChildren<AudioProps>> = ({ id, children }) => {
|
||||
const { styles } = useStyle();
|
||||
const onClick: React.MouseEventHandler<HTMLAnchorElement> = () => {
|
||||
const audio = document.querySelector<HTMLAudioElement>(`#${id}`);
|
||||
audio?.play();
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { memo, useMemo, useRef, useState } from 'react';
|
||||
import type { CSSProperties } from 'react';
|
||||
import { SearchOutlined } from '@ant-design/icons';
|
||||
import { Affix, Card, Col, Divider, Flex, Input, Row, Tag, Typography } from 'antd';
|
||||
import { createStyles, useTheme } from 'antd-style';
|
||||
import { createStaticStyles, useTheme } from 'antd-style';
|
||||
import { useIntl, useLocation, useSidebarData } from 'dumi';
|
||||
import debounce from 'lodash/debounce';
|
||||
import scrollIntoView from 'scroll-into-view-if-needed';
|
||||
@@ -12,7 +12,7 @@ import SiteContext from '../../slots/SiteContext';
|
||||
import type { Component } from './ProComponentsList';
|
||||
import proComponentsList from './ProComponentsList';
|
||||
|
||||
const useStyle = createStyles(({ cssVar, css }) => ({
|
||||
const styles = createStaticStyles(({ cssVar, css }) => ({
|
||||
componentsOverviewGroupTitle: css`
|
||||
margin-bottom: ${cssVar.marginLG} !important;
|
||||
`,
|
||||
@@ -78,7 +78,6 @@ const reportSearch = debounce<(value: string) => void>((value) => {
|
||||
const { Title } = Typography;
|
||||
|
||||
const Overview: React.FC = () => {
|
||||
const { styles } = useStyle();
|
||||
const { isDark } = React.use(SiteContext);
|
||||
|
||||
const data = useSidebarData();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { useMemo, useState } from 'react';
|
||||
import { LinkOutlined, QuestionCircleOutlined, RightOutlined } from '@ant-design/icons';
|
||||
import { ConfigProvider, Flex, Popover, Table, Typography } from 'antd';
|
||||
import { createStyles, css, useTheme } from 'antd-style';
|
||||
import { createStaticStyles, css, useTheme } from 'antd-style';
|
||||
import { getDesignToken } from 'antd-token-previewer';
|
||||
import tokenMeta from 'antd/es/version/token-meta.json';
|
||||
import tokenData from 'antd/es/version/token.json';
|
||||
@@ -53,7 +53,7 @@ const locales = {
|
||||
},
|
||||
};
|
||||
|
||||
const useStyle = createStyles(({ cssVar }) => ({
|
||||
const styles = createStaticStyles(({ cssVar }) => ({
|
||||
tableTitle: css`
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
@@ -104,8 +104,6 @@ const SubTokenTable: React.FC<SubTokenTableProps> = (props) => {
|
||||
|
||||
const [open, setOpen] = useState<boolean>(defaultOpen ?? process.env.NODE_ENV !== 'production');
|
||||
|
||||
const { styles } = useStyle();
|
||||
|
||||
if (!tokens.length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import * as React from 'react';
|
||||
import { App } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { useIntl } from 'dumi';
|
||||
|
||||
import CopyableIcon from './CopyableIcon';
|
||||
import type { CategoriesKeys } from './fields';
|
||||
import type { ThemeType } from './IconSearch';
|
||||
|
||||
const useStyle = createStyles(({ css, cssVar }) => ({
|
||||
const styles = createStaticStyles(({ css, cssVar }) => ({
|
||||
anticonsList: css`
|
||||
margin: ${cssVar.margin} 0;
|
||||
overflow: hidden;
|
||||
@@ -36,7 +36,6 @@ interface CategoryProps {
|
||||
const Category: React.FC<CategoryProps> = (props) => {
|
||||
const { message } = App.useApp();
|
||||
const { icons, title, newIcons, theme } = props;
|
||||
const { styles } = useStyle();
|
||||
const intl = useIntl();
|
||||
const [justCopied, setJustCopied] = React.useState<string | null>(null);
|
||||
const copyId = React.useRef<ReturnType<typeof setTimeout> | null>(null);
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { CSSProperties } from 'react';
|
||||
import React, { useCallback, useMemo, useState } from 'react';
|
||||
import Icon, * as AntdIcons from '@ant-design/icons';
|
||||
import { Affix, Empty, Input, Segmented } from 'antd';
|
||||
import { createStyles, useTheme } from 'antd-style';
|
||||
import { createStaticStyles, useTheme } from 'antd-style';
|
||||
import type { SegmentedOptions } from 'antd/es/segmented';
|
||||
import { useIntl } from 'dumi';
|
||||
import debounce from 'lodash/debounce';
|
||||
@@ -22,7 +22,7 @@ export enum ThemeType {
|
||||
|
||||
const allIcons: { [key: string]: any } = AntdIcons;
|
||||
|
||||
const useStyle = createStyles(({ css, cssVar }) => ({
|
||||
const styles = createStaticStyles(({ css, cssVar }) => ({
|
||||
iconSearchAffix: css`
|
||||
display: flex;
|
||||
transition: all ${cssVar.motionDurationSlow};
|
||||
@@ -39,7 +39,6 @@ const NEW_ICON_NAMES: ReadonlyArray<string> = [];
|
||||
|
||||
const IconSearch: React.FC = () => {
|
||||
const intl = useIntl();
|
||||
const { styles } = useStyle();
|
||||
const [displayState, setDisplayState] = useState<IconSearchState>({
|
||||
searchKey: '',
|
||||
theme: ThemeType.Outlined,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import React, { Suspense } from 'react';
|
||||
import { Skeleton } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
|
||||
const IconSearch = React.lazy(() => import('./IconSearch'));
|
||||
|
||||
const useStyle = createStyles(({ css, cssVar }) => ({
|
||||
const styles = createStaticStyles(({ css, cssVar }) => ({
|
||||
searchWrapper: css`
|
||||
display: flex;
|
||||
gap: ${cssVar.padding};
|
||||
@@ -34,8 +34,6 @@ const useStyle = createStyles(({ css, cssVar }) => ({
|
||||
}));
|
||||
|
||||
const IconSearchFallback: React.FC = () => {
|
||||
const { styles } = useStyle();
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className={styles.searchWrapper}>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { createStyles, css } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { clsx } from 'clsx';
|
||||
|
||||
interface IconProps {
|
||||
@@ -7,7 +7,7 @@ interface IconProps {
|
||||
style?: React.CSSProperties;
|
||||
}
|
||||
|
||||
const useStyle = createStyles(() => ({
|
||||
const classNames = createStaticStyles(({ css }) => ({
|
||||
iconWrap: css`
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
@@ -19,9 +19,8 @@ const useStyle = createStyles(() => ({
|
||||
|
||||
const BunIcon: React.FC<IconProps> = (props) => {
|
||||
const { className, style } = props;
|
||||
const { styles } = useStyle();
|
||||
return (
|
||||
<span className={clsx(styles.iconWrap, className)} style={style}>
|
||||
<span className={clsx(classNames.iconWrap, className)} style={style}>
|
||||
<svg id="Bun" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 80 70" width="1em" height="1em">
|
||||
<title>Bun Logo</title>
|
||||
<path
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { createStyles, css } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { clsx } from 'clsx';
|
||||
|
||||
interface IconProps {
|
||||
@@ -7,7 +7,7 @@ interface IconProps {
|
||||
style?: React.CSSProperties;
|
||||
}
|
||||
|
||||
const useStyle = createStyles(() => ({
|
||||
const classNames = createStaticStyles(({ css }) => ({
|
||||
iconWrap: css`
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
@@ -19,9 +19,8 @@ const useStyle = createStyles(() => ({
|
||||
|
||||
const NpmIcon: React.FC<IconProps> = (props) => {
|
||||
const { className, style } = props;
|
||||
const { styles } = useStyle();
|
||||
return (
|
||||
<span className={clsx(styles.iconWrap, className)} style={style}>
|
||||
<span className={clsx(classNames.iconWrap, className)} style={style}>
|
||||
<svg
|
||||
fill="#E53E3E"
|
||||
focusable="false"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { createStyles, css } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { clsx } from 'clsx';
|
||||
|
||||
interface IconProps {
|
||||
@@ -7,7 +7,7 @@ interface IconProps {
|
||||
style?: React.CSSProperties;
|
||||
}
|
||||
|
||||
const useStyle = createStyles(() => ({
|
||||
const classNames = createStaticStyles(({ css }) => ({
|
||||
iconWrap: css`
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
@@ -19,9 +19,8 @@ const useStyle = createStyles(() => ({
|
||||
|
||||
const PnpmIcon: React.FC<IconProps> = (props) => {
|
||||
const { className, style } = props;
|
||||
const { styles } = useStyle();
|
||||
return (
|
||||
<span className={clsx(styles.iconWrap, className)} style={style}>
|
||||
<span className={clsx(classNames.iconWrap, className)} style={style}>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="#F69220"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { createStyles, css } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { clsx } from 'clsx';
|
||||
|
||||
interface IconProps {
|
||||
@@ -7,7 +7,7 @@ interface IconProps {
|
||||
style?: React.CSSProperties;
|
||||
}
|
||||
|
||||
const useStyle = createStyles(() => ({
|
||||
const classNames = createStaticStyles(({ css }) => ({
|
||||
iconWrap: css`
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
@@ -19,9 +19,8 @@ const useStyle = createStyles(() => ({
|
||||
|
||||
const YarnIcon: React.FC<IconProps> = (props) => {
|
||||
const { className, style } = props;
|
||||
const { styles } = useStyle();
|
||||
return (
|
||||
<span className={clsx(styles.iconWrap, className)} style={style}>
|
||||
<span className={clsx(classNames.iconWrap, className)} style={style}>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
fill="#2C8EBB"
|
||||
|
||||
@@ -2,7 +2,7 @@ import React, { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { UpOutlined } from '@ant-design/icons';
|
||||
import type { MenuProps } from 'antd';
|
||||
import { Badge, Tag, Tooltip } from 'antd';
|
||||
import { createStyles, css } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { clsx } from 'clsx';
|
||||
import { FormattedMessage, useLiveDemo, useSiteData } from 'dumi';
|
||||
import { major, minVersion } from 'semver';
|
||||
@@ -17,7 +17,7 @@ import DemoContext from '../../slots/DemoContext';
|
||||
import { isOfficialHost } from '../../utils';
|
||||
import Actions from './Actions';
|
||||
|
||||
const useStyle = createStyles(({ cssVar }) => {
|
||||
const styles = createStaticStyles(({ cssVar, css }) => {
|
||||
return {
|
||||
codeHideBtn: css`
|
||||
position: sticky;
|
||||
@@ -68,7 +68,6 @@ const CodePreviewer: React.FC<AntdPreviewerProps> = (props) => {
|
||||
const { pkg } = useSiteData();
|
||||
|
||||
const location = useLocation();
|
||||
const { styles } = useStyle();
|
||||
|
||||
const entryName = 'index.tsx';
|
||||
const entryCode = asset.dependencies[entryName].value;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React from 'react';
|
||||
import { Skeleton } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
|
||||
const useStyle = createStyles(({ css, cssVar }) => ({
|
||||
const styles = createStaticStyles(({ css, cssVar }) => ({
|
||||
skeletonWrapper: css`
|
||||
width: 100% !important;
|
||||
height: 250px;
|
||||
@@ -12,7 +12,6 @@ const useStyle = createStyles(({ css, cssVar }) => ({
|
||||
}));
|
||||
|
||||
const DemoFallback = () => {
|
||||
const { styles } = useStyle();
|
||||
return (
|
||||
<Skeleton.Node
|
||||
active
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { FC } from 'react';
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import { CheckOutlined, SketchOutlined } from '@ant-design/icons';
|
||||
import { App } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import copy from '../../../../components/_util/copy';
|
||||
import { nodeToGroup } from 'html2sketch';
|
||||
|
||||
@@ -22,7 +22,7 @@ const locales = {
|
||||
},
|
||||
};
|
||||
|
||||
const useStyle = createStyles(({ cssVar, css }) => ({
|
||||
const styles = createStaticStyles(({ cssVar, css }) => ({
|
||||
wrapper: css`
|
||||
position: relative;
|
||||
border: 1px solid ${cssVar.colorBorderSecondary};
|
||||
@@ -72,7 +72,6 @@ const useStyle = createStyles(({ cssVar, css }) => ({
|
||||
}));
|
||||
|
||||
const DesignPreviewer: FC<AntdPreviewerProps> = ({ children, title, description, tip, asset }) => {
|
||||
const { styles } = useStyle();
|
||||
const demoRef = useRef<HTMLDivElement>(null);
|
||||
const [copied, setCopied] = React.useState<boolean>(false);
|
||||
const { message } = App.useApp();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as React from 'react';
|
||||
import { BugOutlined } from '@ant-design/icons';
|
||||
import { Button, Flex, Popover, theme } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles, cx } from 'antd-style';
|
||||
import dayjs from 'dayjs';
|
||||
import type { Dayjs } from 'dayjs';
|
||||
|
||||
@@ -33,7 +33,7 @@ const locales = {
|
||||
},
|
||||
};
|
||||
|
||||
const useStyle = createStyles(({ cssVar, css }) => ({
|
||||
const styles = createStaticStyles(({ cssVar, css }) => ({
|
||||
container: css`
|
||||
margin-block: ${cssVar.margin};
|
||||
padding: ${cssVar.padding};
|
||||
@@ -49,8 +49,6 @@ const useStyle = createStyles(({ cssVar, css }) => ({
|
||||
const RefinedChangelog: React.FC<React.PropsWithChildren<RefinedChangelogProps>> = (props) => {
|
||||
const { version, date, children } = props;
|
||||
|
||||
const { styles, cx } = useStyle();
|
||||
|
||||
const memoizedValue = React.useMemo<ContextProps>(() => {
|
||||
const realVersion = version || '0.0.0';
|
||||
const bugVersionInfo = matchDeprecated(realVersion);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { Suspense } from 'react';
|
||||
import type { SandpackSetup } from '@codesandbox/sandpack-react';
|
||||
import { Skeleton } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { useSearchParams } from 'dumi';
|
||||
|
||||
import { version } from '../../../../package.json';
|
||||
@@ -17,7 +17,7 @@ const root = createRoot(document.getElementById("root"));
|
||||
root.render(<App />);
|
||||
`;
|
||||
|
||||
const useStyle = createStyles(({ css, cssVar }) => ({
|
||||
const styles = createStaticStyles(({ css, cssVar }) => ({
|
||||
fallback: css`
|
||||
width: 100%;
|
||||
> * {
|
||||
@@ -32,7 +32,6 @@ const useStyle = createStyles(({ css, cssVar }) => ({
|
||||
}));
|
||||
|
||||
const SandpackFallback: React.FC = () => {
|
||||
const { styles } = useStyle();
|
||||
return (
|
||||
<div className={styles.fallback}>
|
||||
<Skeleton.Node active style={{ height: 500, width: '100%' }}>
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
import React from 'react';
|
||||
import { FastColor } from '@ant-design/fast-color';
|
||||
import { Flex, theme } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import tokenMeta from 'antd/es/version/token-meta.json';
|
||||
import { clsx } from 'clsx';
|
||||
|
||||
import useLocale from '../../../hooks/useLocale';
|
||||
|
||||
const useStyle = createStyles(({ cssVar, css }) => {
|
||||
const styles = createStaticStyles(({ cssVar, css }) => {
|
||||
const height = cssVar.controlHeightLG;
|
||||
const dotSize = height / 5;
|
||||
|
||||
@@ -63,7 +63,6 @@ interface ColorCircleProps {
|
||||
}
|
||||
|
||||
const ColorCircle: React.FC<ColorCircleProps> = ({ color }) => {
|
||||
const { styles } = useStyle();
|
||||
return (
|
||||
<Flex align="center" gap={4}>
|
||||
<div className={styles.dot} style={{ background: color }} />
|
||||
@@ -79,7 +78,6 @@ export interface TokenCompareProps {
|
||||
const TokenCompare: React.FC<TokenCompareProps> = (props) => {
|
||||
const { tokenNames = '' } = props;
|
||||
const [, lang] = useLocale();
|
||||
const { styles } = useStyle();
|
||||
|
||||
const tokenList = React.useMemo(() => {
|
||||
const list = tokenNames.split('|');
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import React from 'react';
|
||||
import { PauseCircleFilled, PlayCircleFilled } from '@ant-design/icons';
|
||||
import { createStyles, css } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { clsx } from 'clsx';
|
||||
|
||||
const useStyles = createStyles(({ cx, cssVar }) => {
|
||||
const styles = createStaticStyles(({ css, cx, cssVar }) => {
|
||||
const play = css`
|
||||
position: absolute;
|
||||
inset-inline-end: ${cssVar.paddingLG};
|
||||
@@ -45,7 +45,6 @@ const VideoPlayer: React.FC<React.HtmlHTMLAttributes<HTMLVideoElement>> = ({
|
||||
className,
|
||||
...restProps
|
||||
}) => {
|
||||
const { styles } = useStyles();
|
||||
const videoRef = React.useRef<HTMLVideoElement>(null);
|
||||
const [playing, setPlaying] = React.useState(false);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useEffect, useRef } from 'react';
|
||||
import { createStyles, css } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { useRouteMeta } from 'dumi';
|
||||
|
||||
import useLocale from '../../../hooks/useLocale';
|
||||
@@ -17,7 +17,7 @@ export interface BehaviorMapProps {
|
||||
data: BehaviorMapItem;
|
||||
}
|
||||
|
||||
const useStyle = createStyles(({ cssVar }) => ({
|
||||
const styles = createStaticStyles(({ css, cssVar }) => ({
|
||||
container: css`
|
||||
width: 100%;
|
||||
min-height: 600px;
|
||||
@@ -100,7 +100,6 @@ const locales = {
|
||||
|
||||
const BehaviorMap: React.FC<BehaviorMapProps> = ({ data }) => {
|
||||
const chartRef = useRef<HTMLDivElement>(null);
|
||||
const { styles } = useStyle();
|
||||
const [locale] = useLocale(locales);
|
||||
const meta = useRouteMeta();
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import type { FC } from 'react';
|
||||
import React, { Suspense } from 'react';
|
||||
import { Skeleton } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
|
||||
import useLocale from '../../../hooks/useLocale';
|
||||
import type { BehaviorMapProps } from './BehaviorMap';
|
||||
|
||||
const InternalBehaviorMap = React.lazy(() => import('./BehaviorMap'));
|
||||
|
||||
const useStyle = createStyles(({ cssVar, css }) => ({
|
||||
const styles = createStaticStyles(({ cssVar, css }) => ({
|
||||
fallback: css`
|
||||
width: 100%;
|
||||
> * {
|
||||
@@ -32,7 +32,6 @@ const locales = {
|
||||
};
|
||||
|
||||
const BehaviorMapFallback: React.FC = () => {
|
||||
const { styles } = useStyle();
|
||||
const [locale] = useLocale(locales);
|
||||
return (
|
||||
<div className={styles.fallback}>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
|
||||
const useStyle = createStyles(({ cssVar, css }) => ({
|
||||
const styles = createStaticStyles(({ cssVar, css }) => ({
|
||||
browserMockup: css`
|
||||
position: relative;
|
||||
border-top: 2em solid rgba(230, 230, 230, 0.7);
|
||||
@@ -49,7 +49,6 @@ const useStyle = createStyles(({ cssVar, css }) => ({
|
||||
}));
|
||||
|
||||
const BrowserFrame: React.FC<React.PropsWithChildren> = ({ children }) => {
|
||||
const { styles } = useStyle();
|
||||
return <div className={styles.browserMockup}>{children}</div>;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { ComponentProps, FC } from 'react';
|
||||
import React from 'react';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import SourceCodeEditor from 'dumi/theme-default/slots/SourceCodeEditor';
|
||||
|
||||
import LiveError from '../slots/LiveError';
|
||||
|
||||
const useStyle = createStyles(({ cssVar, css }) => {
|
||||
const styles = createStaticStyles(({ cssVar, css }) => {
|
||||
return {
|
||||
editor: css`
|
||||
// override dumi editor styles
|
||||
@@ -54,7 +54,6 @@ const LiveCode: FC<
|
||||
error: Error | null;
|
||||
} & Pick<ComponentProps<typeof SourceCodeEditor>, 'lang' | 'initialValue' | 'onChange'>
|
||||
> = (props) => {
|
||||
const { styles } = useStyle();
|
||||
return (
|
||||
<div className={styles.editor}>
|
||||
<SourceCodeEditor
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import React from 'react';
|
||||
import { StyleProvider } from '@ant-design/cssinjs';
|
||||
import { ConfigProvider, Flex, Skeleton, Spin } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { useLocation } from 'dumi';
|
||||
|
||||
import { Common } from './styles';
|
||||
|
||||
const useStyle = createStyles(({ css, cssVar }) => {
|
||||
const styles = createStaticStyles(({ css, cssVar }) => {
|
||||
return {
|
||||
skeletonWrapper: css`
|
||||
width: 100%;
|
||||
@@ -27,8 +27,6 @@ const useStyle = createStyles(({ css, cssVar }) => {
|
||||
const Loading: React.FC = () => {
|
||||
const { pathname } = useLocation();
|
||||
|
||||
const { styles } = useStyle();
|
||||
|
||||
let loadingNode: React.ReactNode = null;
|
||||
|
||||
if (
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import * as React from 'react';
|
||||
import { createStyles, css } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { clsx } from 'clsx';
|
||||
|
||||
const useStyle = createStyles(({ cssVar, cx }) => {
|
||||
const styles = createStaticStyles(({ cssVar, css, cx }) => {
|
||||
const duration = cssVar.motionDurationSlow;
|
||||
|
||||
const marker = css`
|
||||
@@ -55,8 +55,6 @@ export interface MarkerProps {
|
||||
}
|
||||
|
||||
const Marker = React.memo<MarkerProps>((props) => {
|
||||
const { styles } = useStyle();
|
||||
|
||||
const { rect, primary, ...restProps } = props;
|
||||
|
||||
const rectRef = React.useRef(rect);
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import { InfoCircleOutlined, PushpinOutlined } from '@ant-design/icons';
|
||||
import { get, set } from '@rc-component/util';
|
||||
import { Button, Col, ConfigProvider, Flex, Popover, Row, Tag, theme, Typography } from 'antd';
|
||||
import { createStyles, css } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { clsx } from 'clsx';
|
||||
import Prism from 'prismjs';
|
||||
|
||||
@@ -12,7 +12,7 @@ export interface SemanticPreviewInjectionProps {
|
||||
classNames?: Record<string, string>;
|
||||
}
|
||||
|
||||
const useStyle = createStyles(({ cssVar }) => ({
|
||||
const styles = createStaticStyles(({ css, cssVar }) => ({
|
||||
container: css`
|
||||
position: relative;
|
||||
z-index: 0;
|
||||
@@ -155,8 +155,6 @@ const SemanticPreview: React.FC<SemanticPreviewProps> = (props) => {
|
||||
|
||||
const mergedSemantic = pinSemantic || hoverSemantic;
|
||||
|
||||
const { styles } = useStyle();
|
||||
|
||||
const hoveredSemanticClassNames = React.useMemo(() => {
|
||||
if (!mergedSemantic) {
|
||||
return semanticClassNames;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
|
||||
import useLocale from '../../../hooks/useLocale';
|
||||
import EN from './en-US.md';
|
||||
@@ -7,7 +7,7 @@ import CN from './zh-CN.md';
|
||||
|
||||
const changeLog = { cn: CN, en: EN };
|
||||
|
||||
const useStyle = createStyles(({ css }) => ({
|
||||
const classNames = createStaticStyles(({ css }) => ({
|
||||
container: css`
|
||||
max-height: max(62vh, 500px);
|
||||
overflow-y: scroll;
|
||||
@@ -25,13 +25,11 @@ const useStyle = createStyles(({ css }) => ({
|
||||
const ChangeLog = () => {
|
||||
const [, lang] = useLocale();
|
||||
|
||||
const { styles } = useStyle();
|
||||
|
||||
const validatedLanguage = Object.keys(changeLog).includes(lang) ? lang : 'en';
|
||||
const C = changeLog[validatedLanguage];
|
||||
|
||||
return (
|
||||
<div className={styles.container}>
|
||||
<div className={classNames.container}>
|
||||
<C />
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import type { PropsWithChildren } from 'react';
|
||||
import React from 'react';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { useSearchParams } from 'dumi';
|
||||
|
||||
import CommonHelmet from '../../common/CommonHelmet';
|
||||
import Content from '../../slots/Content';
|
||||
import Sidebar from '../../slots/Sidebar';
|
||||
|
||||
const useStyle = createStyles(({ css, cssVar }) => ({
|
||||
const styles = createStaticStyles(({ css, cssVar }) => ({
|
||||
main: css`
|
||||
display: flex;
|
||||
margin-top: ${cssVar.marginXL};
|
||||
@@ -15,7 +15,6 @@ const useStyle = createStyles(({ css, cssVar }) => ({
|
||||
}));
|
||||
|
||||
const SidebarLayout: React.FC<PropsWithChildren> = ({ children }) => {
|
||||
const { styles } = useStyle();
|
||||
const [searchParams] = useSearchParams();
|
||||
const hideLayout = searchParams.get('layout') === 'false';
|
||||
return (
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { RightOutlined, YuqueOutlined, ZhihuOutlined } from '@ant-design/icons';
|
||||
import { Button, Card, Divider } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { clsx } from 'clsx';
|
||||
|
||||
import useLocale from '../../../hooks/useLocale';
|
||||
@@ -10,7 +10,7 @@ import JuejinIcon from '../../../theme/icons/JuejinIcon';
|
||||
const ANTD_IMG_URL =
|
||||
'https://picx.zhimg.com/v2-3b2bca09c2771e7a82a81562e806be4d.jpg?source=d16d100b';
|
||||
|
||||
const useStyle = createStyles(({ cssVar, css }) => ({
|
||||
const styles = createStaticStyles(({ cssVar, css }) => ({
|
||||
card: css`
|
||||
width: 100%;
|
||||
margin: calc(${cssVar.marginMD} * 2) 0;
|
||||
@@ -113,19 +113,17 @@ interface Props {
|
||||
const ColumnCard: React.FC<Props> = ({ zhihuLink, yuqueLink, juejinLink }) => {
|
||||
const [locale] = useLocale(locales);
|
||||
const {
|
||||
styles: {
|
||||
card,
|
||||
bigTitle,
|
||||
cardBody,
|
||||
leftCard,
|
||||
title,
|
||||
subTitle,
|
||||
logo,
|
||||
arrowIcon,
|
||||
zlBtn,
|
||||
discussLogo,
|
||||
},
|
||||
} = useStyle();
|
||||
card,
|
||||
bigTitle,
|
||||
cardBody,
|
||||
leftCard,
|
||||
title,
|
||||
subTitle,
|
||||
logo,
|
||||
arrowIcon,
|
||||
zlBtn,
|
||||
discussLogo,
|
||||
} = styles;
|
||||
if (!zhihuLink && !yuqueLink && !juejinLink) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import React, { Suspense } from 'react';
|
||||
import ContributorsList from '@qixian.cs/github-contributors-list';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { clsx } from 'clsx';
|
||||
import { useIntl } from 'dumi';
|
||||
|
||||
import SiteContext from '../SiteContext';
|
||||
import ContributorAvatar from './ContributorAvatar';
|
||||
|
||||
const useStyle = createStyles(({ cssVar, css }) => ({
|
||||
const styles = createStaticStyles(({ cssVar, css }) => ({
|
||||
listMobile: css`
|
||||
margin: 1em 0 !important;
|
||||
`,
|
||||
@@ -48,7 +48,6 @@ const blockList = [
|
||||
|
||||
const Contributors: React.FC<ContributorsProps> = ({ filename }) => {
|
||||
const { formatMessage } = useIntl();
|
||||
const { styles } = useStyle();
|
||||
const { isMobile } = React.use(SiteContext);
|
||||
|
||||
if (!filename) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as React from 'react';
|
||||
import { removeCSS, updateCSS } from '@rc-component/util/lib/Dom/dynamicCSS';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
|
||||
import useLocale from '../../../hooks/useLocale';
|
||||
|
||||
@@ -20,7 +20,7 @@ const locales = {
|
||||
},
|
||||
};
|
||||
|
||||
const useStyle = createStyles(({ css, cssVar }) => ({
|
||||
const styles = createStaticStyles(({ css, cssVar }) => ({
|
||||
container: css`
|
||||
position: fixed;
|
||||
inset-inline-start: 0;
|
||||
@@ -80,8 +80,6 @@ const InfoNewVersion: React.FC = () => {
|
||||
removeCSS(whereCls);
|
||||
}, []);
|
||||
|
||||
const { styles } = useStyle();
|
||||
|
||||
if (supportWhere) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { omit } from '@rc-component/util';
|
||||
import { Button, Tooltip } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { clsx } from 'clsx';
|
||||
|
||||
export interface SwitchBtnProps {
|
||||
@@ -18,7 +18,7 @@ export interface SwitchBtnProps {
|
||||
|
||||
const BASE_SIZE = '1.2em';
|
||||
|
||||
const useStyle = createStyles(({ cssVar, css }) => {
|
||||
const styles = createStaticStyles(({ cssVar, css }) => {
|
||||
return {
|
||||
btn: css`
|
||||
width: ${cssVar.controlHeight};
|
||||
@@ -65,9 +65,7 @@ const useStyle = createStyles(({ cssVar, css }) => {
|
||||
const SwitchBtn: React.FC<SwitchBtnProps> = (props) => {
|
||||
const { label1, label2, tooltip1, tooltip2, value, pure, onClick, ...rest } = props;
|
||||
|
||||
const {
|
||||
styles: { btn, innerDiv, labelStyle, label1Style, label2Style },
|
||||
} = useStyle();
|
||||
const { btn, innerDiv, labelStyle, label1Style, label2Style } = styles;
|
||||
|
||||
const node = (
|
||||
<Button
|
||||
|
||||
@@ -4,16 +4,16 @@ import { isValidElement } from 'react';
|
||||
import type { TooltipProps } from '../tooltip';
|
||||
import isNonNullable from './isNonNullable';
|
||||
|
||||
const convertToTooltipProps = <P extends TooltipProps>(tooltip: P | ReactNode) => {
|
||||
const convertToTooltipProps = <P extends TooltipProps>(tooltip: P | ReactNode, context?: P) => {
|
||||
if (!isNonNullable(tooltip)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (typeof tooltip === 'object' && !isValidElement(tooltip)) {
|
||||
return tooltip as P;
|
||||
return { ...context, ...tooltip } as P;
|
||||
}
|
||||
|
||||
return { title: tooltip } as P;
|
||||
return { ...context, title: tooltip } as P;
|
||||
};
|
||||
|
||||
export default convertToTooltipProps;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import React from 'react';
|
||||
import { Alert, Button, Flex } from 'antd';
|
||||
import type { AlertProps } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
|
||||
const useStyle = createStyles(({ css }) => ({
|
||||
const classNames = createStaticStyles(({ css }) => ({
|
||||
root: css`
|
||||
border: 2px dashed #ccc;
|
||||
border-radius: 8px;
|
||||
@@ -40,12 +40,10 @@ const styleFn: AlertProps['styles'] = ({ props: { type } }) => {
|
||||
};
|
||||
|
||||
const App: React.FC = () => {
|
||||
const { styles } = useStyle();
|
||||
|
||||
const alertSharedProps: AlertProps = {
|
||||
showIcon: true,
|
||||
classNames: {
|
||||
root: styles.root,
|
||||
root: classNames.root,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import React from 'react';
|
||||
import { AutoComplete, Flex } from 'antd';
|
||||
import type { AutoCompleteProps } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
|
||||
const useStyle = createStyles(({ css }) => ({
|
||||
const classNames = createStaticStyles(({ css }) => ({
|
||||
root: css`
|
||||
border-radius: 4px;
|
||||
`,
|
||||
@@ -39,7 +39,6 @@ const options: AutoCompleteProps['options'] = [
|
||||
];
|
||||
|
||||
const App: React.FC = () => {
|
||||
const { styles: classNames } = useStyle();
|
||||
const sharedProps: AutoCompleteProps = {
|
||||
options,
|
||||
classNames: {
|
||||
|
||||
@@ -18,7 +18,7 @@ export interface AvatarProps {
|
||||
/** Shape of avatar, options: `circle`, `square` */
|
||||
shape?: 'circle' | 'square';
|
||||
/*
|
||||
* Size of avatar, options: `large`, `small`, `default`
|
||||
* Size of avatar, options: `large`, `medium`, `small`
|
||||
* or a custom number size
|
||||
* */
|
||||
size?: AvatarSize;
|
||||
@@ -111,7 +111,7 @@ const Avatar = React.forwardRef<HTMLSpanElement, AvatarProps>((props, ref) => {
|
||||
}
|
||||
};
|
||||
|
||||
const size = useSize((ctxSize) => customSize ?? avatarCtx?.size ?? ctxSize ?? 'default');
|
||||
const size = useSize((ctxSize) => customSize ?? avatarCtx?.size ?? ctxSize ?? 'medium');
|
||||
|
||||
const needResponsive = Object.keys(typeof size === 'object' ? size || {} : {}).some((key) =>
|
||||
['xs', 'sm', 'md', 'lg', 'xl', 'xxl'].includes(key),
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
import * as React from 'react';
|
||||
|
||||
import type { ScreenSizeMap } from '../_util/responsiveObserver';
|
||||
import type { SizeType } from '../config-provider/SizeContext';
|
||||
|
||||
export type AvatarSize = 'large' | 'small' | 'default' | number | ScreenSizeMap;
|
||||
/**
|
||||
* 'default' is deprecated and will be removed in v7, please use `medium` instead.
|
||||
*/
|
||||
export type AvatarSize = SizeType | 'default' | number | ScreenSizeMap;
|
||||
|
||||
export interface AvatarContextType {
|
||||
size?: AvatarSize;
|
||||
|
||||
@@ -44,7 +44,7 @@ export interface AvatarGroupProps {
|
||||
popover?: PopoverProps;
|
||||
};
|
||||
/*
|
||||
* Size of avatar, options: `large`, `small`, `default`
|
||||
* Size of avatar, options: `large`, `medium`, `small`
|
||||
* or a custom number size
|
||||
* */
|
||||
size?: AvatarSize;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { useState } from 'react';
|
||||
import { Avatar, Button, Space } from 'antd';
|
||||
|
||||
type SizeType = 'large' | 'small' | 'default' | number;
|
||||
type SizeType = 'large' | 'small' | 'medium' | number;
|
||||
|
||||
const App: React.FC = () => {
|
||||
const [hide, setHide] = useState(true);
|
||||
@@ -13,7 +13,7 @@ const App: React.FC = () => {
|
||||
};
|
||||
|
||||
const toggleSize = () => {
|
||||
const sizes = ['small', 'default', 'large'] as SizeType[];
|
||||
const sizes = ['small', 'medium', 'large'] as SizeType[];
|
||||
let current = sizes.indexOf(size) + 1;
|
||||
if (current > 2) {
|
||||
current = 0;
|
||||
|
||||
@@ -36,7 +36,7 @@ Common props ref:[Common props](/docs/react/common-props)
|
||||
| gap | Letter type unit distance between left and right sides | number | 4 | 4.3.0 |
|
||||
| icon | Custom icon type for an icon avatar | ReactNode | - | |
|
||||
| shape | The shape of avatar | `circle` \| `square` | `circle` | |
|
||||
| size | The size of the avatar | number \| `large` \| `small` \| `default` \| { xs: number, sm: number, ...} | `default` | 4.7.0 |
|
||||
| size | The size of the avatar | number \| `large` \| `medium` \| `small` \| { xs: number, sm: number, ...} | `medium` | 4.7.0 |
|
||||
| src | The address of the image for an image avatar or image element | string \| ReactNode | - | ReactNode: 4.8.0 |
|
||||
| srcSet | A list of sources to use for different screen resolutions | string | - | |
|
||||
| draggable | Whether the picture is allowed to be dragged | boolean \| `'true'` \| `'false'` | true | |
|
||||
@@ -50,7 +50,7 @@ Common props ref:[Common props](/docs/react/common-props)
|
||||
| Property | Description | Type | Default | Version |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| max | Set maximum display related configurations, Before `5.18.0` you can use [parameters](https://github.com/ant-design/ant-design/blob/9d134859becbdae5b9ce276f6d9af4264691d81f/components/avatar/group.tsx#L35-L38) | `{ count?: number; style?: CSSProperties; popover?: PopoverProps }` | - | 5.18.0 |
|
||||
| size | The size of the avatar | number \| `large` \| `small` \| `default` \| { xs: number, sm: number, ...} | `default` | 4.8.0 |
|
||||
| size | The size of the avatar | number \| `large` \| `medium` \| `small` \| { xs: number, sm: number, ...} | `medium` | 4.8.0 |
|
||||
| shape | The shape of the avatar | `circle` \| `square` | `circle` | 5.8.0 |
|
||||
|
||||
## Design Token
|
||||
|
||||
@@ -41,7 +41,7 @@ group:
|
||||
| gap | 字符类型距离左右两侧边界单位像素 | number | 4 | 4.3.0 |
|
||||
| icon | 设置头像的自定义图标 | ReactNode | - | |
|
||||
| shape | 指定头像的形状 | `circle` \| `square` | `circle` | |
|
||||
| size | 设置头像的大小 | number \| `large` \| `small` \| `default` \| { xs: number, sm: number, ...} | `default` | 4.7.0 |
|
||||
| size | 设置头像的大小 | number \| `large` \| `medium` \| `small` \| { xs: number, sm: number, ...} | `medium` | 4.7.0 |
|
||||
| src | 图片类头像的资源地址或者图片元素 | string \| ReactNode | - | ReactNode: 4.8.0 |
|
||||
| srcSet | 设置图片类头像响应式资源地址 | string | - | |
|
||||
| draggable | 图片是否允许拖动 | boolean \| `'true'` \| `'false'` | true | |
|
||||
@@ -55,7 +55,7 @@ group:
|
||||
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| max | 设置最多显示相关配置,`5.18.0` 前可使用 [参数](https://github.com/ant-design/ant-design/blob/9d134859becbdae5b9ce276f6d9af4264691d81f/components/avatar/group.tsx#L35-L38) | `{ count?: number; style?: CSSProperties; popover?: PopoverProps }` | - | 5.18.0 |
|
||||
| size | 设置头像的大小 | number \| `large` \| `small` \| `default` \| { xs: number, sm: number, ...} | `default` | 4.8.0 |
|
||||
| size | 设置头像的大小 | number \| `large` \| `medium` \| `small` \| { xs: number, sm: number, ...} | `medium` | 4.8.0 |
|
||||
| shape | 设置头像的形状 | `circle` \| `square` | `circle` | 5.8.0 |
|
||||
|
||||
## 主题变量(Design Token){#design-token}
|
||||
|
||||
@@ -3083,7 +3083,7 @@ exports[`renders components/badge/demo/style-class.tsx extend context correctly
|
||||
/>
|
||||
</span>
|
||||
<sup
|
||||
class="ant-scroll-number acss-9c7r58 ant-badge-count ant-badge-count-sm"
|
||||
class="ant-scroll-number acss-1aprf71 ant-badge-count ant-badge-count-sm"
|
||||
data-show="true"
|
||||
title="5"
|
||||
>
|
||||
@@ -3113,7 +3113,7 @@ exports[`renders components/badge/demo/style-class.tsx extend context correctly
|
||||
/>
|
||||
</span>
|
||||
<sup
|
||||
class="ant-scroll-number acss-9c7r58 ant-badge-count"
|
||||
class="ant-scroll-number acss-1aprf71 ant-badge-count"
|
||||
data-show="true"
|
||||
style="font-size: 14px; background-color: rgb(105, 111, 199);"
|
||||
title="5"
|
||||
@@ -3141,7 +3141,7 @@ exports[`renders components/badge/demo/style-class.tsx extend context correctly
|
||||
class="ant-flex css-var-test-id ant-flex-align-stretch ant-flex-gap-middle ant-flex-vertical"
|
||||
>
|
||||
<div
|
||||
class="ant-ribbon-wrapper css-var-test-id acss-19a7de9"
|
||||
class="ant-ribbon-wrapper css-var-test-id acss-15qh5u5"
|
||||
>
|
||||
<div
|
||||
class="ant-card ant-card-bordered ant-card-small css-var-test-id"
|
||||
@@ -3180,7 +3180,7 @@ exports[`renders components/badge/demo/style-class.tsx extend context correctly
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-ribbon-wrapper css-var-test-id acss-19a7de9"
|
||||
class="ant-ribbon-wrapper css-var-test-id acss-15qh5u5"
|
||||
>
|
||||
<div
|
||||
class="ant-card ant-card-bordered ant-card-small css-var-test-id"
|
||||
|
||||
@@ -3053,7 +3053,7 @@ exports[`renders components/badge/demo/style-class.tsx correctly 1`] = `
|
||||
/>
|
||||
</span>
|
||||
<sup
|
||||
class="ant-scroll-number acss-9c7r58 ant-badge-count ant-badge-count-sm"
|
||||
class="ant-scroll-number acss-1aprf71 ant-badge-count ant-badge-count-sm"
|
||||
data-show="true"
|
||||
title="5"
|
||||
>
|
||||
@@ -3083,7 +3083,7 @@ exports[`renders components/badge/demo/style-class.tsx correctly 1`] = `
|
||||
/>
|
||||
</span>
|
||||
<sup
|
||||
class="ant-scroll-number acss-9c7r58 ant-badge-count"
|
||||
class="ant-scroll-number acss-1aprf71 ant-badge-count"
|
||||
data-show="true"
|
||||
style="font-size:14px;background-color:#696FC7"
|
||||
title="5"
|
||||
@@ -3111,7 +3111,7 @@ exports[`renders components/badge/demo/style-class.tsx correctly 1`] = `
|
||||
class="ant-flex css-var-test-id ant-flex-align-stretch ant-flex-gap-middle ant-flex-vertical"
|
||||
>
|
||||
<div
|
||||
class="ant-ribbon-wrapper css-var-test-id acss-19a7de9"
|
||||
class="ant-ribbon-wrapper css-var-test-id acss-15qh5u5"
|
||||
>
|
||||
<div
|
||||
class="ant-card ant-card-bordered ant-card-small css-var-test-id"
|
||||
@@ -3150,7 +3150,7 @@ exports[`renders components/badge/demo/style-class.tsx correctly 1`] = `
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-ribbon-wrapper css-var-test-id acss-19a7de9"
|
||||
class="ant-ribbon-wrapper css-var-test-id acss-15qh5u5"
|
||||
>
|
||||
<div
|
||||
class="ant-card ant-card-bordered ant-card-small css-var-test-id"
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
import React from 'react';
|
||||
import { Avatar, Badge, Card, Flex, Space } from 'antd';
|
||||
import type { BadgeProps } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import type { RibbonProps } from 'antd/es/badge/Ribbon';
|
||||
|
||||
const useStylesBadge = createStyles(() => ({
|
||||
indicator: {
|
||||
fontSize: 10,
|
||||
},
|
||||
const badgeClassNames = createStaticStyles(({ css }) => ({
|
||||
indicator: css`
|
||||
font-size: 10px;
|
||||
`,
|
||||
}));
|
||||
|
||||
const useStylesRibbon = createStyles(() => ({
|
||||
root: {
|
||||
width: 400,
|
||||
border: '1px solid #d9d9d9',
|
||||
borderRadius: 10,
|
||||
},
|
||||
const ribbonClassNames = createStaticStyles(({ css }) => ({
|
||||
root: css`
|
||||
width: 400px;
|
||||
border: 1px solid #d9d9d9;
|
||||
border-radius: 10px;
|
||||
`,
|
||||
}));
|
||||
|
||||
const badgeStyles: BadgeProps['styles'] = {
|
||||
@@ -57,8 +57,6 @@ const ribbonStylesFn: RibbonProps['styles'] = (info) => {
|
||||
};
|
||||
|
||||
const App: React.FC = () => {
|
||||
const { styles: badgeClassNames } = useStylesBadge();
|
||||
const { styles: ribbonClassNames } = useStylesRibbon();
|
||||
return (
|
||||
<Space size="large" vertical>
|
||||
<Flex gap="middle">
|
||||
|
||||
@@ -881,12 +881,12 @@ exports[`renders components/breadcrumb/demo/style-class.tsx extend context corre
|
||||
>
|
||||
<nav
|
||||
aria-label="Breadcrumb with Object"
|
||||
class="ant-breadcrumb acss-lz3q7n css-var-test-id"
|
||||
class="ant-breadcrumb acss-14g82y5 css-var-test-id"
|
||||
style="border: 1px solid rgb(240, 240, 240); padding: 8px; border-radius: 4px;"
|
||||
>
|
||||
<ol>
|
||||
<li
|
||||
class="ant-breadcrumb-item acss-3btzkp"
|
||||
class="ant-breadcrumb-item acss-11xwyle"
|
||||
style="color: rgb(24, 144, 255);"
|
||||
>
|
||||
<span
|
||||
@@ -897,13 +897,13 @@ exports[`renders components/breadcrumb/demo/style-class.tsx extend context corre
|
||||
</li>
|
||||
<li
|
||||
aria-hidden="true"
|
||||
class="ant-breadcrumb-separator acss-t9kin8"
|
||||
class="ant-breadcrumb-separator acss-1qxitnl"
|
||||
style="color: rgba(0, 0, 0, 0.45);"
|
||||
>
|
||||
/
|
||||
</li>
|
||||
<li
|
||||
class="ant-breadcrumb-item acss-3btzkp"
|
||||
class="ant-breadcrumb-item acss-11xwyle"
|
||||
style="color: rgb(24, 144, 255);"
|
||||
>
|
||||
<span
|
||||
@@ -920,12 +920,12 @@ exports[`renders components/breadcrumb/demo/style-class.tsx extend context corre
|
||||
</nav>
|
||||
<nav
|
||||
aria-label="Breadcrumb with Function"
|
||||
class="ant-breadcrumb acss-lz3q7n css-var-test-id"
|
||||
class="ant-breadcrumb acss-14g82y5 css-var-test-id"
|
||||
style="border: 1px solid rgb(245, 239, 255); padding: 8px; border-radius: 4px;"
|
||||
>
|
||||
<ol>
|
||||
<li
|
||||
class="ant-breadcrumb-item acss-3btzkp"
|
||||
class="ant-breadcrumb-item acss-11xwyle"
|
||||
style="color: rgb(143, 135, 241);"
|
||||
>
|
||||
<span
|
||||
@@ -936,12 +936,12 @@ exports[`renders components/breadcrumb/demo/style-class.tsx extend context corre
|
||||
</li>
|
||||
<li
|
||||
aria-hidden="true"
|
||||
class="ant-breadcrumb-separator acss-t9kin8"
|
||||
class="ant-breadcrumb-separator acss-1qxitnl"
|
||||
>
|
||||
/
|
||||
</li>
|
||||
<li
|
||||
class="ant-breadcrumb-item acss-3btzkp"
|
||||
class="ant-breadcrumb-item acss-11xwyle"
|
||||
style="color: rgb(143, 135, 241);"
|
||||
>
|
||||
<span
|
||||
@@ -956,12 +956,12 @@ exports[`renders components/breadcrumb/demo/style-class.tsx extend context corre
|
||||
</li>
|
||||
<li
|
||||
aria-hidden="true"
|
||||
class="ant-breadcrumb-separator acss-t9kin8"
|
||||
class="ant-breadcrumb-separator acss-1qxitnl"
|
||||
>
|
||||
/
|
||||
</li>
|
||||
<li
|
||||
class="ant-breadcrumb-item acss-3btzkp"
|
||||
class="ant-breadcrumb-item acss-11xwyle"
|
||||
style="color: rgb(143, 135, 241);"
|
||||
>
|
||||
<span
|
||||
|
||||
@@ -525,12 +525,12 @@ exports[`renders components/breadcrumb/demo/style-class.tsx correctly 1`] = `
|
||||
>
|
||||
<nav
|
||||
aria-label="Breadcrumb with Object"
|
||||
class="ant-breadcrumb acss-lz3q7n css-var-test-id"
|
||||
class="ant-breadcrumb acss-14g82y5 css-var-test-id"
|
||||
style="border:1px solid #f0f0f0;padding:8px;border-radius:4px"
|
||||
>
|
||||
<ol>
|
||||
<li
|
||||
class="ant-breadcrumb-item acss-3btzkp"
|
||||
class="ant-breadcrumb-item acss-11xwyle"
|
||||
style="color:#1890ff"
|
||||
>
|
||||
<span
|
||||
@@ -541,13 +541,13 @@ exports[`renders components/breadcrumb/demo/style-class.tsx correctly 1`] = `
|
||||
</li>
|
||||
<li
|
||||
aria-hidden="true"
|
||||
class="ant-breadcrumb-separator acss-t9kin8"
|
||||
class="ant-breadcrumb-separator acss-1qxitnl"
|
||||
style="color:rgba(0, 0, 0, 0.45)"
|
||||
>
|
||||
/
|
||||
</li>
|
||||
<li
|
||||
class="ant-breadcrumb-item acss-3btzkp"
|
||||
class="ant-breadcrumb-item acss-11xwyle"
|
||||
style="color:#1890ff"
|
||||
>
|
||||
<span
|
||||
@@ -564,12 +564,12 @@ exports[`renders components/breadcrumb/demo/style-class.tsx correctly 1`] = `
|
||||
</nav>
|
||||
<nav
|
||||
aria-label="Breadcrumb with Function"
|
||||
class="ant-breadcrumb acss-lz3q7n css-var-test-id"
|
||||
class="ant-breadcrumb acss-14g82y5 css-var-test-id"
|
||||
style="border:1px solid #F5EFFF;padding:8px;border-radius:4px"
|
||||
>
|
||||
<ol>
|
||||
<li
|
||||
class="ant-breadcrumb-item acss-3btzkp"
|
||||
class="ant-breadcrumb-item acss-11xwyle"
|
||||
style="color:#8F87F1"
|
||||
>
|
||||
<span
|
||||
@@ -580,12 +580,12 @@ exports[`renders components/breadcrumb/demo/style-class.tsx correctly 1`] = `
|
||||
</li>
|
||||
<li
|
||||
aria-hidden="true"
|
||||
class="ant-breadcrumb-separator acss-t9kin8"
|
||||
class="ant-breadcrumb-separator acss-1qxitnl"
|
||||
>
|
||||
/
|
||||
</li>
|
||||
<li
|
||||
class="ant-breadcrumb-item acss-3btzkp"
|
||||
class="ant-breadcrumb-item acss-11xwyle"
|
||||
style="color:#8F87F1"
|
||||
>
|
||||
<span
|
||||
@@ -600,12 +600,12 @@ exports[`renders components/breadcrumb/demo/style-class.tsx correctly 1`] = `
|
||||
</li>
|
||||
<li
|
||||
aria-hidden="true"
|
||||
class="ant-breadcrumb-separator acss-t9kin8"
|
||||
class="ant-breadcrumb-separator acss-1qxitnl"
|
||||
>
|
||||
/
|
||||
</li>
|
||||
<li
|
||||
class="ant-breadcrumb-item acss-3btzkp"
|
||||
class="ant-breadcrumb-item acss-11xwyle"
|
||||
style="color:#8F87F1"
|
||||
>
|
||||
<span
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
import React from 'react';
|
||||
import { Breadcrumb, Flex } from 'antd';
|
||||
import type { BreadcrumbProps } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
|
||||
const useStyles = createStyles(() => ({
|
||||
root: { padding: 8, borderRadius: 4 },
|
||||
item: { color: '#1890ff' },
|
||||
separator: { color: 'rgba(0, 0, 0, 0.45)' },
|
||||
const classNames = createStaticStyles(({ css }) => ({
|
||||
root: css`
|
||||
padding: 8px;
|
||||
border-radius: 4px;
|
||||
`,
|
||||
item: css`
|
||||
color: #1890ff;
|
||||
`,
|
||||
separator: css`
|
||||
color: rgba(0, 0, 0, 0.45);
|
||||
`,
|
||||
}));
|
||||
|
||||
const styles: BreadcrumbProps['styles'] = {
|
||||
@@ -33,8 +40,6 @@ const items = [
|
||||
];
|
||||
|
||||
const App: React.FC = () => {
|
||||
const { styles: classNames } = useStyles();
|
||||
|
||||
return (
|
||||
<Flex vertical gap="middle">
|
||||
<Breadcrumb
|
||||
|
||||
@@ -331,7 +331,7 @@ const InternalCompoundedButton = React.forwardRef<
|
||||
// ========================== Size ==========================
|
||||
const { compactSize, compactItemClassnames } = useCompactItemContext(prefixCls, direction);
|
||||
|
||||
const sizeClassNameMap = { large: 'lg', small: 'sm', middle: undefined };
|
||||
const sizeClassNameMap = { large: 'lg', small: 'sm', middle: undefined, medium: undefined };
|
||||
|
||||
const sizeFullName = useSize((ctxSize) => customizeSize ?? compactSize ?? groupSize ?? ctxSize);
|
||||
|
||||
|
||||
@@ -115,6 +115,23 @@ describe('Button', () => {
|
||||
expect(container.querySelector('.ant-btn')).toHaveClass('ant-btn-two-chinese-chars');
|
||||
});
|
||||
|
||||
// https://github.com/ant-design/ant-design/issues/56591
|
||||
it('should preserve className when rendering two Chinese characters in child element', () => {
|
||||
const { container } = render(
|
||||
<Button>
|
||||
<span className="custom-class" style={{ color: 'rgb(255, 0, 0)' }}>
|
||||
按钮
|
||||
</span>
|
||||
</Button>,
|
||||
);
|
||||
|
||||
const span = container.querySelector('span.custom-class');
|
||||
expect(span).toBeTruthy();
|
||||
expect(span).toHaveClass('custom-class');
|
||||
expect(span).toHaveStyle({ color: 'rgb(255, 0, 0)' });
|
||||
expect(span).toHaveTextContent('按 钮');
|
||||
});
|
||||
|
||||
// https://github.com/ant-design/ant-design/issues/18118
|
||||
it('should not insert space to link or text button', () => {
|
||||
const wrapper1 = render(<Button type="link">按钮</Button>);
|
||||
|
||||
@@ -28,7 +28,7 @@ export function isUnBorderedButtonVariant(type?: ButtonVariantType) {
|
||||
}
|
||||
|
||||
function splitCNCharsBySpace(
|
||||
child: React.ReactElement | string | number,
|
||||
child: React.ReactElement<any> | string | number,
|
||||
needInserted: boolean,
|
||||
style?: React.CSSProperties,
|
||||
className?: string,
|
||||
@@ -43,20 +43,18 @@ function splitCNCharsBySpace(
|
||||
typeof child !== 'string' &&
|
||||
typeof child !== 'number' &&
|
||||
isString(child.type) &&
|
||||
isTwoCNChar(
|
||||
(
|
||||
child as React.ReactElement<{
|
||||
children: string;
|
||||
}>
|
||||
).props.children,
|
||||
)
|
||||
isTwoCNChar((child as React.ReactElement<{ children: string }>).props.children)
|
||||
) {
|
||||
return cloneElement(child, (oriProps) => ({
|
||||
...oriProps,
|
||||
children: oriProps.children.split('').join(SPACE),
|
||||
className,
|
||||
style,
|
||||
}));
|
||||
return cloneElement(child, (oriProps) => {
|
||||
const mergedCls = clsx(oriProps.className, className) || undefined;
|
||||
const mergedStyle: React.CSSProperties = { ...style, ...oriProps.style };
|
||||
return {
|
||||
...oriProps,
|
||||
children: oriProps.children.split('').join(SPACE),
|
||||
className: mergedCls,
|
||||
style: mergedStyle,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
if (isString(child)) {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import React from 'react';
|
||||
import { Button, ConfigProvider, Flex } from 'antd';
|
||||
import type { ThemeConfig } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
|
||||
const useSpecStyle = createStyles(({ css }) => ({
|
||||
const specClassNames = createStaticStyles(({ css }) => ({
|
||||
primary: css`
|
||||
background: #5794f7;
|
||||
border-color: blue;
|
||||
@@ -27,7 +27,7 @@ const useSpecStyle = createStyles(({ css }) => ({
|
||||
`,
|
||||
}));
|
||||
|
||||
const useOriginalClsStyle = createStyles(({ css }) => ({
|
||||
const originalClsStyle = createStaticStyles(({ css }) => ({
|
||||
wrapper: css`
|
||||
.ant-btn-primary {
|
||||
color: #ec5b56;
|
||||
@@ -59,9 +59,6 @@ const theme: ThemeConfig = {
|
||||
};
|
||||
|
||||
const App: React.FC = () => {
|
||||
const { styles: specStyle } = useSpecStyle();
|
||||
const { styles: originalClsStyle } = useOriginalClsStyle();
|
||||
|
||||
return (
|
||||
<Flex vertical gap="small">
|
||||
{/* link color */}
|
||||
@@ -74,19 +71,19 @@ const App: React.FC = () => {
|
||||
|
||||
{/* css specificity */}
|
||||
<Flex gap="small" wrap>
|
||||
<Button type="primary" className={specStyle.primary}>
|
||||
<Button type="primary" className={specClassNames.primary}>
|
||||
Primary Button
|
||||
</Button>
|
||||
<Button type="default" className={specStyle.default}>
|
||||
<Button type="default" className={specClassNames.default}>
|
||||
Default Button
|
||||
</Button>
|
||||
<Button type="dashed" className={specStyle.dashed}>
|
||||
<Button type="dashed" className={specClassNames.dashed}>
|
||||
Dashed Button
|
||||
</Button>
|
||||
<Button type="text" className={specStyle.text}>
|
||||
<Button type="text" className={specClassNames.text}>
|
||||
Text Button
|
||||
</Button>
|
||||
<Button type="link" className={specStyle.link}>
|
||||
<Button type="link" className={specClassNames.link}>
|
||||
Link Button
|
||||
</Button>
|
||||
</Flex>
|
||||
|
||||
@@ -1771,7 +1771,7 @@ exports[`renders components/collapse/demo/style-class.tsx extend context correct
|
||||
class="ant-flex css-var-test-id ant-flex-align-stretch ant-flex-gap-middle ant-flex-vertical"
|
||||
>
|
||||
<div
|
||||
class="ant-collapse ant-collapse-icon-placement-start css-var-test-id acss-c792w8"
|
||||
class="ant-collapse ant-collapse-icon-placement-start css-var-test-id acss-1xdwrp5"
|
||||
style="background-color: rgb(250, 250, 250); border: 1px solid rgb(224, 224, 224); border-radius: 8px;"
|
||||
>
|
||||
<div
|
||||
@@ -1911,7 +1911,7 @@ exports[`renders components/collapse/demo/style-class.tsx extend context correct
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-collapse ant-collapse-icon-placement-start ant-collapse-large css-var-test-id acss-c792w8"
|
||||
class="ant-collapse ant-collapse-icon-placement-start ant-collapse-large css-var-test-id acss-1xdwrp5"
|
||||
style="background-color: rgb(255, 255, 255); border: 1px solid rgb(105, 111, 199); border-radius: 8px;"
|
||||
>
|
||||
<div
|
||||
|
||||
@@ -1671,7 +1671,7 @@ exports[`renders components/collapse/demo/style-class.tsx correctly 1`] = `
|
||||
class="ant-flex css-var-test-id ant-flex-align-stretch ant-flex-gap-middle ant-flex-vertical"
|
||||
>
|
||||
<div
|
||||
class="ant-collapse ant-collapse-icon-placement-start css-var-test-id acss-c792w8"
|
||||
class="ant-collapse ant-collapse-icon-placement-start css-var-test-id acss-1xdwrp5"
|
||||
style="background-color:#fafafa;border:1px solid #e0e0e0;border-radius:8px"
|
||||
>
|
||||
<div
|
||||
@@ -1811,7 +1811,7 @@ exports[`renders components/collapse/demo/style-class.tsx correctly 1`] = `
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-collapse ant-collapse-icon-placement-start ant-collapse-large css-var-test-id acss-c792w8"
|
||||
class="ant-collapse ant-collapse-icon-placement-start ant-collapse-large css-var-test-id acss-1xdwrp5"
|
||||
style="background-color:#fff;border:1px solid #696FC7;border-radius:8px"
|
||||
>
|
||||
<div
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
import React from 'react';
|
||||
import { Collapse, Flex } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
|
||||
import type { CollapseProps } from '..';
|
||||
|
||||
const useStyles = createStyles(() => ({
|
||||
root: {
|
||||
backgroundColor: '#fafafa',
|
||||
border: '1px solid #e0e0e0',
|
||||
borderRadius: 8,
|
||||
},
|
||||
const classNames = createStaticStyles(({ css }) => ({
|
||||
root: css`
|
||||
background-color: #fafafa;
|
||||
border: 1px solid #e0e0e0;
|
||||
border-radius: 8px;
|
||||
`,
|
||||
}));
|
||||
|
||||
const element = (
|
||||
@@ -68,8 +68,6 @@ const stylesFn: CollapseProps['styles'] = ({ props }) => {
|
||||
};
|
||||
|
||||
const App: React.FC = () => {
|
||||
const { styles: classNames } = useStyles();
|
||||
|
||||
const sharedProps: CollapseProps = { classNames, items };
|
||||
|
||||
return (
|
||||
|
||||
@@ -225,7 +225,7 @@ const ColorPicker: CompoundedComponent = (props) => {
|
||||
const rootCls = useCSSVarCls(prefixCls);
|
||||
const [hashId, cssVarCls] = useStyle(prefixCls, rootCls);
|
||||
const rtlCls = { [`${prefixCls}-rtl`]: direction };
|
||||
const mergedRootCls = clsx(mergedClassNames.root, rootClassName, cssVarCls, rootCls, rtlCls);
|
||||
const mergedRootCls = clsx(rootClassName, cssVarCls, rootCls, rtlCls);
|
||||
const mergedCls = clsx(
|
||||
getStatusClassNames(prefixCls, contextStatus),
|
||||
{
|
||||
@@ -262,7 +262,7 @@ const ColorPicker: CompoundedComponent = (props) => {
|
||||
destroyOnHidden: destroyOnHidden ?? !!destroyTooltipOnHide,
|
||||
};
|
||||
|
||||
const mergedStyle: React.CSSProperties = { ...mergedStyles.root, ...contextStyle, ...style };
|
||||
const mergedStyle: React.CSSProperties = { ...contextStyle, ...style };
|
||||
|
||||
// ============================ zIndex ============================
|
||||
|
||||
@@ -305,6 +305,8 @@ const ColorPicker: CompoundedComponent = (props) => {
|
||||
open={popupOpen}
|
||||
className={mergedCls}
|
||||
style={mergedStyle}
|
||||
classNames={mergedClassNames}
|
||||
styles={mergedStyles}
|
||||
prefixCls={prefixCls}
|
||||
disabled={mergedDisabled}
|
||||
showText={showText}
|
||||
|
||||
@@ -9465,7 +9465,7 @@ exports[`renders components/color-picker/demo/style-class.tsx extend context cor
|
||||
>
|
||||
<div
|
||||
aria-describedby="test-id"
|
||||
class="ant-color-picker-trigger acss-pbemrr css-var-test-id ant-color-picker-css-var"
|
||||
class="ant-color-picker-trigger css-var-test-id ant-color-picker-css-var acss-pbemrr"
|
||||
>
|
||||
<div
|
||||
class="ant-color-picker-color-block"
|
||||
@@ -9477,7 +9477,7 @@ exports[`renders components/color-picker/demo/style-class.tsx extend context cor
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-popover ant-zoom-big-appear ant-zoom-big-appear-prepare ant-zoom-big ant-popover-css-var css-var-test-id css-var-test-id ant-color-picker acss-pbemrr css-var-test-id ant-color-picker-css-var ant-popover-placement-bottomLeft"
|
||||
class="ant-popover ant-zoom-big-appear ant-zoom-big-appear-prepare ant-zoom-big ant-popover-css-var css-var-test-id css-var-test-id ant-color-picker css-var-test-id ant-color-picker-css-var ant-popover-placement-bottomLeft"
|
||||
style="--arrow-x: 0px; --arrow-y: 0px; left: -1000vw; top: -1000vh; right: auto; bottom: auto; box-sizing: border-box; border: 1px solid rgb(255, 255, 255);"
|
||||
>
|
||||
<div
|
||||
@@ -9832,7 +9832,7 @@ exports[`renders components/color-picker/demo/style-class.tsx extend context cor
|
||||
>
|
||||
<div
|
||||
aria-describedby="test-id"
|
||||
class="ant-color-picker-trigger ant-color-picker-lg acss-pbemrr css-var-test-id ant-color-picker-css-var"
|
||||
class="ant-color-picker-trigger ant-color-picker-lg css-var-test-id ant-color-picker-css-var acss-pbemrr"
|
||||
>
|
||||
<div
|
||||
class="ant-color-picker-color-block"
|
||||
@@ -9844,7 +9844,7 @@ exports[`renders components/color-picker/demo/style-class.tsx extend context cor
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-popover ant-zoom-big-appear ant-zoom-big-appear-prepare ant-zoom-big ant-popover-css-var css-var-test-id css-var-test-id ant-color-picker acss-pbemrr css-var-test-id ant-color-picker-css-var ant-popover-placement-bottomLeft"
|
||||
class="ant-popover ant-zoom-big-appear ant-zoom-big-appear-prepare ant-zoom-big ant-popover-css-var css-var-test-id css-var-test-id ant-color-picker css-var-test-id ant-color-picker-css-var ant-popover-placement-bottomLeft"
|
||||
style="--arrow-x: 0px; --arrow-y: 0px; left: -1000vw; top: -1000vh; right: auto; bottom: auto; box-sizing: border-box; border: 1px solid rgb(114, 46, 209);"
|
||||
>
|
||||
<div
|
||||
|
||||
@@ -552,7 +552,7 @@ exports[`renders components/color-picker/demo/style-class.tsx correctly 1`] = `
|
||||
class="ant-flex css-var-test-id ant-flex-gap-small"
|
||||
>
|
||||
<div
|
||||
class="ant-color-picker-trigger acss-pbemrr css-var-test-id ant-color-picker-css-var"
|
||||
class="ant-color-picker-trigger css-var-test-id ant-color-picker-css-var acss-pbemrr"
|
||||
>
|
||||
<div
|
||||
class="ant-color-picker-color-block"
|
||||
@@ -572,7 +572,7 @@ exports[`renders components/color-picker/demo/style-class.tsx correctly 1`] = `
|
||||
class="ant-flex css-var-test-id ant-flex-gap-small"
|
||||
>
|
||||
<div
|
||||
class="ant-color-picker-trigger ant-color-picker-lg acss-pbemrr css-var-test-id ant-color-picker-css-var"
|
||||
class="ant-color-picker-trigger ant-color-picker-lg css-var-test-id ant-color-picker-css-var acss-pbemrr"
|
||||
>
|
||||
<div
|
||||
class="ant-color-picker-color-block"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { FC } from 'react';
|
||||
import React from 'react';
|
||||
import clsx from 'clsx';
|
||||
|
||||
import type { AggregationColor } from '../color';
|
||||
import { generateColor } from '../util';
|
||||
@@ -8,10 +9,12 @@ interface ColorClearProps {
|
||||
prefixCls: string;
|
||||
value?: AggregationColor;
|
||||
onChange?: (value: AggregationColor) => void;
|
||||
className?: string;
|
||||
style?: React.CSSProperties;
|
||||
}
|
||||
|
||||
const ColorClear: FC<ColorClearProps> = ({ prefixCls, value, onChange }) => {
|
||||
const handleClick = () => {
|
||||
const ColorClear: FC<ColorClearProps> = ({ prefixCls, value, onChange, className, style }) => {
|
||||
const onClick = () => {
|
||||
if (onChange && value && !value.cleared) {
|
||||
const hsba = value.toHsb();
|
||||
hsba.a = 0;
|
||||
@@ -21,7 +24,7 @@ const ColorClear: FC<ColorClearProps> = ({ prefixCls, value, onChange }) => {
|
||||
onChange(genColor);
|
||||
}
|
||||
};
|
||||
return <div className={`${prefixCls}-clear`} onClick={handleClick} />;
|
||||
return <div className={clsx(`${prefixCls}-clear`, className)} style={style} onClick={onClick} />;
|
||||
};
|
||||
|
||||
export default ColorClear;
|
||||
|
||||
@@ -7,7 +7,12 @@ import { clsx } from 'clsx';
|
||||
|
||||
import { useLocale } from '../../locale';
|
||||
import type { AggregationColor } from '../color';
|
||||
import type { ColorFormatType, ColorPickerProps } from '../interface';
|
||||
import type {
|
||||
ColorFormatType,
|
||||
ColorPickerProps,
|
||||
ColorPickerSemanticClassNames,
|
||||
ColorPickerSemanticStyles,
|
||||
} from '../interface';
|
||||
import { getColorAlpha } from '../util';
|
||||
import ColorClear from './ColorClear';
|
||||
|
||||
@@ -20,6 +25,8 @@ export interface ColorTriggerProps {
|
||||
showText?: ColorPickerProps['showText'];
|
||||
className?: string;
|
||||
style?: CSSProperties;
|
||||
classNames: ColorPickerSemanticClassNames;
|
||||
styles: ColorPickerSemanticStyles;
|
||||
onClick?: MouseEventHandler<HTMLDivElement>;
|
||||
onMouseEnter?: MouseEventHandler<HTMLDivElement>;
|
||||
onMouseLeave?: MouseEventHandler<HTMLDivElement>;
|
||||
@@ -27,8 +34,20 @@ export interface ColorTriggerProps {
|
||||
}
|
||||
|
||||
const ColorTrigger = forwardRef<HTMLDivElement, ColorTriggerProps>((props, ref) => {
|
||||
const { color, prefixCls, open, disabled, format, className, showText, activeIndex, ...rest } =
|
||||
props;
|
||||
const {
|
||||
color,
|
||||
prefixCls,
|
||||
open,
|
||||
disabled,
|
||||
format,
|
||||
className,
|
||||
style,
|
||||
classNames,
|
||||
styles,
|
||||
showText,
|
||||
activeIndex,
|
||||
...rest
|
||||
} = props;
|
||||
|
||||
const colorTriggerPrefixCls = `${prefixCls}-trigger`;
|
||||
const colorTextPrefixCls = `${colorTriggerPrefixCls}-text`;
|
||||
@@ -85,24 +104,42 @@ const ColorTrigger = forwardRef<HTMLDivElement, ColorTriggerProps>((props, ref)
|
||||
const containerNode = useMemo<React.ReactNode>(
|
||||
() =>
|
||||
color.cleared ? (
|
||||
<ColorClear prefixCls={prefixCls} />
|
||||
<ColorClear prefixCls={prefixCls} className={classNames.body} style={styles.body} />
|
||||
) : (
|
||||
<ColorBlock prefixCls={prefixCls} color={color.toCssString()} />
|
||||
<ColorBlock
|
||||
prefixCls={prefixCls}
|
||||
color={color.toCssString()}
|
||||
className={classNames.body}
|
||||
innerClassName={classNames.content}
|
||||
style={styles.body}
|
||||
innerStyle={styles.content}
|
||||
/>
|
||||
),
|
||||
[color, prefixCls],
|
||||
[color, prefixCls, classNames.body, classNames.content, styles.body, styles.content],
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
ref={ref}
|
||||
className={clsx(colorTriggerPrefixCls, className, {
|
||||
className={clsx(colorTriggerPrefixCls, className, classNames.root, {
|
||||
[`${colorTriggerPrefixCls}-active`]: open,
|
||||
[`${colorTriggerPrefixCls}-disabled`]: disabled,
|
||||
})}
|
||||
style={{
|
||||
...styles.root,
|
||||
...style,
|
||||
}}
|
||||
{...pickAttrs(rest)}
|
||||
>
|
||||
{containerNode}
|
||||
{showText && <div className={colorTextPrefixCls}>{desc}</div>}
|
||||
{showText && (
|
||||
<div
|
||||
className={clsx(colorTextPrefixCls, classNames.description)}
|
||||
style={styles.description}
|
||||
>
|
||||
{desc}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,17 +1,23 @@
|
||||
import React from 'react';
|
||||
import type { ColorPickerProps } from 'antd';
|
||||
import { ColorPicker } from 'antd';
|
||||
import { ColorPicker, Flex } from 'antd';
|
||||
|
||||
import SemanticPreview from '../../../.dumi/theme/common/SemanticPreview';
|
||||
import useLocale from '../../../.dumi/hooks/useLocale';
|
||||
import SemanticPreview from '../../../.dumi/theme/common/SemanticPreview';
|
||||
|
||||
const locales = {
|
||||
cn: {
|
||||
root: '触发器容器,包含边框样式、过渡动画、尺寸控制等样式,显示颜色块和文本内容',
|
||||
body: '色块容器,包含底色、边框等样式',
|
||||
content: '色块颜色元素,包含实际选择的颜色样式',
|
||||
description: '描述文本内容,包含字体样式、颜色等样式',
|
||||
'popup.root': '弹出面板根容器,包含背景色、阴影效果、色彩选择面板、滑块控制和预设颜色等样式',
|
||||
},
|
||||
en: {
|
||||
root: 'Trigger container with border styles, transition animations, size controls, displaying color block and text content',
|
||||
body: 'Color block container with background color, border styles',
|
||||
content: 'Color block element with actual selected color styles',
|
||||
description: 'Description text content with font styles and color',
|
||||
'popup.root':
|
||||
'Popup panel root container with background color, shadow effects, color selection panel, slider controls and preset colors',
|
||||
},
|
||||
@@ -20,10 +26,11 @@ const locales = {
|
||||
const Block: React.FC<Readonly<ColorPickerProps>> = (props) => {
|
||||
const divRef = React.useRef<HTMLDivElement>(null);
|
||||
return (
|
||||
<div ref={divRef} style={{ height: 300 }}>
|
||||
<Flex ref={divRef} style={{ height: 300 }} align="flex-start" gap="small">
|
||||
<ColorPicker
|
||||
defaultValue="#1677ff"
|
||||
open
|
||||
showText
|
||||
{...props}
|
||||
getPopupContainer={() => divRef!.current!}
|
||||
styles={{
|
||||
@@ -32,7 +39,8 @@ const Block: React.FC<Readonly<ColorPickerProps>> = (props) => {
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<ColorPicker open={false} allowClear {...props} />
|
||||
</Flex>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -43,6 +51,9 @@ const App: React.FC = () => {
|
||||
componentName="ColorPicker"
|
||||
semantics={[
|
||||
{ name: 'root', desc: locale.root },
|
||||
{ name: 'body', desc: locale.body },
|
||||
{ name: 'content', desc: locale.content },
|
||||
{ name: 'description', desc: locale.description },
|
||||
{ name: 'popup.root', desc: locale['popup.root'] },
|
||||
]}
|
||||
>
|
||||
|
||||
@@ -59,10 +59,16 @@ export type ColorPickerSemanticName = keyof ColorPickerSemanticClassNames &
|
||||
|
||||
export type ColorPickerSemanticClassNames = {
|
||||
root?: string;
|
||||
body?: string;
|
||||
content?: string;
|
||||
description?: string;
|
||||
};
|
||||
|
||||
export type ColorPickerSemanticStyles = {
|
||||
root?: React.CSSProperties;
|
||||
body?: React.CSSProperties;
|
||||
content?: React.CSSProperties;
|
||||
description?: React.CSSProperties;
|
||||
};
|
||||
|
||||
export type ColorPickerClassNamesType = SemanticClassNamesType<
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import * as React from 'react';
|
||||
|
||||
export type SizeType = 'small' | 'middle' | 'large' | undefined;
|
||||
/**
|
||||
* Note: `middle` is deprecated and will be removed in v7, please use `medium` instead.
|
||||
*/
|
||||
export type SizeType = 'small' | 'medium' | 'middle' | 'large' | undefined;
|
||||
|
||||
const SizeContext = React.createContext<SizeType>(undefined);
|
||||
|
||||
|
||||
@@ -298,6 +298,7 @@ export type FormConfig = ComponentStyleConfig &
|
||||
| 'variant'
|
||||
| 'classNames'
|
||||
| 'styles'
|
||||
| 'tooltip'
|
||||
>;
|
||||
|
||||
export type FloatButtonConfig = ComponentStyleConfig &
|
||||
|
||||
@@ -133,7 +133,7 @@ const {
|
||||
| flex | Set Flex common props | { className?: string, style?: React.CSSProperties, vertical?: boolean } | - | 5.10.0 |
|
||||
| floatButton | Set FloatButton common props | { className?: string, style?: React.CSSProperties, classNames?: [FloatButtonProps\["classNames"\]](/components/float-button#semantic-dom), styles?: [FloatButtonProps\["styles"\]](/components/float-button#semantic-dom), backTopIcon?: React.ReactNode } | - | |
|
||||
| floatButtonGroup | Set FloatButton.Group common props | { closeIcon?: React.ReactNode, className?: string, style?: React.CSSProperties, classNames?: [FloatButtonProps\["classNames"\]](/components/float-button#semantic-dom), styles?: [FloatButtonProps\["styles"\]](/components/float-button#semantic-dom) } | - | |
|
||||
| form | Set Form common props | { className?: string, style?: React.CSSProperties, validateMessages?: [ValidateMessages](/components/form/#validatemessages), requiredMark?: boolean \| `optional`, scrollToFirstError?: boolean \| [Options](https://github.com/stipsan/scroll-into-view-if-needed/tree/ece40bd9143f48caf4b99503425ecb16b0ad8249#options), classNames?:[FormConfig\["classNames"\]](/components/form#semantic-dom), styles?: [FormConfig\["styles"\]](/components/form#semantic-dom) } | - | `requiredMark`: 4.8.0; `colon`: 4.18.0; `scrollToFirstError`: 5.2.0; `className` and `style`: 5.7.0 |
|
||||
| form | Set Form common props | { className?: string, style?: React.CSSProperties, validateMessages?: [ValidateMessages](/components/form/#validatemessages), requiredMark?: boolean \| `optional`, scrollToFirstError?: boolean \| [Options](https://github.com/stipsan/scroll-into-view-if-needed/tree/ece40bd9143f48caf4b99503425ecb16b0ad8249#options), classNames?:[FormConfig\["classNames"\]](/components/form#semantic-dom), styles?: [FormConfig\["styles"\]](/components/form#semantic-dom), tooltip?: [TooltipProps](/components/tooltip#api) & { icon?: ReactNode } } | - | `requiredMark`: 4.8.0; `colon`: 4.18.0; `scrollToFirstError`: 5.2.0; `className` and `style`: 5.7.0; `tooltip`: 6.3.0 |
|
||||
| image | Set Image common props | { className?: string, style?: React.CSSProperties, preview?: { closeIcon?: React.ReactNode, classNames?:[ImageConfig\["classNames"\]](/components/image#semantic-dom), styles?: [ImageConfig\["styles"\]](/components/image#semantic-dom) }, fallback?: string } | - | 5.7.0, `closeIcon`: 5.14.0, `classNames` and `styles`: 6.0.0 |
|
||||
| input | Set Input common props | { autoComplete?: string, className?: string, style?: React.CSSProperties, allowClear?: boolean \| { clearIcon?: ReactNode } } | - | 4.2.0, `allowClear`: 5.15.0 |
|
||||
| inputNumber | Set InputNumber common props | { className?: string, style?: React.CSSProperties, classNames?: [InputNumberConfig\["classNames"\]](/components/input-number#semantic-dom), styles?: [InputNumberConfig\["styles"\]](/components/input-number#semantic-dom) } | - | |
|
||||
|
||||
@@ -135,7 +135,7 @@ const {
|
||||
| flex | 设置 Flex 组件的通用属性 | { className?: string, style?: React.CSSProperties, vertical?: boolean } | - | 5.10.0 |
|
||||
| floatButton | 设置 FloatButton 组件的通用属性 | { className?: string, style?: React.CSSProperties, classNames?: [FloatButtonProps\["classNames"\]](/components/float-button-cn#semantic-dom), styles?: [FloatButtonProps\["styles"\]](/components/float-button-cn#semantic-dom), backTopIcon?: React.ReactNode } | - | |
|
||||
| floatButtonGroup | 设置 FloatButton.Group 组件的通用属性 | { closeIcon?: React.ReactNode, className?: string, style?: React.CSSProperties, classNames?: [FloatButtonProps\["classNames"\]](/components/float-button-cn#semantic-dom), styles?: [FloatButtonProps\["styles"\]](/components/float-button-cn#semantic-dom) } | - | |
|
||||
| form | 设置 Form 组件的通用属性 | { className?: string, style?: React.CSSProperties, validateMessages?: [ValidateMessages](/components/form-cn#validatemessages), requiredMark?: boolean \| `optional`, colon?: boolean, scrollToFirstError?: boolean \| [Options](https://github.com/stipsan/scroll-into-view-if-needed/tree/ece40bd9143f48caf4b99503425ecb16b0ad8249#options), classNames?:[FormConfig\["classNames"\]](/components/form-cn#semantic-dom), styles?: [FormConfig\["styles"\]](/components/form-cn#semantic-dom) } | - | `requiredMark`: 4.8.0; `colon`: 4.18.0; `scrollToFirstError`: 5.2.0; `className` 和 `style`: 5.7.0 |
|
||||
| form | 设置 Form 组件的通用属性 | { className?: string, style?: React.CSSProperties, validateMessages?: [ValidateMessages](/components/form-cn#validatemessages), requiredMark?: boolean \| `optional`, colon?: boolean, scrollToFirstError?: boolean \| [Options](https://github.com/stipsan/scroll-into-view-if-needed/tree/ece40bd9143f48caf4b99503425ecb16b0ad8249#options), classNames?:[FormConfig\["classNames"\]](/components/form-cn#semantic-dom), styles?: [FormConfig\["styles"\]](/components/form-cn#semantic-dom), tooltip?: [TooltipProps](/components/tooltip-cn#api) & { icon?: ReactNode } } | - | `requiredMark`: 4.8.0; `colon`: 4.18.0; `scrollToFirstError`: 5.2.0; `className` 和 `style`: 5.7.0; `tooltip`: 6.3.0 |
|
||||
| image | 设置 Image 组件的通用属性 | { className?: string, style?: React.CSSProperties, preview?: { closeIcon?: React.ReactNode, classNames?:[ImageConfig\["classNames"\]](/components/image-cn#semantic-dom), styles?: [ImageConfig\["styles"\]](/components/image-cn#semantic-dom) }, fallback?: string } | - | 5.7.0, `closeIcon`: 5.14.0, `classNames` 和 `styles`: 6.0.0 |
|
||||
| input | 设置 Input 组件的通用属性 | { autoComplete?: string, className?: string, style?: React.CSSProperties,classNames?:[InputConfig\["classNames"\]](/components/input-cn#semantic-input), styles?: [InputConfig\["styles"\]](/components/input-cn#semantic-input), allowClear?: boolean \| { clearIcon?: ReactNode } } | - | 5.7.0, `allowClear`: 5.15.0 |
|
||||
| inputNumber | 设置 Input 组件的通用属性 | { className?: string, style?: React.CSSProperties, classNames?: [InputNumberConfig\["classNames"\]](/components/input-number-cn#semantic-dom), styles?: [InputNumberConfig\["styles"\]](/components/input-number-cn#semantic-dom) } | - | |
|
||||
|
||||
@@ -2318,7 +2318,7 @@ exports[`renders components/descriptions/demo/style-class.tsx extend context cor
|
||||
class="ant-flex css-var-test-id ant-flex-align-stretch ant-flex-gap-middle ant-flex-vertical"
|
||||
>
|
||||
<div
|
||||
class="ant-descriptions acss-nk32ej ant-descriptions-small ant-descriptions-bordered css-var-test-id"
|
||||
class="ant-descriptions acss-ven0qr ant-descriptions-small ant-descriptions-bordered css-var-test-id"
|
||||
>
|
||||
<div
|
||||
class="ant-descriptions-header"
|
||||
@@ -2408,7 +2408,7 @@ exports[`renders components/descriptions/demo/style-class.tsx extend context cor
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-descriptions acss-nk32ej ant-descriptions-bordered css-var-test-id"
|
||||
class="ant-descriptions acss-ven0qr ant-descriptions-bordered css-var-test-id"
|
||||
style="border-radius: 8px; border: 1px solid rgb(205, 193, 255);"
|
||||
>
|
||||
<div
|
||||
|
||||
@@ -2148,7 +2148,7 @@ exports[`renders components/descriptions/demo/style-class.tsx correctly 1`] = `
|
||||
class="ant-flex css-var-test-id ant-flex-align-stretch ant-flex-gap-middle ant-flex-vertical"
|
||||
>
|
||||
<div
|
||||
class="ant-descriptions acss-nk32ej ant-descriptions-small ant-descriptions-bordered css-var-test-id"
|
||||
class="ant-descriptions acss-ven0qr ant-descriptions-small ant-descriptions-bordered css-var-test-id"
|
||||
>
|
||||
<div
|
||||
class="ant-descriptions-header"
|
||||
@@ -2230,7 +2230,7 @@ exports[`renders components/descriptions/demo/style-class.tsx correctly 1`] = `
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-descriptions acss-nk32ej ant-descriptions-bordered css-var-test-id"
|
||||
class="ant-descriptions acss-ven0qr ant-descriptions-bordered css-var-test-id"
|
||||
style="border-radius:8px;border:1px solid #CDC1FF"
|
||||
>
|
||||
<div
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import React from 'react';
|
||||
import { Descriptions, Flex } from 'antd';
|
||||
import type { DescriptionsProps } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
|
||||
const useStyle = createStyles(() => ({
|
||||
root: {
|
||||
padding: 10,
|
||||
},
|
||||
const classNames = createStaticStyles(({ css }) => ({
|
||||
root: css`
|
||||
padding: 10px;
|
||||
`,
|
||||
}));
|
||||
|
||||
const items: DescriptionsProps['items'] = [
|
||||
@@ -47,8 +47,6 @@ const stylesFn: DescriptionsProps['styles'] = (info) => {
|
||||
};
|
||||
|
||||
const App: React.FC = () => {
|
||||
const { styles: classNames } = useStyle();
|
||||
|
||||
const descriptionsProps: DescriptionsProps = {
|
||||
title: 'User Info',
|
||||
items,
|
||||
|
||||
@@ -117,15 +117,11 @@ const DrawerPanel: React.FC<DrawerPanelProps> = (props) => {
|
||||
});
|
||||
|
||||
const closablePlacement = React.useMemo<'start' | 'end' | undefined>(() => {
|
||||
const mergedClosableVal = closable ?? contextClosable;
|
||||
if (mergedClosableVal === false) {
|
||||
const merged = closable ?? contextClosable;
|
||||
if (merged === false) {
|
||||
return undefined;
|
||||
}
|
||||
if (
|
||||
typeof mergedClosableVal === 'object' &&
|
||||
mergedClosableVal &&
|
||||
mergedClosableVal.placement === 'end'
|
||||
) {
|
||||
if (typeof merged === 'object' && merged?.placement === 'end') {
|
||||
return 'end';
|
||||
}
|
||||
return 'start';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { useState } from 'react';
|
||||
import { Button, Drawer, Flex } from 'antd';
|
||||
import type { DrawerProps } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
|
||||
const lineStyle: React.CSSProperties = {
|
||||
lineHeight: '28px',
|
||||
@@ -22,11 +22,11 @@ const sharedContent = (
|
||||
</>
|
||||
);
|
||||
|
||||
const useStyles = createStyles(() => ({
|
||||
container: {
|
||||
borderRadius: 10,
|
||||
padding: 10,
|
||||
},
|
||||
const classNames = createStaticStyles(({ css }) => ({
|
||||
container: css`
|
||||
border-radius: 10px;
|
||||
padding: 10px;
|
||||
`,
|
||||
}));
|
||||
|
||||
const styles: DrawerProps['styles'] = {
|
||||
@@ -56,7 +56,6 @@ const stylesFn: DrawerProps['styles'] = (info) => {
|
||||
const App: React.FC = () => {
|
||||
const [drawerOpen, setOpen] = useState(false);
|
||||
const [drawerFnOpen, setFnOpen] = useState(false);
|
||||
const { styles: classNames } = useStyles();
|
||||
|
||||
const sharedProps: DrawerProps = {
|
||||
classNames,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Button, Empty, Flex } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
|
||||
import type { EmptyProps } from '..';
|
||||
|
||||
@@ -9,7 +9,7 @@ const emptySharedProps: EmptyProps = {
|
||||
children: <Button type="primary">Create Now</Button>,
|
||||
};
|
||||
|
||||
const useStyle = createStyles(({ css }) => ({
|
||||
const classNames = createStaticStyles(({ css }) => ({
|
||||
root: css`
|
||||
border: 1px dashed #ccc;
|
||||
padding: 16px;
|
||||
@@ -35,10 +35,8 @@ const stylesFn: EmptyProps['styles'] = ({ props }) => {
|
||||
};
|
||||
|
||||
const App: React.FC = () => {
|
||||
const { styles } = useStyle();
|
||||
|
||||
const classNames: EmptyProps['classNames'] = {
|
||||
root: styles.root,
|
||||
const emptyClassNames: EmptyProps['classNames'] = {
|
||||
root: classNames.root,
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -46,13 +44,13 @@ const App: React.FC = () => {
|
||||
<Empty
|
||||
{...emptySharedProps}
|
||||
description="Object styles"
|
||||
classNames={classNames}
|
||||
classNames={emptyClassNames}
|
||||
styles={stylesObject}
|
||||
/>
|
||||
<Empty
|
||||
{...emptySharedProps}
|
||||
description="Function styles"
|
||||
classNames={classNames}
|
||||
classNames={emptyClassNames}
|
||||
styles={stylesFn}
|
||||
/>
|
||||
</Flex>
|
||||
|
||||
@@ -21,6 +21,7 @@ import type { ColProps } from '../grid/col';
|
||||
import type { FormContextProps } from './context';
|
||||
import { FormContext, FormProvider, NoFormStyle, VariantContext } from './context';
|
||||
import type { FeedbackIcons } from './FormItem';
|
||||
import type { FormTooltipProps } from './FormItemLabel';
|
||||
import useForm from './hooks/useForm';
|
||||
import type { FormInstance } from './hooks/useForm';
|
||||
import useFormWarning from './hooks/useFormWarning';
|
||||
@@ -74,6 +75,7 @@ export interface FormProps<Values = any> extends Omit<RcFormProps<Values>, 'form
|
||||
requiredMark?: RequiredMark;
|
||||
rootClassName?: string;
|
||||
variant?: Variant;
|
||||
tooltip?: FormTooltipProps;
|
||||
}
|
||||
|
||||
const InternalForm: React.ForwardRefRenderFunction<FormRef, FormProps> = (props, ref) => {
|
||||
@@ -88,6 +90,7 @@ const InternalForm: React.ForwardRefRenderFunction<FormRef, FormProps> = (props,
|
||||
style: contextStyle,
|
||||
styles: contextStyles,
|
||||
classNames: contextClassNames,
|
||||
tooltip: contextTooltip,
|
||||
} = useComponentConfig('form');
|
||||
|
||||
const {
|
||||
@@ -112,6 +115,7 @@ const InternalForm: React.ForwardRefRenderFunction<FormRef, FormProps> = (props,
|
||||
variant,
|
||||
classNames,
|
||||
styles,
|
||||
tooltip,
|
||||
...restFormProps
|
||||
} = props;
|
||||
|
||||
@@ -140,6 +144,8 @@ const InternalForm: React.ForwardRefRenderFunction<FormRef, FormProps> = (props,
|
||||
|
||||
const mergedColon = colon ?? contextColon;
|
||||
|
||||
const mergedTooltip = { ...contextTooltip, ...tooltip };
|
||||
|
||||
const prefixCls = getPrefixCls('form', customizePrefixCls);
|
||||
|
||||
// Style
|
||||
@@ -198,6 +204,7 @@ const InternalForm: React.ForwardRefRenderFunction<FormRef, FormProps> = (props,
|
||||
itemRef: __INTERNAL__.itemRef,
|
||||
form: wrapForm,
|
||||
feedbackIcons,
|
||||
tooltip: mergedTooltip,
|
||||
classNames: mergedClassNames,
|
||||
styles: mergedStyles,
|
||||
}),
|
||||
@@ -213,6 +220,7 @@ const InternalForm: React.ForwardRefRenderFunction<FormRef, FormProps> = (props,
|
||||
feedbackIcons,
|
||||
mergedClassNames,
|
||||
mergedStyles,
|
||||
mergedTooltip,
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import useCSSVarCls from '../../config-provider/hooks/useCSSVarCls';
|
||||
import { FormContext, NoStyleItemContext } from '../context';
|
||||
import type { FormInstance, FormItemLayout } from '../Form';
|
||||
import type { FormItemInputProps } from '../FormItemInput';
|
||||
import type { FormItemLabelProps, LabelTooltipType } from '../FormItemLabel';
|
||||
import type { FormItemLabelProps } from '../FormItemLabel';
|
||||
import useChildren from '../hooks/useChildren';
|
||||
import useFormItemStatus from '../hooks/useFormItemStatus';
|
||||
import useFrameState from '../hooks/useFrameState';
|
||||
@@ -100,7 +100,6 @@ export interface FormItemProps<Values = any>
|
||||
hidden?: boolean;
|
||||
initialValue?: any;
|
||||
messageVariables?: Record<string, string>;
|
||||
tooltip?: LabelTooltipType;
|
||||
layout?: FormItemLayout;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ import * as React from 'react';
|
||||
import QuestionCircleOutlined from '@ant-design/icons/QuestionCircleOutlined';
|
||||
import { clsx } from 'clsx';
|
||||
|
||||
import convertToTooltipProps from '../_util/convertToTooltipProps';
|
||||
import type { ColProps } from '../grid/col';
|
||||
import Col from '../grid/col';
|
||||
import { useLocale } from '../locale';
|
||||
@@ -13,12 +12,13 @@ import type { FormContextProps } from './context';
|
||||
import { FormContext } from './context';
|
||||
import type { RequiredMark } from './Form';
|
||||
import type { FormLabelAlign } from './interface';
|
||||
import convertToTooltipProps from '../_util/convertToTooltipProps';
|
||||
|
||||
export type WrapperTooltipProps = TooltipProps & {
|
||||
export type FormTooltipProps = TooltipProps & {
|
||||
icon?: React.ReactElement;
|
||||
};
|
||||
|
||||
export type LabelTooltipType = WrapperTooltipProps | React.ReactNode;
|
||||
export type FormItemTooltipType = FormTooltipProps | React.ReactNode;
|
||||
|
||||
export interface FormItemLabelProps {
|
||||
colon?: boolean;
|
||||
@@ -30,7 +30,7 @@ export interface FormItemLabelProps {
|
||||
* @internal Used for pass `requiredMark` from `<Form />`
|
||||
*/
|
||||
requiredMark?: RequiredMark;
|
||||
tooltip?: LabelTooltipType;
|
||||
tooltip?: FormItemTooltipType;
|
||||
vertical?: boolean;
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ const FormItemLabel: React.FC<FormItemLabelProps & { required?: boolean; prefixC
|
||||
colon: contextColon,
|
||||
classNames: contextClassNames,
|
||||
styles: contextStyles,
|
||||
tooltip: contextTooltip,
|
||||
} = React.useContext<FormContextProps>(FormContext);
|
||||
|
||||
if (!label) {
|
||||
@@ -86,23 +87,19 @@ const FormItemLabel: React.FC<FormItemLabelProps & { required?: boolean; prefixC
|
||||
labelChildren = label.replace(/[:|:]\s*$/, '');
|
||||
}
|
||||
|
||||
// Tooltip
|
||||
const tooltipProps = convertToTooltipProps(tooltip);
|
||||
|
||||
const tooltipProps = convertToTooltipProps<FormTooltipProps>(tooltip, contextTooltip);
|
||||
if (tooltipProps) {
|
||||
const { icon = <QuestionCircleOutlined />, ...restTooltipProps } = tooltipProps;
|
||||
const tooltipNode: React.ReactNode = (
|
||||
<Tooltip {...restTooltipProps}>
|
||||
{React.cloneElement(icon, {
|
||||
className: `${prefixCls}-item-tooltip`,
|
||||
title: '',
|
||||
onClick: (e: React.MouseEvent) => {
|
||||
// Prevent label behavior in tooltip icon
|
||||
// https://github.com/ant-design/ant-design/issues/46154
|
||||
<Tooltip {...tooltipProps}>
|
||||
<span
|
||||
className={`${prefixCls}-item-tooltip`}
|
||||
onClick={(e: React.MouseEvent) => {
|
||||
e.preventDefault();
|
||||
},
|
||||
tabIndex: null,
|
||||
})}
|
||||
}}
|
||||
tabIndex={-1}
|
||||
>
|
||||
{tooltipProps.icon || tooltipProps.children || <QuestionCircleOutlined />}
|
||||
</span>
|
||||
</Tooltip>
|
||||
);
|
||||
|
||||
|
||||
@@ -11371,27 +11371,31 @@ exports[`renders components/form/demo/register.tsx extend context correctly 1`]
|
||||
Nickname
|
||||
<span
|
||||
aria-describedby="test-id"
|
||||
aria-label="question-circle"
|
||||
class="anticon anticon-question-circle ant-form-item-tooltip"
|
||||
role="img"
|
||||
title=""
|
||||
class="ant-form-item-tooltip"
|
||||
tabindex="-1"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
data-icon="question-circle"
|
||||
fill="currentColor"
|
||||
focusable="false"
|
||||
height="1em"
|
||||
viewBox="64 64 896 896"
|
||||
width="1em"
|
||||
<span
|
||||
aria-label="question-circle"
|
||||
class="anticon anticon-question-circle"
|
||||
role="img"
|
||||
>
|
||||
<path
|
||||
d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"
|
||||
/>
|
||||
<path
|
||||
d="M623.6 316.7C593.6 290.4 554 276 512 276s-81.6 14.5-111.6 40.7C369.2 344 352 380.7 352 420v7.6c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V420c0-44.1 43.1-80 96-80s96 35.9 96 80c0 31.1-22 59.6-56.1 72.7-21.2 8.1-39.2 22.3-52.1 40.9-13.1 19-19.9 41.8-19.9 64.9V620c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8v-22.7a48.3 48.3 0 0130.9-44.8c59-22.7 97.1-74.7 97.1-132.5.1-39.3-17.1-76-48.3-103.3zM472 732a40 40 0 1080 0 40 40 0 10-80 0z"
|
||||
/>
|
||||
</svg>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
data-icon="question-circle"
|
||||
fill="currentColor"
|
||||
focusable="false"
|
||||
height="1em"
|
||||
viewBox="64 64 896 896"
|
||||
width="1em"
|
||||
>
|
||||
<path
|
||||
d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"
|
||||
/>
|
||||
<path
|
||||
d="M623.6 316.7C593.6 290.4 554 276 512 276s-81.6 14.5-111.6 40.7C369.2 344 352 380.7 352 420v7.6c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V420c0-44.1 43.1-80 96-80s96 35.9 96 80c0 31.1-22 59.6-56.1 72.7-21.2 8.1-39.2 22.3-52.1 40.9-13.1 19-19.9 41.8-19.9 64.9V620c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8v-22.7a48.3 48.3 0 0130.9-44.8c59-22.7 97.1-74.7 97.1-132.5.1-39.3-17.1-76-48.3-103.3zM472 732a40 40 0 1080 0 40 40 0 10-80 0z"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</span>
|
||||
<div
|
||||
class="ant-tooltip ant-zoom-big-fast-appear ant-zoom-big-fast-appear-prepare ant-zoom-big-fast ant-tooltip-css-var css-var-test-id ant-tooltip-placement-top"
|
||||
@@ -12639,27 +12643,31 @@ exports[`renders components/form/demo/required-mark.tsx extend context correctly
|
||||
Field A
|
||||
<span
|
||||
aria-describedby="test-id"
|
||||
aria-label="question-circle"
|
||||
class="anticon anticon-question-circle ant-form-item-tooltip"
|
||||
role="img"
|
||||
title=""
|
||||
class="ant-form-item-tooltip"
|
||||
tabindex="-1"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
data-icon="question-circle"
|
||||
fill="currentColor"
|
||||
focusable="false"
|
||||
height="1em"
|
||||
viewBox="64 64 896 896"
|
||||
width="1em"
|
||||
<span
|
||||
aria-label="question-circle"
|
||||
class="anticon anticon-question-circle"
|
||||
role="img"
|
||||
>
|
||||
<path
|
||||
d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"
|
||||
/>
|
||||
<path
|
||||
d="M623.6 316.7C593.6 290.4 554 276 512 276s-81.6 14.5-111.6 40.7C369.2 344 352 380.7 352 420v7.6c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V420c0-44.1 43.1-80 96-80s96 35.9 96 80c0 31.1-22 59.6-56.1 72.7-21.2 8.1-39.2 22.3-52.1 40.9-13.1 19-19.9 41.8-19.9 64.9V620c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8v-22.7a48.3 48.3 0 0130.9-44.8c59-22.7 97.1-74.7 97.1-132.5.1-39.3-17.1-76-48.3-103.3zM472 732a40 40 0 1080 0 40 40 0 10-80 0z"
|
||||
/>
|
||||
</svg>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
data-icon="question-circle"
|
||||
fill="currentColor"
|
||||
focusable="false"
|
||||
height="1em"
|
||||
viewBox="64 64 896 896"
|
||||
width="1em"
|
||||
>
|
||||
<path
|
||||
d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"
|
||||
/>
|
||||
<path
|
||||
d="M623.6 316.7C593.6 290.4 554 276 512 276s-81.6 14.5-111.6 40.7C369.2 344 352 380.7 352 420v7.6c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V420c0-44.1 43.1-80 96-80s96 35.9 96 80c0 31.1-22 59.6-56.1 72.7-21.2 8.1-39.2 22.3-52.1 40.9-13.1 19-19.9 41.8-19.9 64.9V620c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8v-22.7a48.3 48.3 0 0130.9-44.8c59-22.7 97.1-74.7 97.1-132.5.1-39.3-17.1-76-48.3-103.3zM472 732a40 40 0 1080 0 40 40 0 10-80 0z"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</span>
|
||||
<div
|
||||
class="ant-tooltip ant-zoom-big-fast-appear ant-zoom-big-fast-appear-prepare ant-zoom-big-fast ant-tooltip-css-var css-var-test-id ant-tooltip-placement-top"
|
||||
@@ -12719,27 +12727,31 @@ exports[`renders components/form/demo/required-mark.tsx extend context correctly
|
||||
Field B
|
||||
<span
|
||||
aria-describedby="test-id"
|
||||
aria-label="info-circle"
|
||||
class="anticon anticon-info-circle ant-form-item-tooltip"
|
||||
role="img"
|
||||
title=""
|
||||
class="ant-form-item-tooltip"
|
||||
tabindex="-1"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
data-icon="info-circle"
|
||||
fill="currentColor"
|
||||
focusable="false"
|
||||
height="1em"
|
||||
viewBox="64 64 896 896"
|
||||
width="1em"
|
||||
<span
|
||||
aria-label="info-circle"
|
||||
class="anticon anticon-info-circle"
|
||||
role="img"
|
||||
>
|
||||
<path
|
||||
d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"
|
||||
/>
|
||||
<path
|
||||
d="M464 336a48 48 0 1096 0 48 48 0 10-96 0zm72 112h-48c-4.4 0-8 3.6-8 8v272c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V456c0-4.4-3.6-8-8-8z"
|
||||
/>
|
||||
</svg>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
data-icon="info-circle"
|
||||
fill="currentColor"
|
||||
focusable="false"
|
||||
height="1em"
|
||||
viewBox="64 64 896 896"
|
||||
width="1em"
|
||||
>
|
||||
<path
|
||||
d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"
|
||||
/>
|
||||
<path
|
||||
d="M464 336a48 48 0 1096 0 48 48 0 10-96 0zm72 112h-48c-4.4 0-8 3.6-8 8v272c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V456c0-4.4-3.6-8-8-8z"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</span>
|
||||
<div
|
||||
class="ant-tooltip ant-zoom-big-fast-appear ant-zoom-big-fast-appear-prepare ant-zoom-big-fast ant-tooltip-css-var css-var-test-id ant-tooltip-placement-top"
|
||||
|
||||
@@ -7638,27 +7638,31 @@ exports[`renders components/form/demo/register.tsx correctly 1`] = `
|
||||
>
|
||||
Nickname
|
||||
<span
|
||||
aria-label="question-circle"
|
||||
class="anticon anticon-question-circle ant-form-item-tooltip"
|
||||
role="img"
|
||||
title=""
|
||||
class="ant-form-item-tooltip"
|
||||
tabindex="-1"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
data-icon="question-circle"
|
||||
fill="currentColor"
|
||||
focusable="false"
|
||||
height="1em"
|
||||
viewBox="64 64 896 896"
|
||||
width="1em"
|
||||
<span
|
||||
aria-label="question-circle"
|
||||
class="anticon anticon-question-circle"
|
||||
role="img"
|
||||
>
|
||||
<path
|
||||
d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"
|
||||
/>
|
||||
<path
|
||||
d="M623.6 316.7C593.6 290.4 554 276 512 276s-81.6 14.5-111.6 40.7C369.2 344 352 380.7 352 420v7.6c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V420c0-44.1 43.1-80 96-80s96 35.9 96 80c0 31.1-22 59.6-56.1 72.7-21.2 8.1-39.2 22.3-52.1 40.9-13.1 19-19.9 41.8-19.9 64.9V620c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8v-22.7a48.3 48.3 0 0130.9-44.8c59-22.7 97.1-74.7 97.1-132.5.1-39.3-17.1-76-48.3-103.3zM472 732a40 40 0 1080 0 40 40 0 10-80 0z"
|
||||
/>
|
||||
</svg>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
data-icon="question-circle"
|
||||
fill="currentColor"
|
||||
focusable="false"
|
||||
height="1em"
|
||||
viewBox="64 64 896 896"
|
||||
width="1em"
|
||||
>
|
||||
<path
|
||||
d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"
|
||||
/>
|
||||
<path
|
||||
d="M623.6 316.7C593.6 290.4 554 276 512 276s-81.6 14.5-111.6 40.7C369.2 344 352 380.7 352 420v7.6c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V420c0-44.1 43.1-80 96-80s96 35.9 96 80c0 31.1-22 59.6-56.1 72.7-21.2 8.1-39.2 22.3-52.1 40.9-13.1 19-19.9 41.8-19.9 64.9V620c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8v-22.7a48.3 48.3 0 0130.9-44.8c59-22.7 97.1-74.7 97.1-132.5.1-39.3-17.1-76-48.3-103.3zM472 732a40 40 0 1080 0 40 40 0 10-80 0z"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
@@ -8529,27 +8533,31 @@ exports[`renders components/form/demo/required-mark.tsx correctly 1`] = `
|
||||
>
|
||||
Field A
|
||||
<span
|
||||
aria-label="question-circle"
|
||||
class="anticon anticon-question-circle ant-form-item-tooltip"
|
||||
role="img"
|
||||
title=""
|
||||
class="ant-form-item-tooltip"
|
||||
tabindex="-1"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
data-icon="question-circle"
|
||||
fill="currentColor"
|
||||
focusable="false"
|
||||
height="1em"
|
||||
viewBox="64 64 896 896"
|
||||
width="1em"
|
||||
<span
|
||||
aria-label="question-circle"
|
||||
class="anticon anticon-question-circle"
|
||||
role="img"
|
||||
>
|
||||
<path
|
||||
d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"
|
||||
/>
|
||||
<path
|
||||
d="M623.6 316.7C593.6 290.4 554 276 512 276s-81.6 14.5-111.6 40.7C369.2 344 352 380.7 352 420v7.6c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V420c0-44.1 43.1-80 96-80s96 35.9 96 80c0 31.1-22 59.6-56.1 72.7-21.2 8.1-39.2 22.3-52.1 40.9-13.1 19-19.9 41.8-19.9 64.9V620c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8v-22.7a48.3 48.3 0 0130.9-44.8c59-22.7 97.1-74.7 97.1-132.5.1-39.3-17.1-76-48.3-103.3zM472 732a40 40 0 1080 0 40 40 0 10-80 0z"
|
||||
/>
|
||||
</svg>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
data-icon="question-circle"
|
||||
fill="currentColor"
|
||||
focusable="false"
|
||||
height="1em"
|
||||
viewBox="64 64 896 896"
|
||||
width="1em"
|
||||
>
|
||||
<path
|
||||
d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"
|
||||
/>
|
||||
<path
|
||||
d="M623.6 316.7C593.6 290.4 554 276 512 276s-81.6 14.5-111.6 40.7C369.2 344 352 380.7 352 420v7.6c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V420c0-44.1 43.1-80 96-80s96 35.9 96 80c0 31.1-22 59.6-56.1 72.7-21.2 8.1-39.2 22.3-52.1 40.9-13.1 19-19.9 41.8-19.9 64.9V620c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8v-22.7a48.3 48.3 0 0130.9-44.8c59-22.7 97.1-74.7 97.1-132.5.1-39.3-17.1-76-48.3-103.3zM472 732a40 40 0 1080 0 40 40 0 10-80 0z"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
@@ -8588,27 +8596,31 @@ exports[`renders components/form/demo/required-mark.tsx correctly 1`] = `
|
||||
>
|
||||
Field B
|
||||
<span
|
||||
aria-label="info-circle"
|
||||
class="anticon anticon-info-circle ant-form-item-tooltip"
|
||||
role="img"
|
||||
title=""
|
||||
class="ant-form-item-tooltip"
|
||||
tabindex="-1"
|
||||
>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
data-icon="info-circle"
|
||||
fill="currentColor"
|
||||
focusable="false"
|
||||
height="1em"
|
||||
viewBox="64 64 896 896"
|
||||
width="1em"
|
||||
<span
|
||||
aria-label="info-circle"
|
||||
class="anticon anticon-info-circle"
|
||||
role="img"
|
||||
>
|
||||
<path
|
||||
d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"
|
||||
/>
|
||||
<path
|
||||
d="M464 336a48 48 0 1096 0 48 48 0 10-96 0zm72 112h-48c-4.4 0-8 3.6-8 8v272c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V456c0-4.4-3.6-8-8-8z"
|
||||
/>
|
||||
</svg>
|
||||
<svg
|
||||
aria-hidden="true"
|
||||
data-icon="info-circle"
|
||||
fill="currentColor"
|
||||
focusable="false"
|
||||
height="1em"
|
||||
viewBox="64 64 896 896"
|
||||
width="1em"
|
||||
>
|
||||
<path
|
||||
d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372 372 166.6 372 372-166.6 372-372 372z"
|
||||
/>
|
||||
<path
|
||||
d="M464 336a48 48 0 1096 0 48 48 0 10-96 0zm72 112h-48c-4.4 0-8 3.6-8 8v272c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V456c0-4.4-3.6-8-8-8z"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</span>
|
||||
<span
|
||||
class="ant-form-item-optional"
|
||||
|
||||
@@ -1601,7 +1601,7 @@ describe('Form', () => {
|
||||
expect(container.querySelector('.ant-tooltip-container')).toHaveTextContent('Bamboo');
|
||||
});
|
||||
|
||||
it('config tooltip should show when hover on icon', async () => {
|
||||
it('TooltipProps', async () => {
|
||||
const { container } = render(
|
||||
<Form>
|
||||
<Form.Item label="light" tooltip={{ title: 'Bamboo' }}>
|
||||
@@ -1616,6 +1616,24 @@ describe('Form', () => {
|
||||
|
||||
expect(container.querySelector('.ant-tooltip-container')).toHaveTextContent('Bamboo');
|
||||
});
|
||||
|
||||
it('ConfigProvider', async () => {
|
||||
const { container } = render(
|
||||
<ConfigProvider form={{ tooltip: { icon: <span className="foobar">Foobar</span> } }}>
|
||||
<Form>
|
||||
<Form.Item label="light" tooltip={{ title: 'Bamboo' }}>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</ConfigProvider>,
|
||||
);
|
||||
|
||||
fireEvent.mouseEnter(container.querySelector('.foobar')!);
|
||||
fireEvent.click(container.querySelector('.foobar')!);
|
||||
await waitFakeTimer();
|
||||
|
||||
expect(container.querySelector('.ant-tooltip-container')).toHaveTextContent('Bamboo');
|
||||
});
|
||||
});
|
||||
|
||||
it('warningOnly validate', async () => {
|
||||
|
||||
@@ -15,6 +15,7 @@ import type {
|
||||
RequiredMark,
|
||||
} from './Form';
|
||||
import type { FeedbackIcons, ValidateStatus } from './FormItem';
|
||||
import type { FormTooltipProps } from './FormItemLabel';
|
||||
import type { FormLabelAlign, NamePath } from './interface';
|
||||
|
||||
/** Form Context. Set top form style and pass to Form Item usage. */
|
||||
@@ -32,6 +33,7 @@ export interface FormContextProps {
|
||||
itemRef: (name: (string | number)[]) => (node: React.ReactElement) => void;
|
||||
form?: FormInstance;
|
||||
feedbackIcons?: FeedbackIcons;
|
||||
tooltip?: FormTooltipProps;
|
||||
}
|
||||
|
||||
export const FormContext = React.createContext<FormContextProps>({
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import React from 'react';
|
||||
import { AlertFilled, CloseSquareFilled } from '@ant-design/icons';
|
||||
import { Button, Form, Input, Mentions, Tooltip } from 'antd';
|
||||
import { createStyles, css } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import uniqueId from 'lodash/uniqueId';
|
||||
|
||||
const useStyle = createStyles(() => ({
|
||||
const classNames = createStaticStyles(({ css }) => ({
|
||||
'custom-feedback-icons': css`
|
||||
.ant-form-item-feedback-icon {
|
||||
pointer-events: all;
|
||||
@@ -14,7 +14,6 @@ const useStyle = createStyles(() => ({
|
||||
|
||||
const App: React.FC = () => {
|
||||
const [form] = Form.useForm();
|
||||
const { styles } = useStyle();
|
||||
|
||||
return (
|
||||
<Form
|
||||
@@ -36,7 +35,7 @@ const App: React.FC = () => {
|
||||
<Form.Item
|
||||
name="custom-feedback-test-item"
|
||||
label="Test"
|
||||
className={styles['custom-feedback-icons']}
|
||||
className={classNames['custom-feedback-icons']}
|
||||
rules={[{ required: true, type: 'email' }, { min: 10 }]}
|
||||
help=""
|
||||
hasFeedback
|
||||
@@ -46,7 +45,7 @@ const App: React.FC = () => {
|
||||
<Form.Item
|
||||
name="custom-feedback-test-item2"
|
||||
label="Test"
|
||||
className={styles['custom-feedback-icons']}
|
||||
className={classNames['custom-feedback-icons']}
|
||||
rules={[{ required: true, type: 'email' }, { min: 10 }]}
|
||||
help=""
|
||||
hasFeedback={{
|
||||
@@ -69,7 +68,7 @@ const App: React.FC = () => {
|
||||
<Form.Item
|
||||
name="custom-feedback-test-item3"
|
||||
label="Test"
|
||||
className={styles['custom-feedback-icons']}
|
||||
className={classNames['custom-feedback-icons']}
|
||||
hasFeedback
|
||||
validateStatus="success"
|
||||
initialValue="@mention1"
|
||||
|
||||
@@ -85,6 +85,7 @@ Common props ref:[Common props](/docs/react/common-props)
|
||||
| scrollToFirstError | Auto scroll to first failed field when submit | boolean \| [Options](https://github.com/stipsan/scroll-into-view-if-needed/tree/ece40bd9143f48caf4b99503425ecb16b0ad8249#options) \| { focus: boolean } | false | focus: 5.24.0 |
|
||||
| size | Set field component size (antd components only) | `small` \| `middle` \| `large` | - | |
|
||||
| styles | Customize inline style for each semantic structure inside the component. Supports object or function. | Record<[SemanticDOM](#semantic-dom), CSSProperties> \| (info: { props })=> Record<[SemanticDOM](#semantic-dom), CSSProperties> | - | |
|
||||
| tooltip | Config tooltip props | [TooltipProps](/components/tooltip#api) & { icon?: ReactNode } | - | 6.3.0 |
|
||||
| validateMessages | Validation prompt template, description [see below](#validatemessages) | [ValidateMessages](https://github.com/ant-design/ant-design/blob/6234509d18bac1ac60fbb3f92a5b2c6a6361295a/components/locale/en_US.ts#L88-L134) | - | |
|
||||
| validateTrigger | Config field validate trigger | string \| string\[] | `onChange` | 4.3.0 |
|
||||
| variant | Variant of components inside form | `outlined` \| `borderless` \| `filled` \| `underlined` | `outlined` | 5.13.0 \| `underlined`: 5.24.0 |
|
||||
@@ -150,7 +151,7 @@ Form field component for data bidirectional binding, validation, layout, and so
|
||||
| required | Display required style. It will be generated by the validation rule | boolean | false | |
|
||||
| rules | Rules for field validation. Click [here](#form-demo-basic) to see an example | [Rule](#rule)\[] | - | |
|
||||
| shouldUpdate | Custom field update logic. See [below](#shouldupdate) | boolean \| (prevValue, curValue) => boolean | false | |
|
||||
| tooltip | Config tooltip info | ReactNode \| [TooltipProps & { icon: ReactNode }](/components/tooltip#api) | - | 4.7.0 |
|
||||
| tooltip | Config tooltip content | ReactNode \| ([TooltipProps](/components/tooltip#api) & { icon?: ReactNode }) | - | 4.7.0 |
|
||||
| trigger | When to collect the value of children node. Click [here](#form-demo-customized-form-controls) to see an example | string | `onChange` | |
|
||||
| validateDebounce | Delay milliseconds to start validation | number | - | 5.9.0 |
|
||||
| validateFirst | Whether stop validate on first rule of error for this field. Will parallel validate when `parallel` configured | boolean \| `parallel` | false | `parallel`: 4.5.0 |
|
||||
|
||||
@@ -86,6 +86,7 @@ coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*ylFATY6w-ygAAA
|
||||
| scrollToFirstError | 提交失败自动滚动到第一个错误字段 | boolean \| [Options](https://github.com/stipsan/scroll-into-view-if-needed/tree/ece40bd9143f48caf4b99503425ecb16b0ad8249#options) \| { focus: boolean } | false | focus: 5.24.0 |
|
||||
| size | 设置字段组件的尺寸(仅限 antd 组件) | `small` \| `middle` \| `large` | - | |
|
||||
| styles | 用于自定义组件内部各语义化结构的行内 style,支持对象或函数 | Record<[SemanticDOM](#semantic-dom), CSSProperties> \| (info: { props })=> Record<[SemanticDOM](#semantic-dom), CSSProperties> | - | |
|
||||
| tooltip | 配置提示属性 | [TooltipProps](/components/tooltip-cn#api) & { icon?: ReactNode } | - | 6.3.0 |
|
||||
| validateMessages | 验证提示模板,说明[见下](#validatemessages) | [ValidateMessages](https://github.com/ant-design/ant-design/blob/6234509d18bac1ac60fbb3f92a5b2c6a6361295a/components/locale/en_US.ts#L88-L134) | - | |
|
||||
| validateTrigger | 统一设置字段触发验证的时机 | string \| string\[] | `onChange` | 4.3.0 |
|
||||
| variant | 表单内控件变体 | `outlined` \| `borderless` \| `filled` \| `underlined` | `outlined` | 5.13.0 \| `underlined`: 5.24.0 |
|
||||
@@ -151,7 +152,7 @@ const validateMessages = {
|
||||
| required | 必填样式设置。如不设置,则会根据校验规则自动生成 | boolean | false | |
|
||||
| rules | 校验规则,设置字段的校验逻辑。点击[此处](#form-demo-basic)查看示例 | [Rule](#rule)\[] | - | |
|
||||
| shouldUpdate | 自定义字段更新逻辑,说明[见下](#shouldupdate) | boolean \| (prevValue, curValue) => boolean | false | |
|
||||
| tooltip | 配置提示信息 | ReactNode \| [TooltipProps & { icon: ReactNode }](/components/tooltip-cn#api) | - | 4.7.0 |
|
||||
| tooltip | 配置提示信息 | ReactNode \| ([TooltipProps](/components/tooltip-cn#api) & { icon?: ReactNode }) | - | 4.7.0 |
|
||||
| trigger | 设置收集字段值变更的时机。点击[此处](#form-demo-customized-form-controls)查看示例 | string | `onChange` | |
|
||||
| validateFirst | 当某一规则校验不通过时,是否停止剩下的规则的校验。设置 `parallel` 时会并行校验 | boolean \| `parallel` | false | `parallel`: 4.5.0 |
|
||||
| validateDebounce | 设置防抖,延迟毫秒数后进行校验 | number | - | 5.9.0 |
|
||||
|
||||
@@ -726,7 +726,7 @@ exports[`renders components/image/demo/style-class.tsx extend context correctly
|
||||
class="ant-flex css-var-test-id ant-flex-gap-middle"
|
||||
>
|
||||
<div
|
||||
class="ant-image css-var-test-id ant-image-css-var acss-1spuuhl"
|
||||
class="ant-image css-var-test-id ant-image-css-var acss-1tjmp0k"
|
||||
style="width: 160px;"
|
||||
>
|
||||
<img
|
||||
@@ -741,7 +741,7 @@ exports[`renders components/image/demo/style-class.tsx extend context correctly
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="ant-image css-var-test-id ant-image-css-var acss-1spuuhl"
|
||||
class="ant-image css-var-test-id ant-image-css-var acss-1tjmp0k"
|
||||
style="width: 160px; border: 2px solid rgb(165, 148, 249); border-radius: 8px; padding: 4px; transition: all 0.3s ease;"
|
||||
>
|
||||
<img
|
||||
|
||||
@@ -697,7 +697,7 @@ exports[`renders components/image/demo/style-class.tsx correctly 1`] = `
|
||||
class="ant-flex css-var-test-id ant-flex-gap-middle"
|
||||
>
|
||||
<div
|
||||
class="ant-image css-var-test-id ant-image-css-var acss-1spuuhl"
|
||||
class="ant-image css-var-test-id ant-image-css-var acss-1tjmp0k"
|
||||
style="width:160px"
|
||||
>
|
||||
<img
|
||||
@@ -712,7 +712,7 @@ exports[`renders components/image/demo/style-class.tsx correctly 1`] = `
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="ant-image css-var-test-id ant-image-css-var acss-1spuuhl"
|
||||
class="ant-image css-var-test-id ant-image-css-var acss-1tjmp0k"
|
||||
style="width:160px;border:2px solid #A594F9;border-radius:8px;padding:4px;transition:all 0.3s ease"
|
||||
>
|
||||
<img
|
||||
|
||||
@@ -2,13 +2,13 @@ import React from 'react';
|
||||
import { Flex, Image, theme } from 'antd';
|
||||
import type { ImageProps } from 'antd';
|
||||
import type { ImageProps as RcImageProps } from '@rc-component/image';
|
||||
import { createStyles, css } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
import { clsx } from 'clsx';
|
||||
|
||||
import useLocale from '../../../.dumi/hooks/useLocale';
|
||||
import SemanticPreview from '../../../.dumi/theme/common/SemanticPreview';
|
||||
|
||||
const useStyle = createStyles(() => ({
|
||||
const styles = createStaticStyles(({ css }) => ({
|
||||
cover: css`
|
||||
&.semantic-mark-active {
|
||||
opacity: 1;
|
||||
@@ -53,8 +53,6 @@ const Block: React.FC<Readonly<ImagePropsBlock>> = ({ classNames, ...restProps }
|
||||
|
||||
const { token } = theme.useToken();
|
||||
|
||||
const { styles } = useStyle();
|
||||
|
||||
return (
|
||||
<Flex vertical align="center" style={{ minHeight: '100%', width: '100%' }}>
|
||||
<Flex style={{ padding: token.padding, flex: 'none' }} justify="center">
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import React from 'react';
|
||||
import { Flex, Image } from 'antd';
|
||||
import type { ImageProps } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
|
||||
const useStyles = createStyles(() => ({
|
||||
root: {
|
||||
padding: 4,
|
||||
borderRadius: 8,
|
||||
overflow: 'hidden',
|
||||
},
|
||||
const classNames = createStaticStyles(({ css }) => ({
|
||||
root: css`
|
||||
padding: 4px;
|
||||
border-radius: 8px;
|
||||
overflow: hidden;
|
||||
`,
|
||||
}));
|
||||
|
||||
const styles: ImageProps['styles'] = {
|
||||
@@ -36,8 +36,6 @@ const stylesFn: ImageProps['styles'] = (info) => {
|
||||
};
|
||||
|
||||
const App: React.FC = () => {
|
||||
const { styles: classNames } = useStyles();
|
||||
|
||||
const sharedProps: ImageProps = {
|
||||
src: 'https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png',
|
||||
width: 160,
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import React from 'react';
|
||||
import { Flex, Input } from 'antd';
|
||||
import type { GetProps } from 'antd';
|
||||
import { createStyles } from 'antd-style';
|
||||
import { createStaticStyles } from 'antd-style';
|
||||
|
||||
const useStyles = createStyles(({ css, cssVar }) => ({
|
||||
const styles = createStaticStyles(({ css, cssVar }) => ({
|
||||
focusEffect: css`
|
||||
border-width: ${cssVar.lineWidth};
|
||||
border-radius: ${cssVar.borderRadius};
|
||||
@@ -89,7 +89,7 @@ const stylesFnSearch: SearchProps['styles'] = (info) => {
|
||||
};
|
||||
|
||||
const App: React.FC = () => {
|
||||
const { styles: classNames } = useStyles();
|
||||
const classNames = styles;
|
||||
return (
|
||||
<Flex vertical gap="large">
|
||||
<Input
|
||||
|
||||
@@ -911,11 +911,11 @@ exports[`renders components/masonry/demo/style-class.tsx extend context correctl
|
||||
classNames and styles Object
|
||||
</h4>
|
||||
<div
|
||||
class="ant-masonry acss-1ejhsap css-var-test-id"
|
||||
class="ant-masonry acss-fuabzt css-var-test-id"
|
||||
style="height: 260px; border-radius: 12px; padding: 20px; background-color: rgba(250, 250, 250, 0.5);"
|
||||
>
|
||||
<div
|
||||
class="ant-masonry-item acss-3iocwh ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
class="ant-masonry-item acss-w4ipoa ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
style="transform: scale(0.98); transition: transform 0.2s ease; border: 1px solid rgb(204, 204, 204); --ant-masonry-item-width: calc((100% + 16px) / 4); inset-inline-start: calc(var(--ant-masonry-item-width) * 0); width: calc(var(--ant-masonry-item-width) - 16px); position: absolute;"
|
||||
>
|
||||
<div
|
||||
@@ -930,7 +930,7 @@ exports[`renders components/masonry/demo/style-class.tsx extend context correctl
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-masonry-item acss-3iocwh ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
class="ant-masonry-item acss-w4ipoa ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
style="transform: scale(0.98); transition: transform 0.2s ease; border: 1px solid rgb(204, 204, 204); --ant-masonry-item-width: calc((100% + 16px) / 4); inset-inline-start: calc(var(--ant-masonry-item-width) * 0); width: calc(var(--ant-masonry-item-width) - 16px); position: absolute;"
|
||||
>
|
||||
<div
|
||||
@@ -945,7 +945,7 @@ exports[`renders components/masonry/demo/style-class.tsx extend context correctl
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-masonry-item acss-3iocwh ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
class="ant-masonry-item acss-w4ipoa ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
style="transform: scale(0.98); transition: transform 0.2s ease; border: 1px solid rgb(204, 204, 204); --ant-masonry-item-width: calc((100% + 16px) / 4); inset-inline-start: calc(var(--ant-masonry-item-width) * 0); width: calc(var(--ant-masonry-item-width) - 16px); position: absolute;"
|
||||
>
|
||||
<div
|
||||
@@ -960,7 +960,7 @@ exports[`renders components/masonry/demo/style-class.tsx extend context correctl
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-masonry-item acss-3iocwh ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
class="ant-masonry-item acss-w4ipoa ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
style="transform: scale(0.98); transition: transform 0.2s ease; border: 1px solid rgb(204, 204, 204); --ant-masonry-item-width: calc((100% + 16px) / 4); inset-inline-start: calc(var(--ant-masonry-item-width) * 0); width: calc(var(--ant-masonry-item-width) - 16px); position: absolute;"
|
||||
>
|
||||
<div
|
||||
@@ -975,7 +975,7 @@ exports[`renders components/masonry/demo/style-class.tsx extend context correctl
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-masonry-item acss-3iocwh ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
class="ant-masonry-item acss-w4ipoa ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
style="transform: scale(0.98); transition: transform 0.2s ease; border: 1px solid rgb(204, 204, 204); --ant-masonry-item-width: calc((100% + 16px) / 4); inset-inline-start: calc(var(--ant-masonry-item-width) * 0); width: calc(var(--ant-masonry-item-width) - 16px); position: absolute;"
|
||||
>
|
||||
<div
|
||||
@@ -990,7 +990,7 @@ exports[`renders components/masonry/demo/style-class.tsx extend context correctl
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-masonry-item acss-3iocwh ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
class="ant-masonry-item acss-w4ipoa ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
style="transform: scale(0.98); transition: transform 0.2s ease; border: 1px solid rgb(204, 204, 204); --ant-masonry-item-width: calc((100% + 16px) / 4); inset-inline-start: calc(var(--ant-masonry-item-width) * 0); width: calc(var(--ant-masonry-item-width) - 16px); position: absolute;"
|
||||
>
|
||||
<div
|
||||
@@ -1005,7 +1005,7 @@ exports[`renders components/masonry/demo/style-class.tsx extend context correctl
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-masonry-item acss-3iocwh ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
class="ant-masonry-item acss-w4ipoa ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
style="transform: scale(0.98); transition: transform 0.2s ease; border: 1px solid rgb(204, 204, 204); --ant-masonry-item-width: calc((100% + 16px) / 4); inset-inline-start: calc(var(--ant-masonry-item-width) * 0); width: calc(var(--ant-masonry-item-width) - 16px); position: absolute;"
|
||||
>
|
||||
<div
|
||||
@@ -1020,7 +1020,7 @@ exports[`renders components/masonry/demo/style-class.tsx extend context correctl
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-masonry-item acss-3iocwh ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
class="ant-masonry-item acss-w4ipoa ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
style="transform: scale(0.98); transition: transform 0.2s ease; border: 1px solid rgb(204, 204, 204); --ant-masonry-item-width: calc((100% + 16px) / 4); inset-inline-start: calc(var(--ant-masonry-item-width) * 0); width: calc(var(--ant-masonry-item-width) - 16px); position: absolute;"
|
||||
>
|
||||
<div
|
||||
@@ -1047,11 +1047,11 @@ exports[`renders components/masonry/demo/style-class.tsx extend context correctl
|
||||
classNames and styles Function
|
||||
</h4>
|
||||
<div
|
||||
class="ant-masonry acss-1ejhsap css-var-test-id"
|
||||
class="ant-masonry acss-fuabzt css-var-test-id"
|
||||
style="height: 280px; border: 2px solid rgb(24, 144, 255); padding: 20px; background-color: rgba(240, 248, 255, 0.6);"
|
||||
>
|
||||
<div
|
||||
class="ant-masonry-item acss-3iocwh ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
class="ant-masonry-item acss-w4ipoa ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
style="box-shadow: 0 2px 8px rgba(0,0,0,0.1); border: 1px solid rgb(24, 144, 255); --ant-masonry-item-width: calc((100% + 12px) / 3); inset-inline-start: calc(var(--ant-masonry-item-width) * 0); width: calc(var(--ant-masonry-item-width) - 12px); position: absolute;"
|
||||
>
|
||||
<div
|
||||
@@ -1066,7 +1066,7 @@ exports[`renders components/masonry/demo/style-class.tsx extend context correctl
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-masonry-item acss-3iocwh ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
class="ant-masonry-item acss-w4ipoa ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
style="box-shadow: 0 2px 8px rgba(0,0,0,0.1); border: 1px solid rgb(24, 144, 255); --ant-masonry-item-width: calc((100% + 12px) / 3); inset-inline-start: calc(var(--ant-masonry-item-width) * 0); width: calc(var(--ant-masonry-item-width) - 12px); position: absolute;"
|
||||
>
|
||||
<div
|
||||
@@ -1081,7 +1081,7 @@ exports[`renders components/masonry/demo/style-class.tsx extend context correctl
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-masonry-item acss-3iocwh ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
class="ant-masonry-item acss-w4ipoa ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
style="box-shadow: 0 2px 8px rgba(0,0,0,0.1); border: 1px solid rgb(24, 144, 255); --ant-masonry-item-width: calc((100% + 12px) / 3); inset-inline-start: calc(var(--ant-masonry-item-width) * 0); width: calc(var(--ant-masonry-item-width) - 12px); position: absolute;"
|
||||
>
|
||||
<div
|
||||
@@ -1096,7 +1096,7 @@ exports[`renders components/masonry/demo/style-class.tsx extend context correctl
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-masonry-item acss-3iocwh ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
class="ant-masonry-item acss-w4ipoa ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
style="box-shadow: 0 2px 8px rgba(0,0,0,0.1); border: 1px solid rgb(24, 144, 255); --ant-masonry-item-width: calc((100% + 12px) / 3); inset-inline-start: calc(var(--ant-masonry-item-width) * 0); width: calc(var(--ant-masonry-item-width) - 12px); position: absolute;"
|
||||
>
|
||||
<div
|
||||
@@ -1111,7 +1111,7 @@ exports[`renders components/masonry/demo/style-class.tsx extend context correctl
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-masonry-item acss-3iocwh ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
class="ant-masonry-item acss-w4ipoa ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
style="box-shadow: 0 2px 8px rgba(0,0,0,0.1); border: 1px solid rgb(24, 144, 255); --ant-masonry-item-width: calc((100% + 12px) / 3); inset-inline-start: calc(var(--ant-masonry-item-width) * 0); width: calc(var(--ant-masonry-item-width) - 12px); position: absolute;"
|
||||
>
|
||||
<div
|
||||
@@ -1126,7 +1126,7 @@ exports[`renders components/masonry/demo/style-class.tsx extend context correctl
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="ant-masonry-item acss-3iocwh ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
class="ant-masonry-item acss-w4ipoa ant-masonry-item-fade-appear ant-masonry-item-fade-appear-start ant-masonry-item-fade"
|
||||
style="box-shadow: 0 2px 8px rgba(0,0,0,0.1); border: 1px solid rgb(24, 144, 255); --ant-masonry-item-width: calc((100% + 12px) / 3); inset-inline-start: calc(var(--ant-masonry-item-width) * 0); width: calc(var(--ant-masonry-item-width) - 12px); position: absolute;"
|
||||
>
|
||||
<div
|
||||
|
||||
@@ -40,7 +40,7 @@ exports[`renders components/masonry/demo/style-class.tsx correctly 1`] = `
|
||||
classNames and styles Object
|
||||
</h4>
|
||||
<div
|
||||
class="ant-masonry acss-1ejhsap css-var-test-id"
|
||||
class="ant-masonry acss-fuabzt css-var-test-id"
|
||||
style="height:260px;border-radius:12px;padding:20px;background-color:rgba(250,250,250,0.5)"
|
||||
/>
|
||||
</div>
|
||||
@@ -55,7 +55,7 @@ exports[`renders components/masonry/demo/style-class.tsx correctly 1`] = `
|
||||
classNames and styles Function
|
||||
</h4>
|
||||
<div
|
||||
class="ant-masonry acss-1ejhsap css-var-test-id"
|
||||
class="ant-masonry acss-fuabzt css-var-test-id"
|
||||
style="height:280px;border:2px solid #1890ff;padding:20px;background-color:rgba(240,248,255,.6)"
|
||||
/>
|
||||
</div>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user