Skip to content

Commit 723aa86

Browse files
committed
chore(ui): fix checkbox style
1 parent 086d742 commit 723aa86

2 files changed

Lines changed: 36 additions & 25 deletions

File tree

packages/ui/src/components/checkbox/demos/1.Basic.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,26 @@ The simplest usage.
1313
最简单的用法。
1414

1515
```tsx
16-
import { DCheckbox } from '@react-devui/ui';
16+
import { useState } from 'react';
17+
18+
import { DButton, DCheckbox } from '@react-devui/ui';
1719

1820
export default function Demo() {
21+
const [disabled, setDisabled] = useState(false);
22+
1923
return (
2024
<>
21-
<DCheckbox>Checkbox</DCheckbox>
22-
<DCheckbox dIndeterminate>Checkbox</DCheckbox>
23-
<DCheckbox dDisabled>Checkbox</DCheckbox>
24-
<DCheckbox dModel={true} dDisabled>
25+
<DButton
26+
onClick={() => {
27+
setDisabled((prev) => !prev);
28+
}}
29+
>
30+
Toggle disabled
31+
</DButton>
32+
<br />
33+
<br />
34+
<DCheckbox dDisabled={disabled}>Checkbox</DCheckbox>
35+
<DCheckbox dIndeterminate dDisabled={disabled}>
2536
Checkbox
2637
</DCheckbox>
2738
</>

packages/ui/src/styles/components/checkbox.scss

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737

3838
&::after {
3939
background-color: var(--#{$rd-prefix}background-color-disabled);
40-
opacity: 1;
4140
}
4241
}
4342

@@ -47,6 +46,10 @@
4746
border-left-color: var(--#{$rd-prefix}color-disabled);
4847
}
4948
}
49+
50+
@include e(indeterminate) {
51+
background-color: var(--#{$rd-prefix}color-disabled);
52+
}
5053
}
5154

5255
@include when(checked) {
@@ -60,36 +63,34 @@
6063
animation: wave-spread 0.36s linear;
6164
animation-fill-mode: backwards;
6265
}
66+
67+
&::after {
68+
background-color: var(--#{$rd-prefix}color-primary);
69+
}
6370
}
6471

6572
@include e(tick) {
6673
animation: checkbox-tick 133ms linear;
6774
animation-fill-mode: backwards;
6875
}
6976
}
70-
71-
@include e(state-container) {
72-
&::after {
73-
opacity: 1;
74-
}
75-
}
7677
}
7778

7879
@include when(indeterminate) {
7980
&:not(.is-disabled) {
8081
@include e(input) {
8182
border-color: var(--#{$rd-prefix}color-primary);
8283
}
83-
}
8484

85-
@include e(state-container) {
86-
&::before {
87-
animation: wave-spread 0.36s linear;
88-
animation-fill-mode: backwards;
89-
}
85+
@include e(state-container) {
86+
&::before {
87+
animation: wave-spread 0.36s linear;
88+
animation-fill-mode: backwards;
89+
}
9090

91-
&::after {
92-
opacity: 1;
91+
&::after {
92+
background-color: var(--#{$rd-prefix}color-primary);
93+
}
9394
}
9495
}
9596
}
@@ -110,19 +111,18 @@
110111
position: absolute;
111112
inset: 0;
112113
content: '';
113-
border: 1px solid var(--#{$rd-prefix}color-primary);
114+
border: 1px solid transparent;
114115
border-radius: var(--#{$rd-prefix}border-radius);
115-
opacity: 0;
116116
}
117117

118118
&::after {
119119
position: absolute;
120120
inset: 0;
121121
content: '';
122-
background-color: var(--#{$rd-prefix}color-primary);
122+
background-color: transparent;
123123
border-radius: var(--#{$rd-prefix}border-radius);
124-
opacity: 0;
125-
transition: transform var(--#{$rd-prefix}animation-duration-fast) linear, opacity var(--#{$rd-prefix}animation-duration-fast) linear;
124+
transition: transform var(--#{$rd-prefix}animation-duration-fast) linear,
125+
background-color var(--#{$rd-prefix}animation-duration-fast) linear;
126126
}
127127
}
128128

0 commit comments

Comments
 (0)