Skip to content

Commit 349f7bf

Browse files
committed
feat(radio-group): group label styles
1 parent 38f25e4 commit 349f7bf

22 files changed

+256
-23
lines changed

src/components/radio-group/radio-group.fluent.scss

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/components/radio-group/radio-group.indigo.scss

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/components/radio-group/radio-group.ts

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import { LitElement, html } from 'lit';
22
import { property, queryAssignedElements } from 'lit/decorators.js';
3-
43
import { themes } from '../../theming/theming-decorator.js';
4+
import { createMutationController } from '../common/controllers/mutation-observer.js';
55
import { registerComponent } from '../common/definitions/register.js';
66
import IgcRadioComponent from '../radio/radio.js';
77
import type { ContentOrientation } from '../types.js';
8-
import { styles } from './radio-group.base.css.js';
9-
import { styles as fluent } from './radio-group.fluent.css.js';
10-
import { styles as indigo } from './radio-group.indigo.css.js';
11-
import { styles as material } from './radio-group.material.css.js';
8+
import { styles } from './themes/radio-group.base.css.js';
9+
import { styles as shared } from './themes/shared/radio-group.common.css.js';
10+
import { all } from './themes/themes.js';
1211

1312
/**
1413
* The igc-radio-group component unifies one or more igc-radio buttons.
@@ -17,13 +16,10 @@ import { styles as material } from './radio-group.material.css.js';
1716
*
1817
* @slot - Default slot
1918
*/
20-
@themes({
21-
light: { material, fluent, indigo },
22-
dark: { material, fluent, indigo },
23-
})
19+
@themes(all)
2420
export default class IgcRadioGroupComponent extends LitElement {
2521
public static readonly tagName = 'igc-radio-group';
26-
public static override styles = styles;
22+
public static override styles = [styles, shared];
2723

2824
/* blazorSuppress */
2925
public static register() {
@@ -35,6 +31,12 @@ export default class IgcRadioGroupComponent extends LitElement {
3531
private _name!: string;
3632
private _value!: string;
3733

34+
@property({ type: Boolean, reflect: true })
35+
private disabled = false;
36+
37+
@property({ type: Boolean, reflect: true })
38+
private labelBefore = false;
39+
3840
@queryAssignedElements({ flatten: true })
3941
private _radios!: NodeListOf<IgcRadioComponent>;
4042

@@ -90,11 +92,29 @@ export default class IgcRadioGroupComponent extends LitElement {
9092
return this._value;
9193
}
9294

95+
private _observerCallback() {
96+
const radios = Array.from(this._radios as unknown as Element[]).filter(
97+
(el) => el.tagName.toLowerCase() === 'igc-radio'
98+
) as IgcRadioComponent[];
99+
this.disabled = radios.every((radio) => radio.disabled);
100+
this.labelBefore =
101+
radios.some((radio) => radio.labelPosition === 'before') ?? false;
102+
}
103+
93104
constructor() {
94105
super();
95106

96107
this._internals = this.attachInternals();
97108
this._internals.role = 'radiogroup';
109+
110+
createMutationController(this, {
111+
callback: this._observerCallback,
112+
filter: [IgcRadioComponent.tagName],
113+
config: {
114+
attributeFilter: ['disabled', 'label-position'],
115+
subtree: true,
116+
},
117+
});
98118
}
99119

100120
protected override createRenderRoot() {
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@use 'styles/utilities' as *;
2+
@use 'igniteui-theming/sass/themes/schemas/components/dark/label' as *;
3+
4+
$material: digest-schema($dark-material-label);
5+
$bootstrap: digest-schema($dark-bootstrap-label);
6+
$fluent: digest-schema($dark-fluent-label);
7+
$indigo: digest-schema($dark-indigo-label);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@use 'styles/utilities' as *;
2+
@use 'themes' as *;
3+
@use '../light/themes' as light;
4+
5+
$theme: $bootstrap;
6+
7+
:host {
8+
@include css-vars-from-theme(diff(light.$base, $theme), 'ig-radio-group');
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@use 'styles/utilities' as *;
2+
@use 'themes' as *;
3+
@use '../light/themes' as light;
4+
5+
$theme: $fluent;
6+
7+
:host {
8+
@include css-vars-from-theme(diff(light.$base, $theme), 'ig-radio-group');
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@use 'styles/utilities' as *;
2+
@use 'themes' as *;
3+
@use '../light/themes' as light;
4+
5+
$theme: $indigo;
6+
7+
:host {
8+
@include css-vars-from-theme(diff(light.$base, $theme), 'ig-radio-group');
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@use 'styles/utilities' as *;
2+
@use 'themes' as *;
3+
@use '../light/themes' as light;
4+
5+
$theme: $material;
6+
7+
:host {
8+
@include css-vars-from-theme(diff(light.$base, $theme), 'ig-radio-group');
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@use 'styles/utilities' as *;
2+
@use 'igniteui-theming/sass/themes/schemas/components/light/label' as *;
3+
4+
$base: digest-schema($light-label);
5+
$material: digest-schema($material-label);
6+
$bootstrap: digest-schema($bootstrap-label);
7+
$fluent: digest-schema($fluent-label);
8+
$indigo: digest-schema($indigo-label);
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@use 'styles/utilities' as *;
2+
@use 'themes' as *;
3+
4+
$theme: $bootstrap;
5+
6+
:host {
7+
@include css-vars-from-theme(diff($base, $theme), 'ig-radio-group');
8+
}

0 commit comments

Comments
 (0)