Browse Source

Task/extend toggle component to support disabled state (#7585)

* Extend toggle component to support disabled state

* Update changelog
pull/7586/head
Thomas Kaul 1 week ago
committed by GitHub
parent
commit
d2ad879dde
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 1
      CHANGELOG.md
  2. 6
      libs/ui/src/lib/toggle/toggle.component.html
  3. 16
      libs/ui/src/lib/toggle/toggle.component.scss
  4. 17
      libs/ui/src/lib/toggle/toggle.component.stories.ts
  5. 1
      libs/ui/src/lib/toggle/toggle.component.ts

1
CHANGELOG.md

@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed ### Changed
- Extended the toggle component to support a disabled state
- Extended the toggle component to support icons - Extended the toggle component to support icons
## 3.46.0 - 2026-08-09 ## 3.46.0 - 2026-08-09

6
libs/ui/src/lib/toggle/toggle.component.html

@ -9,9 +9,11 @@
[class]="{ [class]="{
'cursor-default': option.value === optionFormControl.value, 'cursor-default': option.value === optionFormControl.value,
'cursor-pointer': 'cursor-pointer':
!isLoading() && option.value !== optionFormControl.value !isDisabled() &&
!isLoading() &&
option.value !== optionFormControl.value
}" }"
[disabled]="isLoading()" [disabled]="isDisabled() || isLoading()"
[title]="option.title ?? ''" [title]="option.title ?? ''"
[value]="option.value" [value]="option.value"
> >

16
libs/ui/src/lib/toggle/toggle.component.scss

@ -9,6 +9,14 @@
background-color: rgba(var(--dark-dividers)); background-color: rgba(var(--dark-dividers));
} }
&.mat-mdc-radio-disabled {
::ng-deep {
label {
color: rgba(var(--dark-disabled-text));
}
}
}
::ng-deep { ::ng-deep {
.mdc-radio { .mdc-radio {
display: none; display: none;
@ -31,6 +39,14 @@
border: 1px solid rgba(var(--light-disabled-text)); border: 1px solid rgba(var(--light-disabled-text));
} }
&.mat-mdc-radio-disabled {
::ng-deep {
label {
color: rgba(var(--light-disabled-text));
}
}
}
::ng-deep { ::ng-deep {
label { label {
color: rgba(var(--light-primary-text), 1); color: rgba(var(--light-primary-text), 1);

17
libs/ui/src/lib/toggle/toggle.component.stories.ts

@ -26,6 +26,22 @@ type Story = StoryObj<GfToggleComponent>;
export const Default: Story = { export const Default: Story = {
args: { args: {
defaultValue: '1d', defaultValue: '1d',
isDisabled: false,
isLoading: false,
options: [
{ label: 'Today', value: '1d' },
{ label: 'YTD', value: 'ytd' },
{ label: '1Y', value: '1y' },
{ label: '5Y', value: '5y' },
{ label: 'Max', value: 'max' }
]
}
};
export const Disabled: Story = {
args: {
defaultValue: '1d',
isDisabled: true,
isLoading: false, isLoading: false,
options: [ options: [
{ label: 'Today', value: '1d' }, { label: 'Today', value: '1d' },
@ -40,6 +56,7 @@ export const Default: Story = {
export const WithIcons: Story = { export const WithIcons: Story = {
args: { args: {
defaultValue: 'TABLE', defaultValue: 'TABLE',
isDisabled: false,
isLoading: false, isLoading: false,
options: [ options: [
{ {

1
libs/ui/src/lib/toggle/toggle.component.ts

@ -20,6 +20,7 @@ import { IonIcon } from '@ionic/angular/standalone';
}) })
export class GfToggleComponent { export class GfToggleComponent {
public readonly defaultValue = input.required<string>(); public readonly defaultValue = input.required<string>();
public readonly isDisabled = input<boolean>(false);
public readonly isLoading = input<boolean>(false); public readonly isLoading = input<boolean>(false);
public readonly options = input<ToggleOption[]>([]); public readonly options = input<ToggleOption[]>([]);

Loading…
Cancel
Save