Skip to content

Commit 27077ed

Browse files
desig9steinsimeonoff
authored andcommitted
fix(calendar): fix material and indigo theme styles to match webC
1 parent 4ff6bfd commit 27077ed

File tree

6 files changed

+2525
-1277
lines changed

6 files changed

+2525
-1277
lines changed

angular.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@
311311
{
312312
"type": "bundle",
313313
"name": "styles",
314-
"maximumWarning": "500kb",
315-
"maximumError": "550kb"
314+
"maximumWarning": "600kb",
315+
"maximumError": "600kb"
316316
},
317317
{
318318
"type": "anyComponentStyle",

projects/igniteui-angular/calendar/src/calendar/days-view/days-view.component.ts

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,30 @@ import {
1313
ElementRef,
1414
ChangeDetectorRef,
1515
ChangeDetectionStrategy,
16+
inject,
17+
DestroyRef,
18+
AfterContentChecked
1619
} from '@angular/core';
1720
import { NG_VALUE_ACCESSOR } from '@angular/forms';
1821
import { TitleCasePipe } from '@angular/common';
1922
import { CalendarSelection, ScrollDirection } from '../../calendar/calendar';
2023
import { IgxDayItemComponent } from './day-item.component';
21-
import { CalendarDay, DateRangeType, PlatformUtil, areSameMonth, generateMonth, getClosestActiveDate, getNextActiveDate, getPreviousActiveDate, intoChunks, isDateInRanges } from 'igniteui-angular/core';
24+
import {
25+
CalendarDay,
26+
DateRangeType,
27+
PlatformUtil,
28+
areSameMonth,
29+
generateMonth,
30+
getClosestActiveDate,
31+
getNextActiveDate,
32+
getPreviousActiveDate,
33+
intoChunks,
34+
isDateInRanges,
35+
getComponentTheme,
36+
IgxTheme,
37+
THEME_TOKEN,
38+
ThemeToken
39+
} from 'igniteui-angular/core';
2240
import { IgxCalendarBaseDirective } from '../calendar-base';
2341
import { IViewChangingEventArgs } from './days-view.interface';
2442

@@ -37,7 +55,7 @@ let NEXT_ID = 0;
3755
changeDetection: ChangeDetectionStrategy.OnPush,
3856
imports: [IgxDayItemComponent, TitleCasePipe]
3957
})
40-
export class IgxDaysViewComponent extends IgxCalendarBaseDirective {
58+
export class IgxDaysViewComponent extends IgxCalendarBaseDirective implements AfterContentChecked {
4159
#standalone = true;
4260

4361
/**
@@ -187,6 +205,33 @@ export class IgxDaysViewComponent extends IgxCalendarBaseDirective {
187205
private _hideTrailingDays: boolean;
188206
private _showActiveDay: boolean;
189207

208+
private _destroyRef = inject(DestroyRef);
209+
private _theme: IgxTheme;
210+
211+
@HostBinding('class.igx-days-view')
212+
public defaultClass = true;
213+
214+
// Theme-specific classes
215+
@HostBinding('class.igx-days-view--material')
216+
protected get isMaterial(): boolean {
217+
return this._theme === 'material';
218+
}
219+
220+
@HostBinding('class.igx-days-view--fluent')
221+
protected get isFluent(): boolean {
222+
return this._theme === 'fluent';
223+
}
224+
225+
@HostBinding('class.igx-days-view--bootstrap')
226+
protected get isBootstrap(): boolean {
227+
return this._theme === 'bootstrap';
228+
}
229+
230+
@HostBinding('class.igx-days-view--indigo')
231+
protected get isIndigo(): boolean {
232+
return this._theme === 'indigo';
233+
}
234+
190235
/**
191236
* @hidden
192237
*/
@@ -195,8 +240,37 @@ export class IgxDaysViewComponent extends IgxCalendarBaseDirective {
195240
@Inject(LOCALE_ID) _localeId: string,
196241
protected el: ElementRef,
197242
public override cdr: ChangeDetectorRef,
243+
@Inject(THEME_TOKEN) private themeToken: ThemeToken
244+
198245
) {
199246
super(platform, _localeId, null, cdr);
247+
248+
this._theme = this.themeToken.theme;
249+
250+
const themeChange = this.themeToken.onChange((theme) => {
251+
if (this._theme !== theme) {
252+
this._theme = theme;
253+
this.cdr.detectChanges();
254+
}
255+
});
256+
257+
this._destroyRef.onDestroy(() => themeChange.unsubscribe());
258+
}
259+
260+
private setComponentTheme() {
261+
// allow DOM theme override (same pattern as input-group)
262+
if (!this.themeToken.preferToken) {
263+
const theme = getComponentTheme(this.el.nativeElement);
264+
265+
if (theme && theme !== this._theme) {
266+
this._theme = theme;
267+
this.cdr.markForCheck();
268+
}
269+
}
270+
}
271+
272+
public ngAfterContentChecked() {
273+
this.setComponentTheme();
200274
}
201275

202276
/**

0 commit comments

Comments
 (0)