Skip to content
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

fix(styles): Update disabled styles for form-check (except switch) #2813

Merged
merged 50 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
ba5450d
fix(styles): Update form validation feedback color and indicators in HCM
imagoiq Mar 6, 2024
182db6a
Lint
imagoiq Mar 6, 2024
26f9e1b
fix(styles): Make styling more coherent for forms elements with High …
imagoiq Mar 11, 2024
fa310ed
Fix using border instead of background to highlight selected state
imagoiq Mar 14, 2024
a67aaf6
Remove commented code
imagoiq Mar 14, 2024
37d27a0
Merge branch 'main' into fix/improve-forms-input-in-hcm
imagoiq Mar 19, 2024
3197640
fix(styles): Update disabled styles for form-check (except switch)
imagoiq Mar 19, 2024
e11a974
Merge branch 'main' into fix/improve-forms-input-in-hcm
imagoiq Mar 21, 2024
d5347d2
Merge branch 'main' into fix/improve-forms-input-in-hcm
imagoiq Mar 21, 2024
9f47f0f
Fixes for card-control
imagoiq Mar 21, 2024
9eac28a
Merge branch 'main' into fix/improve-forms-input-in-hcm
imagoiq Mar 21, 2024
00e55ec
Merge branch 'main' into fix/improve-forms-input-in-hcm
imagoiq Apr 2, 2024
a78ac1a
Merge branch 'main' into feat/2525-update-form-check-styles
imagoiq Apr 2, 2024
530987e
Merge branch 'fix/improve-forms-input-in-hcm' into feat/2525-update-f…
imagoiq Apr 2, 2024
dea02fd
Adjust border width with figma update
imagoiq Apr 2, 2024
125ba22
Merge branch 'main' into fix/improve-forms-input-in-hcm
imagoiq Apr 3, 2024
aa8fa61
Merge branch 'fix/improve-forms-input-in-hcm' into feat/2525-update-f…
imagoiq Apr 3, 2024
bd503f7
Add missing hover state for form-range on hover
imagoiq Apr 4, 2024
84e7238
Merge branch 'fix/improve-forms-input-in-hcm' into feat/2525-update-f…
imagoiq Apr 4, 2024
3ceee7f
Removed line-cap
imagoiq Apr 4, 2024
a7ced0f
Use a function and improve dasharray
imagoiq Apr 4, 2024
e15eeb7
Prototype for simpler version + support for input text and select
imagoiq Apr 4, 2024
4c8156f
Add dash pattern for small version
imagoiq Apr 8, 2024
4edc2db
Lint
imagoiq Apr 8, 2024
91f82aa
Merge branch 'fix/improve-forms-input-in-hcm' into feat/2525-update-f…
imagoiq Apr 8, 2024
01a622c
Remove unneeded prototype for focus-style and remove box-shadow on fo…
imagoiq Apr 8, 2024
995f34e
Add wrapper and styles for input, select and slider
imagoiq Apr 8, 2024
7c96433
Add changelog
imagoiq Apr 8, 2024
f140df2
Improve text input and select on chrome and reinstate hover style for…
imagoiq Apr 8, 2024
71daa2b
Reinstate hover style for checkbox, radio, textarea, switch
imagoiq Apr 8, 2024
fb563db
Consistency on disabled style
imagoiq Apr 8, 2024
9eec980
Fix code smell
imagoiq Apr 8, 2024
e156454
Merge branch 'fix/improve-forms-input-in-hcm' into feat/2525-update-f…
imagoiq Apr 8, 2024
d5dc29b
Remove duplication from merge
imagoiq Apr 8, 2024
f87e625
Remove duplication from merge
imagoiq Apr 8, 2024
2d1ea11
Remove duplication from merge
imagoiq Apr 8, 2024
daa0f53
Remove duplication from merge
imagoiq Apr 8, 2024
d655614
Reinstate selectedItem color
imagoiq Apr 10, 2024
0ee7ed2
Fix issues for checkbox on Firefox
imagoiq Apr 10, 2024
7741117
Extract border-radius from focus-style mixin
imagoiq Apr 10, 2024
15198c9
Merge branch 'main' into fix/improve-forms-input-in-hcm
imagoiq Apr 10, 2024
673040d
Use focus-dark variable
imagoiq Apr 10, 2024
777e6cf
Merge branch 'main' into fix/improve-forms-input-in-hcm
imagoiq Apr 11, 2024
84eac5c
Merge branch 'refs/heads/main' into fix/improve-forms-input-in-hcm
imagoiq Apr 15, 2024
d39587a
Merge branch 'refs/heads/fix/improve-forms-input-in-hcm' into feat/25…
imagoiq Apr 15, 2024
6e5e725
Merge branch 'refs/heads/main' into feat/2525-update-form-check-styles
imagoiq Apr 15, 2024
23e8d7e
Use variable
imagoiq Apr 15, 2024
737297f
Fix various issues from merge
imagoiq Apr 16, 2024
2a06e97
Add line space between variables
imagoiq Apr 16, 2024
977c644
Fix initial value in chrome
imagoiq Apr 16, 2024
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
5 changes: 5 additions & 0 deletions .changeset/odd-rabbits-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@swisspost/design-system-styles': patch
---

Added new disabled styles for radio and checkbox, fixed color contrast on this state and fixed cursor style.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@ describe('Checkbox', () => {
});

it('Has no detectable a11y violations on load for all variants', () => {
cy.checkA11y('#root-inner', {
rules: {
'color-contrast': {
enabled: false,
},
},
});
cy.checkA11y('#root-inner');
});
});
});
8 changes: 1 addition & 7 deletions packages/documentation/cypress/e2e/components/radio.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,7 @@ describe('Radio', () => {
});

it('Has no detectable a11y violations on load for all variants', () => {
cy.checkA11y('#root-inner', {
rules: {
'color-contrast': {
enabled: false,
},
},
});
cy.checkA11y('#root-inner');
});
});
});
72 changes: 58 additions & 14 deletions packages/styles/src/components/form-check.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@use '../variables/spacing';
@use '../variables/animation';
@use '../variables/components/form-check';
@use '../mixins/color' as color-mx;
@use '../mixins/icons' as icons-mx;
@use '../mixins/utilities' as utility-mx;

Expand Down Expand Up @@ -49,10 +50,11 @@
}

@include utility-mx.focus-style-none();

display: inline-flex;
flex: 0 auto;
appearance: none;
background: color.$white;
background: transparent;
oliverschuerch marked this conversation as resolved.
Show resolved Hide resolved
height: form-check.$form-check-input-size;
width: form-check.$form-check-input-size;
border: form-check.$form-check-input-border-width solid
Expand Down Expand Up @@ -108,10 +110,41 @@
}
}

&[type='radio'] {
border-radius: 50%;

&:checked::after {
border: spacing.$size-micro solid transparent;
background-color: currentColor;
border-radius: inherit;
background-clip: padding-box;

@include utility-mx.high-contrast-mode {
background-color: SelectedItem;
border-color: Canvas;
}
}

&[disabled] {
padding: spacing.$size-line; // Used to mimic border width because it is used in combination with background-clip: padding-box; to size the selected shape
background-image: url('#{form-check.$form-check-input-radio-disabled-background-url-light}');

@include color-mx.on-dark-background {
background-image: url('#{form-check.$form-check-input-radio-disabled-background-url-dark}');
}

@include utility-mx.high-contrast-mode {
background-image: url('#{form-check.$form-check-input-radio-disabled-background-url-hcm}') !important;
}
}
}

&[disabled] {
&[type='checkbox'],
&[type='radio'] {
border-color: GrayText !important;
@include utility-mx.high-contrast-mode {
border-color: GrayText !important;
}
}

&[type='checkbox'] {
Expand All @@ -131,28 +164,39 @@
}
}
}
}

&[type='radio'] {
border-radius: 50%;
border: 0;
background-image: url('#{form-check.$form-check-input-disabled-background-url-light-lg}');

&:checked::after {
border: spacing.$size-micro solid transparent;
background-color: currentColor;
border-radius: inherit;
background-clip: padding-box;
@include color-mx.on-dark-background {
background-image: url('#{form-check.$form-check-input-disabled-background-url-dark-lg}');
}

@include utility-mx.high-contrast-mode {
background-image: url('#{form-check.$form-check-input-disabled-background-url-hcm-lg}') !important;
}

.form-check-sm &[type='checkbox'] {
background-image: url('#{form-check.$form-check-input-disabled-background-url-light-sm}');

@include color-mx.on-dark-background {
background-image: url('#{form-check.$form-check-input-disabled-background-url-dark-sm}');
}

@include utility-mx.high-contrast-mode {
background-color: SelectedItem;
border-color: Canvas;
background-image: url('#{form-check.$form-check-input-disabled-background-url-hcm-sm}') !important;
}
}
}

&[disabled],
&[disabled] ~ .form-check-label {
border-color: rgba(var(--post-contrast-color-rgb), 0.4) !important;
color: rgba(var(--post-contrast-color-rgb), 0.4) !important;
text-decoration: line-through;
color: color.$black-alpha-60;

@include color-mx.on-dark-background() {
color: color.$white-alpha-80;
}
}

.form-check-sm & {
Expand Down
22 changes: 22 additions & 0 deletions packages/styles/src/functions/_forms.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Source: https://kovart.github.io/dashed-border-generator/ + added stroke-vector-effect
@function get-background-svg-stroke(
$type,
$color,
$stroke-dasharray,
$stroke-pathlength,
$stroke-width
) {
$svg-additional-attributes: '';
$stroke-pathlength-attribute: '';

@if ($type == 'circle') {
$svg-additional-attributes: "rx='100' ry='100'";
}
@if ($stroke-pathlength != 'initial') {
$stroke-pathlength-attribute: " pathLength='" + $stroke-pathlength + "'";
}
@return "data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg'%3e%3crect width='100%25' height='100%25' " +
$svg-additional-attributes + " fill='none' stroke='" + $color + "' stroke-width='" +
$stroke-width "' stroke-dasharray='" + $stroke-dasharray + "'" + $stroke-pathlength-attribute +
' /%3e%3c/svg%3e';
}
74 changes: 74 additions & 0 deletions packages/styles/src/variables/components/_form-check.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
@use './../animation';
@use './../../functions/icons';
@use './../../functions/sizing';
@use './../../functions/forms' as forms-fn;

$form-check-row-gap: spacing.$size-small-regular !default;
$form-check-column-gap: spacing.$size-mini !default;
Expand All @@ -14,6 +15,79 @@ $form-check-input-size: 1.375rem !default;
$form-check-input-size-sm: spacing.$size-regular !default;
$form-check-input-border-width: forms.$input-border-width !default;
$form-check-input-focus-box-shadow: forms.$input-focus-box-shadow !default;
$form-check-input-disabled-svg-border-width: $form-check-input-border-width * 2;
$form-check-input-disabled-svg-stroke-square-pattern-lg: '2 1.5 4 1.5 4 1.5 4 1.5 2 3.5 4 1.5 4 1.5 4 1.5 2 3.5 4 1.5 4 1.5 4 1.5 2 3.5 4 1.5 4 1.5 4';
$form-check-input-disabled-svg-stroke-square-pathlength-lg: 88;
$form-check-input-disabled-svg-stroke-square-pattern-sm: '2 1.5 4 1.5 4 1.5 2 3.5 4 1.5 4 1.5 2 3.5 4 1.5 4 1.5 2 3.5 4 1.5 4 1.5 4';
$form-check-input-disabled-svg-stroke-square-pathlength-sm: 66;
$form-check-input-disabled-svg-stroke-circle-pattern: '4 2';

// Checkbox lg
$form-check-input-disabled-background-url-light-lg: forms-fn.get-background-svg-stroke(
'square',
color.$gray-60,
$form-check-input-disabled-svg-stroke-square-pattern-lg,
$form-check-input-disabled-svg-stroke-square-pathlength-lg,
$form-check-input-disabled-svg-border-width
);
$form-check-input-disabled-background-url-dark-lg: forms-fn.get-background-svg-stroke(
'square',
color.$white-alpha-80,
$form-check-input-disabled-svg-stroke-square-pattern-lg,
$form-check-input-disabled-svg-stroke-square-pathlength-lg,
$form-check-input-disabled-svg-border-width
);
$form-check-input-disabled-background-url-hcm-lg: forms-fn.get-background-svg-stroke(
'square',
'GrayText',
$form-check-input-disabled-svg-stroke-square-pattern-lg,
$form-check-input-disabled-svg-stroke-square-pathlength-lg,
$form-check-input-disabled-svg-border-width
);
//Checkbox sm
$form-check-input-disabled-background-url-light-sm: forms-fn.get-background-svg-stroke(
'square',
color.$gray-60,
$form-check-input-disabled-svg-stroke-square-pattern-sm,
$form-check-input-disabled-svg-stroke-square-pathlength-sm,
$form-check-input-disabled-svg-border-width
);
$form-check-input-disabled-background-url-dark-sm: forms-fn.get-background-svg-stroke(
'square',
color.$white-alpha-80,
$form-check-input-disabled-svg-stroke-square-pattern-sm,
$form-check-input-disabled-svg-stroke-square-pathlength-sm,
$form-check-input-disabled-svg-border-width
);
$form-check-input-disabled-background-url-hcm-sm: forms-fn.get-background-svg-stroke(
'square',
'GrayText',
$form-check-input-disabled-svg-stroke-square-pattern-sm,
$form-check-input-disabled-svg-stroke-square-pathlength-sm,
$form-check-input-disabled-svg-border-width
);
// Radio
$form-check-input-radio-disabled-background-url-light: forms-fn.get-background-svg-stroke(
'circle',
color.$gray-60,
$form-check-input-disabled-svg-stroke-circle-pattern,
initial,
$form-check-input-disabled-svg-border-width
);
$form-check-input-radio-disabled-background-url-dark: forms-fn.get-background-svg-stroke(
'circle',
color.$white-alpha-80,
$form-check-input-disabled-svg-stroke-circle-pattern,
initial,
$form-check-input-disabled-svg-border-width
);
$form-check-input-radio-disabled-background-url-hcm: forms-fn.get-background-svg-stroke(
'circle',
'GrayText',
$form-check-input-disabled-svg-stroke-circle-pattern,
initial,
$form-check-input-disabled-svg-border-width
);

$form-switch-column-gap: spacing.$size-regular !default;
$form-switch-height: spacing.$size-big !default;
Expand Down
Loading