Skip to content

Commit

Permalink
Feat/new angular components storybook pressed radio (#198)
Browse files Browse the repository at this point in the history
We now have better focus visual behaviour
  • Loading branch information
RberendsDITP authored Nov 20, 2024
1 parent 7890e86 commit e325381
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,13 @@ export class TilburgRadioButton {
@Input() invalid: boolean = false;
@Input() disabled: boolean = false;
@Input() checked: boolean = false;

constructor() {}
mouseUp(event: MouseEvent) {
(event.target as HTMLInputElement).classList.remove('tilburg-radio-pressed');
}
mouseDown(event: MouseEvent) {
(event.target as HTMLInputElement).classList.add('tilburg-radio-pressed');
(event.target as HTMLInputElement).focus();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
[attr.value]="value"
[formControl]="control"
[checked]="checked"
(mouseup)="mouseUp($event)"
(mousedown)="mouseDown($event)"
utrecht-radio-button
/>
36 changes: 18 additions & 18 deletions packages/component-library-angular/src/radio-button/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@
filter: brightness(90%);
}

&:focus,
&:focus-visible {
&:focus-visible:not([aria-disabled="true"], :disabled, .tilburg-radio-pressed) {
background-color: var(--utrecht-radio-button-disabled-background-color);
border-color: var(--utrecht-form-control-focus-border-color);
border-width: 1px;
outline: dashed black thin;
}

&:focus.tilburg-radio-pressed,
&:focus-visible:not(.tilburg-radio-pressed) {
--utrecht-radio-button-color: black;
--_utrecht-radio-button-color: black;
--utrecht-radio-button-background-color: #e6f6ff;
Expand All @@ -43,27 +50,20 @@

background-color: #e6f6ff;
}
}

&:invalid:not(:checked) {
background-color: #ffe1e0;
}

&:focus-visible:not([aria-disabled="true"], :disabled) {
background-color: var(--utrecht-radio-button-disabled-background-color);
border-color: var(--utrecht-form-control-focus-border-color);
border-width: 1px;
outline: dashed black thin;
}
&:focus:not([aria-disabled="true"], :disabled) {
background-color: var(--utrecht-radio-button-disabled-background-color);
border-color: var(--utrecht-form-control-focus-border-color);
border-width: 1px;
}

&:focus:not([aria-disabled="true"], :disabled) {
background-color: var(--utrecht-radio-button-disabled-background-color);
border-color: var(--utrecht-form-control-focus-border-color);
border-width: 1px;
&:invalid:not(:checked) {
background-color: #ffe1e0;
}
}

&:focus-visible:not([aria-disabled="true"], :disabled):checked,
&:focus:not([aria-disabled="true"], :disabled):checked {
&:focus:not([aria-disabled="true"], :disabled).tilburg-radio-pressed {
--_utrecht-radio-button-color: black;
}
}
Expand Down

0 comments on commit e325381

Please sign in to comment.