Skip to content

Commit

Permalink
feat: add radio-button and checkbox disabled style properties (#7615)
Browse files Browse the repository at this point in the history
* radio-button: introduce properties and test

* checkbox: introduce style property and test

* Fix test, remove console.logs

* update test name

* add to globals
  • Loading branch information
FrediWa authored Aug 5, 2024
1 parent 89f77a6 commit 16046b9
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 5 deletions.
26 changes: 26 additions & 0 deletions packages/checkbox/test/visual/lumo/checkbox.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,32 @@ describe('checkbox', () => {
element.required = true;
await visualDiff(div, 'disabled-required');
});

describe('styled', () => {
before(() => {
document.documentElement.style.setProperty('--vaadin-checkbox-disabled-checkmark-color', 'white');
document.documentElement.style.setProperty('--vaadin-checkbox-disabled-background', 'black');
});

after(() => {
document.documentElement.style.removeProperty('--vaadin-checkbox-disabled-checkmark-color');
document.documentElement.style.removeProperty('--vaadin-checkbox-disabled-background');
});

it('checked', async () => {
element.checked = true;
await visualDiff(div, 'styled-disabled-checked');
});

it('indeterminate', async () => {
element.indeterminate = true;
await visualDiff(div, 'styled-disabled-indeterminate');
});

it('unchecked', async () => {
await visualDiff(div, 'styled-disabled');
});
});
});

describe('readonly', () => {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions packages/checkbox/theme/lumo/vaadin-checkbox-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ registerStyles(
--_focus-ring-width: var(--vaadin-focus-ring-width, 2px);
--_selection-color: var(--vaadin-selection-color, var(--lumo-primary-color));
--_invalid-background: var(--vaadin-input-field-invalid-background, var(--lumo-error-color-10pct));
--_disabled-checkmark-color: var(--vaadin-checkbox-disabled-checkmark-color, var(--lumo-contrast-30pct));
}
[part='label'] {
Expand Down Expand Up @@ -153,11 +154,11 @@ registerStyles(
}
:host([disabled]) [part='checkbox'] {
background-color: var(--lumo-contrast-10pct);
background-color: var(--vaadin-checkbox-disabled-background, var(--lumo-contrast-10pct));
}
:host([disabled]) [part='checkbox']::after {
color: var(--lumo-contrast-30pct);
color: var(--_disabled-checkmark-color);
}
:host([disabled]) [part='label'],
Expand All @@ -167,7 +168,7 @@ registerStyles(
}
:host([indeterminate][disabled]) [part='checkbox']::after {
background-color: var(--lumo-contrast-30pct);
background-color: var(--_disabled-checkmark-color);
}
:host([readonly][checked]) [part='checkbox'],
Expand Down
21 changes: 21 additions & 0 deletions packages/radio-group/test/visual/lumo/radio-button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,27 @@ describe('radio-button', () => {
element.checked = true;
await visualDiff(div, 'disabled-checked');
});

describe('styled', () => {
before(() => {
document.documentElement.style.setProperty('--vaadin-radio-button-disabled-background', 'black');
document.documentElement.style.setProperty('--vaadin-radio-button-disabled-dot-color', 'white');
});

after(() => {
document.documentElement.style.removeProperty('--vaadin-radio-button-disabled-background');
document.documentElement.style.removeProperty('--vaadin-radio-button-disabled-dot-color');
});

it('disabled', async () => {
await visualDiff(div, 'styled-disabled');
});

it('disabled checked', async () => {
element.checked = true;
await visualDiff(div, 'styled-disabled-checked');
});
});
});

describe('RTL', () => {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions packages/radio-group/theme/lumo/vaadin-radio-button-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ registerStyles(
}
:host([disabled]) [part='radio'] {
background-color: var(--lumo-contrast-10pct);
background-color: var(--vaadin-radio-button-disabled-background, var(--lumo-contrast-10pct));
}
:host([disabled]) [part='radio']::after {
border-color: var(--lumo-contrast-30pct);
border-color: var(--vaadin-radio-button-disabled-dot-color, var(--lumo-contrast-30pct));
}
/* RTL specific styles */
Expand Down
4 changes: 4 additions & 0 deletions packages/vaadin-lumo-styles/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ const globals = css`
--vaadin-checkbox-label-font-size: var(--lumo-font-size-m);
--vaadin-checkbox-label-padding: var(--lumo-space-xs) var(--lumo-space-s) var(--lumo-space-xs) var(--lumo-space-xs);
--vaadin-checkbox-size: calc(var(--lumo-size-m) / 2);
--vaadin-checkbox-disabled-checkmark-color: var(--lumo-contrast-10pct);
--vaadin-checkbox-disabled-background: var(--lumo-contrast-30pct);
/* Radio button */
--vaadin-radio-button-background: var(--lumo-contrast-20pct);
--vaadin-radio-button-background-hover: var(--lumo-contrast-30pct);
Expand All @@ -72,6 +74,8 @@ const globals = css`
--vaadin-radio-button-label-padding: var(--lumo-space-xs) var(--lumo-space-s) var(--lumo-space-xs)
var(--lumo-space-xs);
--vaadin-radio-button-size: calc(var(--lumo-size-m) / 2);
--vaadin-radio-button-disabled-background: var(--lumo-contrast-10pct);
--vaadin-radio-button-disabled-dot-color: var(--lumo-contrast-30pct);
--vaadin-selection-color: var(--lumo-primary-color);
--vaadin-selection-color-text: var(--lumo-primary-text-color);
--vaadin-input-field-border-radius: var(--lumo-border-radius-m);
Expand Down

0 comments on commit 16046b9

Please sign in to comment.