Skip to content

Commit 1ae6f78

Browse files
committed
refactor(days-view): apply suggested approach
1 parent 1db9095 commit 1ae6f78

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/components/calendar/days-view/days-view.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { html, nothing } from 'lit';
22
import { property, query, state } from 'lit/decorators.js';
33

4+
import { ifDefined } from 'lit/directives/if-defined.js';
45
import { themes } from '../../../theming/theming-decorator.js';
56
import { addKeybindings } from '../../common/controllers/key-bindings.js';
67
import { blazorIndirectRender } from '../../common/decorators/blazorIndirectRender.js';
@@ -398,10 +399,11 @@ export default class IgcDaysViewComponent extends EventEmitterMixin<
398399
};
399400
}
400401

401-
protected renderDay(day: CalendarDay, props: any) {
402+
protected renderDay(day: CalendarDay, today: CalendarDay) {
402403
const ariaLabel = this.intlFormatDay(day);
403404
const { changePreview, clearPreview } = this.getDayHandlers(day);
404405

406+
const props = this.getDayProperties(day, today);
405407
const parts = partNameMap(props);
406408

407409
return html`
@@ -480,17 +482,18 @@ export default class IgcDaysViewComponent extends EventEmitterMixin<
480482
const last = weeks.length - 1;
481483

482484
for (const [idx, week] of weeks.entries()) {
483-
const weekDaysProps: any[] = [];
484-
for (const day of week) {
485-
weekDaysProps.push(this.getDayProperties(day, today));
485+
let hidden: boolean | undefined;
486+
if (idx === 0 || idx === last) {
487+
hidden =
488+
week.every((day) => this.getDayProperties(day, today).hidden) ||
489+
undefined;
486490
}
487-
const hidden = weekDaysProps.every((p) => p.hidden);
488491
yield html`
489-
<div role="row" part="days-row" aria-hidden=${hidden}>
492+
<div role="row" part="days-row" aria-hidden=${ifDefined(hidden)}>
490493
${this.showWeekNumbers
491494
? this.renderWeekNumber(week[0], idx === last)
492495
: nothing}
493-
${week.map((day, i) => this.renderDay(day, weekDaysProps[i]))}
496+
${week.map((day) => this.renderDay(day, today))}
494497
</div>
495498
`;
496499
}

0 commit comments

Comments
 (0)