Skip to content

Commit 2f0d40a

Browse files
authored
fix(theme-service): get theme from component stylesheet instead of the global theme (#14622)
1 parent ebb96f7 commit 2f0d40a

Some content is hidden

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

46 files changed

+674
-629
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"@types/source-map": "0.5.2",
8181
"express": "^4.19.2",
8282
"fflate": "^0.8.1",
83-
"igniteui-theming": "^10.1.0",
83+
"igniteui-theming": "^11.0.0",
8484
"igniteui-trial-watermark": "^3.0.2",
8585
"lodash-es": "^4.17.21",
8686
"rxjs": "^7.8.0",

projects/igniteui-angular/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"igniteui-trial-watermark": "^3.0.2",
7575
"lodash-es": "^4.17.21",
7676
"uuid": "^9.0.0",
77-
"igniteui-theming": "^10.1.0",
77+
"igniteui-theming": "^11.0.0",
7878
"@igniteui/material-icons-extended": "^3.0.0"
7979
},
8080
"peerDependencies": {

projects/igniteui-angular/src/lib/carousel/carousel-base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export abstract class IgxCarouselComponentBase {
4545

4646
constructor(
4747
@Inject(IgxAngularAnimationService) private animationService: AnimationService,
48-
private cdr: ChangeDetectorRef) {
48+
protected cdr: ChangeDetectorRef) {
4949
}
5050

5151
/** @hidden */

projects/igniteui-angular/src/lib/carousel/carousel.component.ts

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { NgIf, NgClass, NgFor, NgTemplateOutlet } from '@angular/common';
22
import {
33
AfterContentInit,
4+
AfterViewInit,
45
ChangeDetectorRef,
56
Component,
67
ContentChild,
@@ -88,7 +89,7 @@ export class CarouselHammerConfig extends HammerGestureConfig {
8889
imports: [IgxIconComponent, NgIf, NgClass, NgFor, NgTemplateOutlet]
8990
})
9091

91-
export class IgxCarouselComponent extends IgxCarouselComponentBase implements OnDestroy, AfterContentInit {
92+
export class IgxCarouselComponent extends IgxCarouselComponentBase implements OnDestroy, AfterViewInit, AfterContentInit {
9293

9394
/**
9495
* Sets the `id` of the carousel.
@@ -587,26 +588,6 @@ export class IgxCarouselComponent extends IgxCarouselComponentBase implements On
587588
) {
588589
super(animationService, cdr);
589590
this.differ = this.iterableDiffers.find([]).create(null);
590-
this.theme = this.theme ?? this.themeService.theme;
591-
592-
for (const icon of this._icons) {
593-
switch(this.theme) {
594-
case 'indigo':
595-
this.iconService.addIconRef(
596-
icon.name,
597-
icon.family,
598-
icon.ref.get('indigo'),
599-
);
600-
break;
601-
case 'material':
602-
default:
603-
this.iconService.addIconRef(
604-
icon.name,
605-
icon.family,
606-
icon.ref.get('material'),
607-
);
608-
}
609-
}
610591
}
611592

612593

@@ -738,6 +719,37 @@ export class IgxCarouselComponent extends IgxCarouselComponentBase implements On
738719
}
739720
}
740721

722+
/** @hidden */
723+
public ngAfterViewInit() {
724+
this.cdr.detach();
725+
726+
if (!this.theme) {
727+
this.theme = this.themeService.getComponentTheme(this.element);
728+
}
729+
730+
for (const icon of this._icons) {
731+
switch(this.theme) {
732+
case 'indigo':
733+
this.iconService.addIconRef(
734+
icon.name,
735+
icon.family,
736+
icon.ref.get('indigo'),
737+
);
738+
break;
739+
case 'material':
740+
default:
741+
this.iconService.addIconRef(
742+
icon.name,
743+
icon.family,
744+
icon.ref.get('material'),
745+
);
746+
}
747+
}
748+
749+
this.cdr.detectChanges();
750+
this.cdr.reattach();
751+
}
752+
741753
/** @hidden */
742754
public ngAfterContentInit() {
743755
this.slides.changes

projects/igniteui-angular/src/lib/core/styles/components/action-strip/_action-strip-theme.scss

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@
7272

7373
$variant: map.get($theme, '_meta', 'variant');
7474
$icon-button-size: map.get((
75-
material: rem(36px),
76-
fluent: rem(32px),
77-
bootstrap: rem(36px),
78-
indigo-design: rem(36px),
75+
'material': rem(36px),
76+
'fluent': rem(32px),
77+
'bootstrap': rem(36px),
78+
'indigo': rem(36px),
7979
), $variant);
8080
$button-size: sizable(rem(28px), rem(28px), $icon-button-size);
8181
$icon-size: sizable(rem(14px), rem(14px), rem(18px));
@@ -179,7 +179,7 @@
179179
color: var-get($theme, 'icon-color');
180180
}
181181

182-
@if $variant == 'indigo-design' or $variant == 'fluent' {
182+
@if $variant == 'indigo' or $variant == 'fluent' {
183183
border-radius: var-get($theme, 'actions-border-radius');
184184
}
185185
}

projects/igniteui-angular/src/lib/core/styles/components/avatar/_avatar-theme.scss

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@
6969
$variant: map.get($theme, '_meta', 'variant');
7070
$bootstrap-theme: $variant == 'bootstrap';
7171
$box-shadow: map.get((
72-
material: null,
73-
fluent: null,
74-
bootstrap: 0 0 0 rem(3px) var-get($theme, 'background'),
75-
indigo-design: null,
72+
'material': null,
73+
'fluent': null,
74+
'bootstrap': 0 0 0 rem(3px) var-get($theme, 'background'),
75+
'indigo': null,
7676
), $variant);
7777

7878
%igx-avatar-outline {
@@ -108,7 +108,7 @@
108108
color: var-get($theme, 'icon-color');
109109
}
110110

111-
@if $variant == 'indigo-design' {
111+
@if $variant == 'indigo' {
112112
igx-icon {
113113
--component-size: 1;
114114
}

projects/igniteui-angular/src/lib/core/styles/components/badge/_badge-theme.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
color: var-get($theme, 'icon-color');
123123
}
124124

125-
@if $variant == 'indigo-design' {
125+
@if $variant == 'indigo' {
126126
igx-icon {
127127
$icon-size: rem(12px);
128128

projects/igniteui-angular/src/lib/core/styles/components/banner/_banner-theme.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
box-shadow: inset 0 rem(-1px) 0 0 var-get($theme, 'banner-border-color');
103103
border-radius: var-get($theme, 'border-radius');
104104

105-
@if $variant == 'indigo-design' {
105+
@if $variant == 'indigo' {
106106
box-shadow: inset 0 0 0 rem(1px) var-get($theme, 'banner-border-color');
107107
padding: rem(16px);
108108
}
@@ -134,7 +134,7 @@
134134
flex: 1 0 0%;
135135
gap: rem(16px);
136136

137-
@if $variant == 'indigo-design' {
137+
@if $variant == 'indigo' {
138138
gap: rem(8px);
139139
} @else {
140140
padding: 0 rem(8px);

projects/igniteui-angular/src/lib/core/styles/components/bottom-nav/_bottom-nav-theme.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,14 @@
186186
igx-icon {
187187
--component-size: 3;
188188

189-
@if $variant == 'indigo-design' {
189+
@if $variant == 'indigo' {
190190
--size: rem(16px);
191191
}
192192
}
193193
}
194194

195195
%igx-bottom-nav-menu-item--disabled {
196-
@if $variant != 'indigo-design' {
196+
@if $variant != 'indigo' {
197197
opacity: .5;
198198
}
199199

@@ -226,7 +226,7 @@
226226
justify-content: center;
227227
color: var-get($theme, 'icon-color');
228228

229-
@if $variant != 'indigo-design' {
229+
@if $variant != 'indigo' {
230230
padding: 0 rem(8px);
231231
height: rem(24px);
232232
transform: translateZ(0);
@@ -250,7 +250,7 @@
250250
color: var-get($theme, 'label-selected-color');
251251
}
252252

253-
@if $variant != 'indigo-design' {
253+
@if $variant != 'indigo' {
254254
%igx-tab-icon--selected {
255255
transform: translateY(-2px);
256256
}

0 commit comments

Comments
 (0)