Skip to content

Commit dd3a11c

Browse files
fix(calendar): fix material and indigo theme styles to match webC (#16543)
Co-authored-by: desig9stein <mspopovv@gmail.com>
1 parent ba04b5c commit dd3a11c

File tree

6 files changed

+2545
-1279
lines changed

6 files changed

+2545
-1279
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: 96 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,42 @@
1-
import { Component, Output, EventEmitter, Input, HostListener, ViewChildren, QueryList, HostBinding, booleanAttribute, ElementRef, ChangeDetectorRef, ChangeDetectionStrategy, inject } from '@angular/core';
1+
import {
2+
Component,
3+
Output,
4+
EventEmitter,
5+
Input,
6+
HostListener,
7+
ViewChildren,
8+
QueryList,
9+
HostBinding,
10+
booleanAttribute,
11+
ElementRef,
12+
ChangeDetectorRef,
13+
ChangeDetectionStrategy,
14+
inject,
15+
DestroyRef,
16+
AfterContentChecked
17+
} from '@angular/core';
218
import { NG_VALUE_ACCESSOR } from '@angular/forms';
319
import { TitleCasePipe } from '@angular/common';
420
import { CalendarSelection, ScrollDirection } from '../../calendar/calendar';
521
import { IgxDayItemComponent } from './day-item.component';
6-
import { CalendarDay, DateRangeType, areSameMonth, generateMonth, getClosestActiveDate, getNextActiveDate, getPreviousActiveDate, intoChunks, isDateInRanges } from 'igniteui-angular/core';
22+
import {
23+
CalendarDay,
24+
DateRangeType,
25+
areSameMonth,
26+
generateMonth,
27+
getClosestActiveDate,
28+
getNextActiveDate,
29+
getPreviousActiveDate,
30+
intoChunks,
31+
isDateInRanges,
32+
getComponentTheme,
33+
IgxTheme,
34+
THEME_TOKEN,
35+
ThemeToken
36+
} from 'igniteui-angular/core';
737
import { IgxCalendarBaseDirective } from '../calendar-base';
838
import { IViewChangingEventArgs } from './days-view.interface';
39+
import { KeyboardNavigationService } from '../calendar.services';
940

1041
let NEXT_ID = 0;
1142

@@ -16,16 +47,17 @@ let NEXT_ID = 0;
1647
provide: NG_VALUE_ACCESSOR,
1748
useExisting: IgxDaysViewComponent
1849
},
50+
KeyboardNavigationService
1951
],
2052
selector: 'igx-days-view',
2153
templateUrl: 'days-view.component.html',
2254
changeDetection: ChangeDetectionStrategy.OnPush,
2355
imports: [IgxDayItemComponent, TitleCasePipe]
2456
})
25-
export class IgxDaysViewComponent extends IgxCalendarBaseDirective {
57+
export class IgxDaysViewComponent extends IgxCalendarBaseDirective implements AfterContentChecked {
2658
protected el = inject(ElementRef);
2759
public override cdr = inject(ChangeDetectorRef);
28-
60+
private themeToken: ThemeToken = inject(THEME_TOKEN);
2961
#standalone = true;
3062

3163
/**
@@ -175,6 +207,66 @@ export class IgxDaysViewComponent extends IgxCalendarBaseDirective {
175207
private _hideTrailingDays: boolean;
176208
private _showActiveDay: boolean;
177209

210+
private _destroyRef = inject(DestroyRef);
211+
private _theme: IgxTheme;
212+
213+
@HostBinding('class.igx-days-view')
214+
public defaultClass = true;
215+
216+
// Theme-specific classes
217+
@HostBinding('class.igx-days-view--material')
218+
protected get isMaterial(): boolean {
219+
return this._theme === 'material';
220+
}
221+
222+
@HostBinding('class.igx-days-view--fluent')
223+
protected get isFluent(): boolean {
224+
return this._theme === 'fluent';
225+
}
226+
227+
@HostBinding('class.igx-days-view--bootstrap')
228+
protected get isBootstrap(): boolean {
229+
return this._theme === 'bootstrap';
230+
}
231+
232+
@HostBinding('class.igx-days-view--indigo')
233+
protected get isIndigo(): boolean {
234+
return this._theme === 'indigo';
235+
}
236+
237+
/**
238+
* @hidden
239+
*/
240+
constructor() {
241+
super();
242+
this._theme = this.themeToken.theme;
243+
244+
const themeChange = this.themeToken.onChange((theme) => {
245+
if (this._theme !== theme) {
246+
this._theme = theme;
247+
this.cdr.detectChanges();
248+
}
249+
});
250+
251+
this._destroyRef.onDestroy(() => themeChange.unsubscribe());
252+
}
253+
254+
private setComponentTheme() {
255+
// allow DOM theme override (same pattern as input-group)
256+
if (!this.themeToken.preferToken) {
257+
const theme = getComponentTheme(this.el.nativeElement);
258+
259+
if (theme && theme !== this._theme) {
260+
this._theme = theme;
261+
this.cdr.markForCheck();
262+
}
263+
}
264+
}
265+
266+
public ngAfterContentChecked() {
267+
this.setComponentTheme();
268+
}
269+
178270
/**
179271
* @hidden
180272
*/

0 commit comments

Comments
 (0)