Skip to content

Commit

Permalink
Feat(web): Switch Radio component to v3 design tokens #DS-1447
Browse files Browse the repository at this point in the history
  • Loading branch information
crishpeen committed Sep 11, 2024
1 parent d6c688e commit fd6dd2d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 19 deletions.
31 changes: 22 additions & 9 deletions packages/web/src/scss/components/Radio/_Radio.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,19 @@ $_field-name: 'Radio';
margin: theme.$input-margin;
font: inherit;
border-radius: theme.$input-border-radius;
background-color: transparent;
background-color: form-fields-theme.$input-background-color;
place-content: center;

&:hover {
background-color: form-fields-theme.$input-background-color-hover;
}

&:active {
background-color: form-fields-theme.$input-background-color-active;
}

&:checked {
border-color: form-fields-theme.$inline-field-input-color-checked;
border-color: form-fields-theme.$inline-field-input-border-color-checked;
}

&::before {
Expand Down Expand Up @@ -84,10 +92,11 @@ $_field-name: 'Radio';

.Radio--disabled > .Radio__input,
.Radio > .Radio__input:disabled {
border-color: form-fields-theme.$input-color-disabled;
border-color: form-fields-theme.$input-border-color-disabled;
background-color: form-fields-theme.$input-background-color-disabled;

&:checked {
border-color: form-fields-theme.$input-color-disabled;
border-color: form-fields-theme.$input-border-color-disabled;
}
}

Expand All @@ -106,17 +115,21 @@ $_field-name: 'Radio';
@include form-fields-tools.item-disabled();
}

// stylelint-disable selector-max-class, selector-max-compound-selectors, selector-max-specificity -- We need to override the default styles for the label in Item.
.Radio--item .Radio__input:checked ~ .Radio__label,
.Radio--item .Radio__input:checked ~ .Radio__text > .Radio__label {
// stylelint-enable selector-max-class, selector-max-compound-selectors, selector-max-specificity
@include form-fields-tools.item-label-checked();
.Radio--item .Radio__label {
@include form-fields-tools.item-label();
}

.Radio--item .Radio__helperText {
@include form-fields-tools.item-helper-text();
}

// stylelint-disable selector-max-specificity -- We need to override the default styles, but not in disabled state
.Radio--item:not(.Radio--disabled) .Radio__input:hover:not(:checked),
.Radio--item:not(.Radio--disabled) .Radio__input:active:not(:checked) {
background-color: form-fields-theme.$input-background-color;
}
// stylelint-enable selector-max-specificity

.Radio--item:not(.Radio--disabled):hover .Radio__helperText,
.Radio--item:not(.Radio--disabled):active .Radio__helperText {
color: inherit;
Expand Down
14 changes: 7 additions & 7 deletions packages/web/src/scss/components/Radio/_theme.scss
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
@use '@tokens' as tokens;
@use '@global' as global-tokens;
@use '../../settings/transitions';
@use '../../theme/form-fields' as form-fields-theme;

$input-border-radius: 50%;
$input-border-radius: global-tokens.$radius-full;
$input-size: 20px;
$input-margin: 2px;
$input-margin: global-tokens.$space-200;
$input-inner-dot-size: 10px;
$input-box-shadow-x: tokens.$space-600;
$input-box-shadow-y: tokens.$space-600;
$input-box-shadow-x: global-tokens.$space-700;
$input-box-shadow-y: global-tokens.$space-700;
$input-box-shadow-before: inset $input-box-shadow-x $input-box-shadow-y
form-fields-theme.$inline-field-input-color-checked;
form-fields-theme.$inline-field-input-background-color-checked;
$input-box-shadow-disabled: inset $input-box-shadow-x $input-box-shadow-y form-fields-theme.$input-color-disabled;
$input-transition-duration: transitions.$duration-100;
$input-transition-timing: transitions.$timing-eased-in-out;
$input-focus-shadow: tokens.$focus;
$input-focus-shadow: global-tokens.$focus;
3 changes: 1 addition & 2 deletions packages/web/src/scss/components/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

// @forward 'Pill';
@forward 'ProductLogo';

// @forward 'Radio';
@forward 'Radio';
@forward 'ScrollView';

// @forward 'Select';
Expand Down
1 change: 0 additions & 1 deletion tests/e2e/demo-components-compare.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const IGNORED_TESTS: string[] = [
'Item',
'Link',
'Pill',
'Radio',
'Select',
'Spinner',
'Stack',
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fd6dd2d

Please sign in to comment.