Skip to content

Commit 372a110

Browse files
committed
fix: should not clean token when token change
1 parent f433802 commit 372a110

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

docs/examples/components/Button.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { useToken } from './theme';
1212

1313
interface ButtonToken extends DerivativeToken {
1414
buttonPadding: string;
15+
buttonBorderBottomWidth: string;
1516
}
1617

1718
// 通用框架
@@ -62,6 +63,7 @@ const genDefaultButtonStyle = (
6263
genSolidButtonStyle(prefixCls, token, () => ({
6364
backgroundColor: token.componentBackgroundColor,
6465
color: token.textColor,
66+
borderWidth: token.buttonBorderBottomWidth,
6567

6668
'&:hover': {
6769
borderColor: token.primaryColor,
@@ -137,6 +139,7 @@ const Button = ({ className, type, ...restProps }: ButtonProps) => {
137139
},
138140
() => ({
139141
buttonPadding: '4px 8px',
142+
buttonBorderBottomWidth: `calc(${token.borderWidth} * 2)`,
140143
}),
141144
);
142145

docs/examples/css-var.tsx

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ const Demo = () => (
1515

1616
export default function App() {
1717
const [show, setShow] = React.useState(true);
18-
1918
const [, forceUpdate] = React.useState({});
19+
const [color, setColor] = React.useState('royalblue');
2020
React.useEffect(() => {
2121
forceUpdate({});
2222
}, []);
@@ -30,13 +30,15 @@ export default function App() {
3030
Show Components
3131
</label>
3232

33+
<button onClick={() => { setColor((prev) => prev === 'royalblue' ? 'mediumslateblue' : 'royalblue')}}>Change theme</button>
34+
3335
{show && (
3436
<div>
3537
<Demo />
3638
<br />
3739
<DesignTokenProvider
3840
value={{
39-
token: { primaryColor: 'green' },
41+
token: { primaryColor: color },
4042
}}
4143
>
4244
<Demo />

src/hooks/useCacheToken.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export default function useCacheToken<
210210
) as [any, string];
211211
tokenWithCssVar._hashId = hashId;
212212

213-
recordCleanToken(hashId);
213+
recordCleanToken(cssVar.key);
214214
return [tokenWithCssVar, hashCls, actualToken, cssVarsStr, cssVar.key];
215215
},
216216
([, , , , themeKey]) => {

0 commit comments

Comments
 (0)