Skip to content

Commit 19abcd9

Browse files
fix(calendar): fix material and indigo theme styles to match webC (#16371)
* fix(calendar): fix material and indigo theme styles to match webC * fix(calendar): update Fluent theme styles to align with design guidelines - Adjust date selection, hover, and focus styles. - Add support for range previews and various states specific to Fluent theme. - Refactor styles to accommodate Fluent theme-specific variants. * fix(calendar): fix calendar bootstrap theme parity with web components * fix(calendar): update Indigo theme styles for improved consistency * fix(calendar): refine bootstrap theme styles for date range and selection states * fix(calendar): update styles for Fluent theme range and preview * fix(calendar): enhance Material theme styles for range and selection states * fix(calendar): adjust date range border radius styles for fluent theme * fix(calendar): theme styles * fix(calendar): update theme styles for improved consistency across variants * fix(calendar): refactor and simplify theme styles - Remove `$bootstrap-theme` variable and use `$variant` for conditionals. - Consolidate redundant styles and improve readability. - Enhance support for theme-specific behaviors across all variants. * fix(calendar): add comprehensive Fluent theme styles for date states - Implement new styles for current, special, selected, and range states. - Add support for hover, focus, and preview across combinations of states. - Update border radius and alignment * refactor(calendar): add theme support for `IgxDaysViewComponent` - Implement dynamic theme bindings and theme-specific classes for Material, Fluent, Bootstrap, and Indigo variants. - Introduce `theme` input property and handle theme overrides via DOM or token. - Update `AfterContentChecked` to adapt theme changes dynamically. * fix(calendar): correct theme token import path in `days-view` component * fix(calendar): Fluent theme styles for month/year * fix(calendar): Fluent theme styles for month/year --------- Co-authored-by: Silvia Ivanova <59446295+SisIvanova@users.noreply.github.com>
1 parent f96df58 commit 19abcd9

File tree

6 files changed

+2518
-1278
lines changed

6 files changed

+2518
-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: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ import {
1212
booleanAttribute,
1313
ElementRef,
1414
ChangeDetectorRef,
15-
ChangeDetectionStrategy,
15+
ChangeDetectionStrategy, inject, DestroyRef, AfterContentChecked,
1616
} from '@angular/core';
1717
import { NG_VALUE_ACCESSOR } from '@angular/forms';
1818
import { TitleCasePipe } from '@angular/common';
1919
import { CalendarSelection, ScrollDirection } from '../../calendar/calendar';
2020
import { IgxDayItemComponent } from './day-item.component';
2121
import { DateRangeType } from '../../core/dates';
2222
import { IgxCalendarBaseDirective } from '../calendar-base';
23-
import { PlatformUtil, intoChunks } from '../../core/utils';
23+
import {PlatformUtil, intoChunks, getComponentTheme} from '../../core/utils';
2424
import { IViewChangingEventArgs } from './days-view.interface';
2525
import {
2626
areSameMonth,
@@ -31,6 +31,7 @@ import {
3131
isDateInRanges,
3232
} from "../common/helpers";
3333
import { CalendarDay } from '../common/model';
34+
import {IgxTheme, THEME_TOKEN, ThemeToken} from "../../services/theme/theme.token";
3435

3536
let NEXT_ID = 0;
3637

@@ -47,7 +48,7 @@ let NEXT_ID = 0;
4748
changeDetection: ChangeDetectionStrategy.OnPush,
4849
imports: [IgxDayItemComponent, TitleCasePipe]
4950
})
50-
export class IgxDaysViewComponent extends IgxCalendarBaseDirective {
51+
export class IgxDaysViewComponent extends IgxCalendarBaseDirective implements AfterContentChecked {
5152
#standalone = true;
5253

5354
/**
@@ -197,6 +198,42 @@ export class IgxDaysViewComponent extends IgxCalendarBaseDirective {
197198
private _hideTrailingDays: boolean;
198199
private _showActiveDay: boolean;
199200

201+
private _destroyRef = inject(DestroyRef);
202+
private _theme: IgxTheme;
203+
204+
@HostBinding('class.igx-days-view')
205+
public defaultClass = true;
206+
207+
// Theme-specific classes
208+
@HostBinding('class.igx-days-view--material')
209+
public get isMaterial(): boolean {
210+
return this._theme === 'material';
211+
}
212+
213+
@HostBinding('class.igx-days-view--fluent')
214+
public get isFluent(): boolean {
215+
return this._theme === 'fluent';
216+
}
217+
218+
@HostBinding('class.igx-days-view--bootstrap')
219+
public get isBootstrap(): boolean {
220+
return this._theme === 'bootstrap';
221+
}
222+
223+
@HostBinding('class.igx-days-view--indigo')
224+
public get isIndigo(): boolean {
225+
return this._theme === 'indigo';
226+
}
227+
228+
@Input()
229+
public set theme(value: IgxTheme) {
230+
this._theme = value;
231+
}
232+
233+
public get theme(): IgxTheme {
234+
return this._theme;
235+
}
236+
200237
/**
201238
* @hidden
202239
*/
@@ -205,8 +242,37 @@ export class IgxDaysViewComponent extends IgxCalendarBaseDirective {
205242
@Inject(LOCALE_ID) _localeId: string,
206243
protected el: ElementRef,
207244
public override cdr: ChangeDetectorRef,
245+
@Inject(THEME_TOKEN) private themeToken: ThemeToken
246+
208247
) {
209248
super(platform, _localeId, null, cdr);
249+
250+
this._theme = this.themeToken.theme;
251+
252+
const themeChange = this.themeToken.onChange((theme) => {
253+
if (this._theme !== theme) {
254+
this._theme = theme;
255+
this.cdr.detectChanges();
256+
}
257+
});
258+
259+
this._destroyRef.onDestroy(() => themeChange.unsubscribe());
260+
}
261+
262+
private setComponentTheme() {
263+
// allow DOM theme override (same pattern as input-group)
264+
if (!this.themeToken.preferToken) {
265+
const theme = getComponentTheme(this.el.nativeElement);
266+
267+
if (theme && theme !== this._theme) {
268+
this.theme = theme;
269+
this.cdr.markForCheck();
270+
}
271+
}
272+
}
273+
274+
public ngAfterContentChecked() {
275+
this.setComponentTheme();
210276
}
211277

212278
/**

0 commit comments

Comments
 (0)