Skip to content

Commit 602292f

Browse files
authored
fix(Switch): fixed multiple color value errors (#687)
* fix(Switch): fixed multiple color value errors * test: update snapshots * chore: update _common
1 parent 0a7caae commit 602292f

File tree

6 files changed

+36
-33
lines changed

6 files changed

+36
-33
lines changed

src/switch/Switch.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ const Switch = forwardRef<HTMLDivElement, SwitchProps>((originalProps, ref) => {
4242
);
4343

4444
const dotClasses = classNames(`${switchClass}__dot`, `${switchClass}__dot--${props.size}`, {
45+
[`${switchClass}__dot--disabled`]: disabled || loading,
4546
[`${switchClass}__dot--checked`]: checked,
4647
[`${switchClass}__dot--plain`]: isArray(label) && label.length !== 2 && !loading,
4748
});
@@ -59,7 +60,7 @@ const Switch = forwardRef<HTMLDivElement, SwitchProps>((originalProps, ref) => {
5960
};
6061

6162
const readerContent = React.useMemo<React.ReactNode>(() => {
62-
if (loading) return <Loading inheritColor size="small" />;
63+
if (loading) return <Loading className={`${switchClass}__loading`} size="16px" />;
6364

6465
if (Array.isArray(label)) {
6566
const [activeContent = '', inactiveContent = ''] = label;
@@ -68,7 +69,7 @@ const Switch = forwardRef<HTMLDivElement, SwitchProps>((originalProps, ref) => {
6869
}
6970

7071
return parseTNode(label, { value });
71-
}, [loading, label, checked, value]);
72+
}, [loading, label, checked, value, switchClass]);
7273

7374
return (
7475
<div ref={ref} className={switchClasses} style={style} onClick={handleToggle}>

src/switch/switch.en-US.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Name | Default Value | Description
2525
-- | -- | --
2626
--td-switch-checked-color | @brand-color | -
2727
--td-switch-checked-disabled-color | @brand-color-disabled | -
28-
--td-switch-dot-border-color | @bg-color-secondarycontainer | -
28+
--td-switch-dot-disabled-color | @font-white-1 | -
2929
--td-switch-dot-horizontal-margin | 3px | -
3030
--td-switch-dot-large-size | 26px | -
3131
--td-switch-dot-plain-horizontal-margin | 5px | -
@@ -40,17 +40,18 @@ Name | Default Value | Description
4040
--td-switch-icon-size | 20px | -
4141
--td-switch-icon-small-size | 16px | -
4242
--td-switch-label-checked-color | @switch-checked-color | -
43-
--td-switch-label-color | @text-color-disabled | -
44-
--td-switch-label-font-size | 12px | -
43+
--td-switch-label-color | @bg-color-secondarycontainer-active | -
4544
--td-switch-label-font-size | 14px | -
46-
--td-switch-label-font-size | 16px | -
45+
--td-switch-label-large-font-size | 16px | -
46+
--td-switch-label-small-font-size | 12px | -
4747
--td-switch-large-height | 32px | -
4848
--td-switch-large-radius | calc(@switch-large-height / 2) | -
4949
--td-switch-large-width | 52px | -
50+
--td-switch-loading-color | @brand-color | -
5051
--td-switch-radius | calc(@switch-height / 2) | -
5152
--td-switch-small-height | 24px | -
5253
--td-switch-small-radius | calc(@switch-small-height / 2) | -
5354
--td-switch-small-width | 39px | -
54-
--td-switch-unchecked-color | @text-color-disabled | -
55+
--td-switch-unchecked-color | @bg-color-secondarycontainer-active | -
5556
--td-switch-unchecked-disabled-color | @bg-color-component-disabled | -
5657
--td-switch-width | 45px | -

src/switch/switch.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ onChange | Function | | TS 类型:`(value: T, context: { e: MouseEvent }) =>
2525
-- | -- | --
2626
--td-switch-checked-color | @brand-color | -
2727
--td-switch-checked-disabled-color | @brand-color-disabled | -
28-
--td-switch-dot-border-color | @bg-color-secondarycontainer | -
28+
--td-switch-dot-disabled-color | @font-white-1 | -
2929
--td-switch-dot-horizontal-margin | 3px | -
3030
--td-switch-dot-large-size | 26px | -
3131
--td-switch-dot-plain-horizontal-margin | 5px | -
@@ -40,17 +40,18 @@ onChange | Function | | TS 类型:`(value: T, context: { e: MouseEvent }) =>
4040
--td-switch-icon-size | 20px | -
4141
--td-switch-icon-small-size | 16px | -
4242
--td-switch-label-checked-color | @switch-checked-color | -
43-
--td-switch-label-color | @text-color-disabled | -
44-
--td-switch-label-font-size | 12px | -
43+
--td-switch-label-color | @bg-color-secondarycontainer-active | -
4544
--td-switch-label-font-size | 14px | -
46-
--td-switch-label-font-size | 16px | -
45+
--td-switch-label-large-font-size | 16px | -
46+
--td-switch-label-small-font-size | 12px | -
4747
--td-switch-large-height | 32px | -
4848
--td-switch-large-radius | calc(@switch-large-height / 2) | -
4949
--td-switch-large-width | 52px | -
50+
--td-switch-loading-color | @brand-color | -
5051
--td-switch-radius | calc(@switch-height / 2) | -
5152
--td-switch-small-height | 24px | -
5253
--td-switch-small-radius | calc(@switch-small-height / 2) | -
5354
--td-switch-small-width | 39px | -
54-
--td-switch-unchecked-color | @text-color-disabled | -
55+
--td-switch-unchecked-color | @bg-color-secondarycontainer-active | -
5556
--td-switch-unchecked-disabled-color | @bg-color-component-disabled | -
5657
--td-switch-width | 45px | -

test/snap/__snapshots__/csr.test.jsx.snap

Lines changed: 18 additions & 18 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)