Skip to content

Commit 71616d9

Browse files
authored
Merge branch '20.1.x' into randriova/calendar-i18n-20.1.x
2 parents d47a519 + a970b68 commit 71616d9

File tree

7 files changed

+2512
-1278
lines changed

7 files changed

+2512
-1278
lines changed

angular.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,8 @@
307307
{
308308
"type": "bundle",
309309
"name": "styles",
310-
"maximumWarning": "500kb",
311-
"maximumError": "550kb"
310+
"maximumWarning": "600kb",
311+
"maximumError": "600kb"
312312
},
313313
{
314314
"type": "anyComponentStyle",

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

Lines changed: 62 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@ 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';
2124
import { DateRangeType } from '../../core/dates';
2225
import { IgxCalendarBaseDirective } from '../calendar-base';
23-
import { PlatformUtil, intoChunks } from '../../core/utils';
26+
import {PlatformUtil, intoChunks, getComponentTheme} from '../../core/utils';
2427
import { IViewChangingEventArgs } from './days-view.interface';
2528
import {
2629
areSameMonth,
@@ -31,6 +34,7 @@ import {
3134
isDateInRanges,
3235
} from "../common/helpers";
3336
import { CalendarDay } from '../common/model';
37+
import {IgxTheme, THEME_TOKEN, ThemeToken} from "../../services/theme/theme.token";
3438

3539
let NEXT_ID = 0;
3640

@@ -47,7 +51,7 @@ let NEXT_ID = 0;
4751
changeDetection: ChangeDetectionStrategy.OnPush,
4852
imports: [IgxDayItemComponent, TitleCasePipe]
4953
})
50-
export class IgxDaysViewComponent extends IgxCalendarBaseDirective {
54+
export class IgxDaysViewComponent extends IgxCalendarBaseDirective implements AfterContentChecked {
5155
#standalone = true;
5256

5357
/**
@@ -197,6 +201,33 @@ export class IgxDaysViewComponent extends IgxCalendarBaseDirective {
197201
private _hideTrailingDays: boolean;
198202
private _showActiveDay: boolean;
199203

204+
private _destroyRef = inject(DestroyRef);
205+
private _theme: IgxTheme;
206+
207+
@HostBinding('class.igx-days-view')
208+
public defaultClass = true;
209+
210+
// Theme-specific classes
211+
@HostBinding('class.igx-days-view--material')
212+
protected get isMaterial(): boolean {
213+
return this._theme === 'material';
214+
}
215+
216+
@HostBinding('class.igx-days-view--fluent')
217+
protected get isFluent(): boolean {
218+
return this._theme === 'fluent';
219+
}
220+
221+
@HostBinding('class.igx-days-view--bootstrap')
222+
protected get isBootstrap(): boolean {
223+
return this._theme === 'bootstrap';
224+
}
225+
226+
@HostBinding('class.igx-days-view--indigo')
227+
protected get isIndigo(): boolean {
228+
return this._theme === 'indigo';
229+
}
230+
200231
/**
201232
* @hidden
202233
*/
@@ -205,8 +236,37 @@ export class IgxDaysViewComponent extends IgxCalendarBaseDirective {
205236
@Inject(LOCALE_ID) _localeId: string,
206237
protected el: ElementRef,
207238
public override cdr: ChangeDetectorRef,
239+
@Inject(THEME_TOKEN) private themeToken: ThemeToken
240+
208241
) {
209242
super(platform, _localeId, null, cdr);
243+
244+
this._theme = this.themeToken.theme;
245+
246+
const themeChange = this.themeToken.onChange((theme) => {
247+
if (this._theme !== theme) {
248+
this._theme = theme;
249+
this.cdr.detectChanges();
250+
}
251+
});
252+
253+
this._destroyRef.onDestroy(() => themeChange.unsubscribe());
254+
}
255+
256+
private setComponentTheme() {
257+
// allow DOM theme override (same pattern as input-group)
258+
if (!this.themeToken.preferToken) {
259+
const theme = getComponentTheme(this.el.nativeElement);
260+
261+
if (theme && theme !== this._theme) {
262+
this._theme = theme;
263+
this.cdr.markForCheck();
264+
}
265+
}
266+
}
267+
268+
public ngAfterContentChecked() {
269+
this.setComponentTheme();
210270
}
211271

212272
/**

0 commit comments

Comments
 (0)