Skip to content

fix(checkbox): [checkbox,select,base-select] change the checkbox icon and synchronously modify the checkbox style #3258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/sites/demos/pc/app/checkbox/basic-usage.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ test('基础用法', async ({ page }) => {
await page.goto('checkbox#basic-usage')
const checkbox = await page.locator('.tiny-checkbox').first()
await expect(checkbox).toHaveClass(/is-checked/)
await expect(checkbox.locator('.tiny-checkbox__inner svg path').nth(1)).toHaveCSS('fill', 'rgb(20, 118, 255)')
await expect(checkbox.locator('.tiny-checkbox__inner svg path').nth(0)).toHaveCSS('fill', 'rgb(20, 118, 255)')
await checkbox.click()
await expect(checkbox).not.toHaveClass(/is-checked/)
})
24 changes: 17 additions & 7 deletions packages/theme/src/checkbox/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -158,23 +158,29 @@

.icon-checked-sur,
.icon-halfselect {
fill: var(--tv-Checkbox-bg-color-active);
path:first-child {
fill: var(--tv-Checkbox-bg-color-active);
}

path:last-child {
fill: var(--tv-Checkbox-border-color-inverse);
}
}

.icon-check {
fill: var(--tv-Checkbox-unchecked-border-color);

path:first-child {
fill: transparent;
}

path:nth-child(2) {
fill: var(--tv-Checkbox-unchecked-border-color);
}
}

.icon-check:hover {
fill: var(--tv-Checkbox-unchecked-border-color-hover);
path:nth-child(2) {
fill: var(--tv-Checkbox-unchecked-border-color-hover);
}
}
}
}
Expand All @@ -185,18 +191,22 @@
.@{checkbox-prefix-cls}__inner {
.icon-checked-sur,
.icon-halfselect {
fill: var(--tv-Checkbox-checked-disabled-bg-color);
path:first-child {
fill: var(--tv-Checkbox-checked-disabled-bg-color);
}

path:last-child {
fill: var(--tv-Checkbox-icon-inverse-disabled);
}
}
.icon-check {
fill: var(--tv-Checkbox-bg-color-disabled);

path:first-child {
fill: var(--tv-Checkbox-bg-color-disabled);
}

path:nth-child(2) {
fill: var(--tv-Checkbox-border-color-disabled);
}
}
}
}
Expand Down
34 changes: 30 additions & 4 deletions packages/theme/src/grid/checkbox.less
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@

&.icon-checked-sur {
display: block;
fill: var(--tv-Grid-bg-color-active);

path:first-child {
fill: var(--tv-Grid-bg-color-active);
}

path:last-child {
fill: var(--tv-Grid-border-color-inverse);
}
Expand All @@ -98,7 +102,10 @@

> svg {
&.icon-half-select {
fill: var(--tv-Grid-bg-color-active);
path:first-child {
fill: var(--tv-Grid-bg-color-active);
}

path:last-child {
fill: var(--tv-Grid-border-color-inverse);
}
Expand All @@ -124,11 +131,13 @@

&:checked + .@{grid-checkbox-prefix-cls}__icon {
> svg {
fill: var(--tv-Grid-checkbox-border-color-disabled);

path:first-child {
fill: var(--tv-Grid-checked-disabled-bg-color);
}

path:nth-child(2) {
fill: var(--tv-Grid-icon-inverse-disabled);
}
}
}
}
Expand All @@ -143,12 +152,29 @@
fill: var(--tv-Grid-checkbox-border-color-disabled);
}
}

& + .@{grid-checkbox-prefix-cls}__icon {
svg.icon-half-select {
path:first-child {
fill: var(--tv-Grid-checked-disabled-bg-color);
}

path:nth-child(2) {
fill: var(--tv-Grid-icon-inverse-disabled);
}
}
}
}
}
&.is__disabled > input:not(:checked) + .tiny-grid-checkbox__icon .icon-check {
path:first-child {
fill: var(--tv-Grid-bg-color-disabled);
}

path:nth-child(2) {
fill: var(--tv-Grid-border-color-disabled);
}

&:hover {
path:last-child {
fill: var(--tv-Grid-unchecked-border-color);
Expand Down
2 changes: 1 addition & 1 deletion packages/theme/src/grid/vars.less
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
// 复选框选中禁用边框色
--tv-Grid-checked-disabled-border-color: var(--tv-color-bg-disabled-control-unactive, #dbdbdb);
// 复选框禁用反白色
--tv-Grid-icon-inverse-disabled: var(--tv-color-icon-inverse);
--tv-Grid-icon-inverse-disabled: var(--tv-color-bg-inverse-disabled, #fff);
// 默认复选框未选中禁用背景色
--tv-Grid-bg-color-disabled: var(--tv-color-bg-disabled, #f0f0f0);
}
24 changes: 17 additions & 7 deletions packages/theme/src/option/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,28 @@
&.selected .tiny-svg,
.checked-sur.tiny-svg,
.halfselect.tiny-svg {
fill: var(--tv-Option-icon-color-checked);
path:first-child {
fill: var(--tv-Option-icon-color-checked);
}

path:last-child {
fill: var(--tv-Option-icon-inverse-disabled);
}
}

.check.tiny-svg {
fill: var(--tv-Option-icon-color-unchecked);

path:first-child {
fill: transparent;
}

path:nth-child(2) {
fill: var(--tv-Option-icon-color-unchecked);
}

&:hover {
fill: var(--tv-Option-icon-color-hover);
path:nth-child(2) {
fill: var(--tv-Option-icon-color-hover);
}
}
}

Expand Down Expand Up @@ -113,19 +119,23 @@
.tiny-svg {
&.checked-sur,
&.halfselect {
fill: var(--tv-Option-checked-disabled-bg-color);
path:first-child {
fill: var(--tv-Option-checked-disabled-bg-color);
}

path:last-child {
fill: var(--tv-Option-icon-color-checked-disabled-inverse);
}
}

&.check {
fill: var(--tv-Option-icon-color-unchecked-disabled);

path:first-child {
fill: var(--tv-Option-bg-color-disabled);
}

path:nth-child(2) {
fill: var(--tv-Option-icon-color-unchecked-disabled);
}
}
}
}
Expand Down
Loading