Skip to content

Commit db68dd5

Browse files
authored
refactor: Dropped themes decorator for explicit initialization (#1746)
1 parent d52c9f8 commit db68dd5

73 files changed

Lines changed: 445 additions & 366 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/components/avatar/avatar.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { html, LitElement, nothing, type PropertyValues } from 'lit';
22
import { property, state } from 'lit/decorators.js';
33
import { ifDefined } from 'lit/directives/if-defined.js';
4-
import { themes } from '../../theming/theming-decorator.js';
4+
import { addThemingController } from '../../theming/theming-controller.js';
55
import { addInternalsController } from '../common/controllers/internals.js';
66
import { registerComponent } from '../common/definitions/register.js';
77
import type { AvatarShape } from '../types.js';
@@ -22,7 +22,6 @@ import { all } from './themes/themes.js';
2222
* @csspart image - The image wrapper of the avatar.
2323
* @csspart icon - The icon wrapper of the avatar.
2424
*/
25-
@themes(all)
2625
export default class IgcAvatarComponent extends LitElement {
2726
public static readonly tagName = 'igc-avatar';
2827
public static override styles = [styles, shared];
@@ -70,6 +69,11 @@ export default class IgcAvatarComponent extends LitElement {
7069
@property({ reflect: true })
7170
public shape: AvatarShape = 'square';
7271

72+
constructor() {
73+
super();
74+
addThemingController(this, all);
75+
}
76+
7377
protected override willUpdate(changedProperties: PropertyValues<this>): void {
7478
if (changedProperties.has('initials') || changedProperties.has('alt')) {
7579
this._internals.setARIA({

src/components/badge/badge.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { html, LitElement, type PropertyValues } from 'lit';
22
import { property } from 'lit/decorators.js';
3-
import { themes } from '../../theming/theming-decorator.js';
3+
import { addThemingController } from '../../theming/theming-controller.js';
44
import { addInternalsController } from '../common/controllers/internals.js';
55
import { registerComponent } from '../common/definitions/register.js';
66
import type { BadgeShape, StyleVariant } from '../types.js';
@@ -18,7 +18,6 @@ import { all } from './themes/themes.js';
1818
*
1919
* @csspart base - The base wrapper of the badge.
2020
*/
21-
@themes(all)
2221
export default class IgcBadgeComponent extends LitElement {
2322
public static readonly tagName = 'igc-badge';
2423
public static override styles = [styles, shared];
@@ -53,6 +52,11 @@ export default class IgcBadgeComponent extends LitElement {
5352
@property({ reflect: true })
5453
public shape: BadgeShape = 'rounded';
5554

55+
constructor() {
56+
super();
57+
addThemingController(this, all);
58+
}
59+
5660
protected override willUpdate(changedProperties: PropertyValues<this>): void {
5761
if (changedProperties.has('variant')) {
5862
this._internals.setARIA({ ariaRoleDescription: `badge ${this.variant}` });

src/components/banner/banner.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { createRef, type Ref, ref } from 'lit/directives/ref.js';
44

55
import { addAnimationController } from '../../animations/player.js';
66
import { growVerIn, growVerOut } from '../../animations/presets/grow/index.js';
7-
import { themes } from '../../theming/theming-decorator.js';
7+
import { addThemingController } from '../../theming/theming-controller.js';
88
import IgcButtonComponent from '../button/button.js';
99
import { addInternalsController } from '../common/controllers/internals.js';
1010
import { registerComponent } from '../common/definitions/register.js';
@@ -38,7 +38,6 @@ export interface IgcBannerComponentEventMap {
3838
* @csspart actions - The part that holds the banner action buttons.
3939
*/
4040

41-
@themes(all)
4241
export default class IgcBannerComponent extends EventEmitterMixin<
4342
IgcBannerComponentEventMap,
4443
Constructor<LitElement>
@@ -67,6 +66,8 @@ export default class IgcBannerComponent extends EventEmitterMixin<
6766
constructor() {
6867
super();
6968

69+
addThemingController(this, all);
70+
7071
addInternalsController(this, {
7172
initialARIA: {
7273
role: 'status',

src/components/button-group/button-group.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { html, LitElement } from 'lit';
22
import { property, queryAssignedElements } from 'lit/decorators.js';
33

4-
import { themes } from '../../theming/theming-decorator.js';
4+
import { addThemingController } from '../../theming/theming-controller.js';
55
import {
66
createMutationController,
77
type MutationControllerParams,
@@ -35,7 +35,6 @@ export interface IgcButtonGroupComponentEventMap {
3535
*
3636
* @csspart group - The button group container.
3737
*/
38-
@themes(all)
3938
export default class IgcButtonGroupComponent extends EventEmitterMixin<
4039
IgcButtonGroupComponentEventMap,
4140
Constructor<LitElement>
@@ -134,6 +133,8 @@ export default class IgcButtonGroupComponent extends EventEmitterMixin<
134133
constructor() {
135134
super();
136135

136+
addThemingController(this, all);
137+
137138
createMutationController(this, {
138139
callback: this._observerCallback,
139140
filter: [IgcToggleButtonComponent.tagName],

src/components/button-group/toggle-button.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { html, LitElement } from 'lit';
22
import { property, query } from 'lit/decorators.js';
33

4-
import { themes } from '../../theming/theming-decorator.js';
4+
import { addThemingController } from '../../theming/theming-controller.js';
55
import { addKeyboardFocusRing } from '../common/controllers/focus-ring.js';
66
import { shadowOptions } from '../common/decorators/shadow-options.js';
77
import { registerComponent } from '../common/definitions/register.js';
@@ -20,7 +20,6 @@ import { styles as shared } from './themes/shared/button/button.common.css.js';
2020
*
2121
* @csspart toggle - The native button element.
2222
*/
23-
@themes(all)
2423
@shadowOptions({ delegatesFocus: true })
2524
export default class IgcToggleButtonComponent extends LitElement {
2625
public static override styles = [styles, shared];
@@ -57,6 +56,11 @@ export default class IgcToggleButtonComponent extends LitElement {
5756
@property({ type: Boolean, reflect: true })
5857
public disabled = false;
5958

59+
constructor() {
60+
super();
61+
addThemingController(this, all);
62+
}
63+
6064
/* alternateName: focusComponent */
6165
/** Sets focus on the button. */
6266
public override focus(options?: FocusOptions): void {

src/components/button/button.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { html } from 'lit';
22
import { property } from 'lit/decorators.js';
33

4-
import { themes } from '../../theming/theming-decorator.js';
4+
import { addThemingController } from '../../theming/theming-controller.js';
55
import { registerComponent } from '../common/definitions/register.js';
66
import type { ButtonVariant } from '../types.js';
77
import { IgcButtonBaseComponent } from './button-base.js';
@@ -23,7 +23,6 @@ import { all } from './themes/button/themes.js';
2323
* @csspart prefix - The prefix container of the igc-button component.
2424
* @csspart suffix - The suffix container of the igc-button component.
2525
*/
26-
@themes(all)
2726
export default class IgcButtonComponent extends IgcButtonBaseComponent {
2827
public static readonly tagName = 'igc-button';
2928
protected static styles = [styles, shared];
@@ -40,6 +39,11 @@ export default class IgcButtonComponent extends IgcButtonBaseComponent {
4039
@property({ reflect: true })
4140
public variant: ButtonVariant = 'contained';
4241

42+
constructor() {
43+
super();
44+
addThemingController(this, all);
45+
}
46+
4347
protected renderContent() {
4448
return html`
4549
<slot name="prefix"></slot>

src/components/button/icon-button.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { html } from 'lit';
22
import { property } from 'lit/decorators.js';
33
import { ifDefined } from 'lit/directives/if-defined.js';
44

5-
import { themes } from '../../theming/theming-decorator.js';
5+
import { addThemingController } from '../../theming/theming-controller.js';
66
import { blazorInclude } from '../common/decorators/blazorInclude.js';
77
import { registerComponent } from '../common/definitions/register.js';
88
import IgcIconComponent from '../icon/icon.js';
@@ -22,7 +22,6 @@ import { all } from './themes/icon-button/themes.js';
2222
* @csspart base - The wrapping element of the icon button.
2323
* @csspart icon - The icon element of the icon button.
2424
*/
25-
@themes(all)
2625
export default class IgcIconButtonComponent extends IgcButtonBaseComponent {
2726
public static readonly tagName = 'igc-icon-button';
2827
protected static styles = [styles, shared];
@@ -61,6 +60,11 @@ export default class IgcIconButtonComponent extends IgcButtonBaseComponent {
6160
@property({ reflect: true })
6261
public variant: IconButtonVariant = 'contained';
6362

63+
constructor() {
64+
super();
65+
addThemingController(this, all);
66+
}
67+
6468
protected renderContent() {
6569
return html`
6670
${this.name || this.mirrored

src/components/calendar/calendar.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { choose } from 'lit/directives/choose.js';
44
import { createRef, type Ref, ref } from 'lit/directives/ref.js';
55
import { styleMap } from 'lit/directives/style-map.js';
66

7-
import { themes } from '../../theming/theming-decorator.js';
7+
import { addThemingController } from '../../theming/theming-controller.js';
88
import {
99
addKeybindings,
1010
arrowDown,
@@ -107,7 +107,6 @@ export const focusActiveDate = Symbol();
107107
* @csspart selected - Indicates selected state. Applies to date, month and year elements of the calendar.
108108
* @csspart current - Indicates current state. Applies to date, month and year elements of the calendar.
109109
*/
110-
@themes(all)
111110
export default class IgcCalendarComponent extends EventEmitterMixin<
112111
IgcCalendarComponentEventMap,
113112
Constructor<IgcCalendarBaseComponent>
@@ -413,6 +412,8 @@ export default class IgcCalendarComponent extends EventEmitterMixin<
413412
constructor() {
414413
super();
415414

415+
addThemingController(this, all);
416+
416417
addKeybindings(this, {
417418
skip: this.isNotFromCalendarView,
418419
ref: this.contentRef,

src/components/calendar/days-view/days-view.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { html, nothing } from 'lit';
22
import { property, query, state } from 'lit/decorators.js';
33

4-
import { themes } from '../../../theming/theming-decorator.js';
4+
import { addThemingController } from '../../../theming/theming-controller.js';
55
import { addKeybindings } from '../../common/controllers/key-bindings.js';
66
import { blazorIndirectRender } from '../../common/decorators/blazorIndirectRender.js';
77
import { blazorSuppressComponent } from '../../common/decorators/blazorSuppressComponent.js';
@@ -55,7 +55,6 @@ export interface IgcDaysViewEventMap extends IgcCalendarComponentEventMap {
5555
*/
5656
@blazorSuppressComponent
5757
@blazorIndirectRender
58-
@themes(all)
5958
export default class IgcDaysViewComponent extends EventEmitterMixin<
6059
IgcDaysViewEventMap,
6160
Constructor<IgcCalendarBaseComponent>
@@ -140,6 +139,8 @@ export default class IgcDaysViewComponent extends EventEmitterMixin<
140139
constructor() {
141140
super();
142141

142+
addThemingController(this, all);
143+
143144
addKeybindings(this, {
144145
bindingDefaults: { preventDefault: true },
145146
}).setActivateHandler(this.handleInteraction);

src/components/calendar/months-view/months-view.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { html, LitElement } from 'lit';
22
import { property, query, state } from 'lit/decorators.js';
33
import { range } from 'lit/directives/range.js';
44

5-
import { themes } from '../../../theming/theming-decorator.js';
5+
import { addThemingController } from '../../../theming/theming-controller.js';
66
import { addKeybindings } from '../../common/controllers/key-bindings.js';
77
import { blazorIndirectRender } from '../../common/decorators/blazorIndirectRender.js';
88
import { blazorSuppressComponent } from '../../common/decorators/blazorSuppressComponent.js';
@@ -30,7 +30,6 @@ import type { IgcCalendarComponentEventMap } from '../types.js';
3030
*/
3131
@blazorIndirectRender
3232
@blazorSuppressComponent
33-
@themes(all)
3433
export default class IgcMonthsViewComponent extends EventEmitterMixin<
3534
IgcCalendarComponentEventMap,
3635
Constructor<LitElement>
@@ -86,6 +85,8 @@ export default class IgcMonthsViewComponent extends EventEmitterMixin<
8685
constructor() {
8786
super();
8887

88+
addThemingController(this, all);
89+
8990
addKeybindings(this, {
9091
bindingDefaults: { preventDefault: true },
9192
}).setActivateHandler(this.handleInteraction);

0 commit comments

Comments
 (0)