Skip to content

Commit 29c311a

Browse files
authored
fix(calendar): reflect the orientation attr. (#1775)
1 parent 81f15e2 commit 29c311a

File tree

8 files changed

+22
-26
lines changed

8 files changed

+22
-26
lines changed

src/components/calendar/calendar-rendering.spec.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,13 @@ describe('Calendar Rendering', () => {
140140
expect(last.children.item(6)?.part.contains('hidden')).to.be.true;
141141
});
142142

143-
it('should change orientation', async () => {
144-
const dom = getCalendarDOM(calendar);
145-
146-
expect(
147-
getComputedStyle(dom.content).getPropertyValue('flex-direction')
148-
).to.equal('row');
149-
143+
it('should set vertical orientation part', async () => {
150144
calendar.orientation = 'vertical';
151145
await elementUpdated(calendar);
152146

153-
expect(
154-
getComputedStyle(dom.content).getPropertyValue('flex-direction')
155-
).to.equal('column');
147+
const dom = getCalendarDOM(calendar);
148+
expect(dom.content).to.exist;
149+
expect(dom.content.part.contains('content-vertical')).to.be.true;
156150
});
157151

158152
it('successfully enables and disables `hideHeader`', async () => {

src/components/calendar/calendar.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import { html, nothing } from 'lit';
22
import { property, query, queryAll, state } from 'lit/decorators.js';
33
import { choose } from 'lit/directives/choose.js';
44
import { createRef, type Ref, ref } from 'lit/directives/ref.js';
5-
import { styleMap } from 'lit/directives/style-map.js';
6-
75
import { addThemingController } from '../../theming/theming-controller.js';
86
import {
97
addKeybindings,
@@ -74,6 +72,7 @@ export const focusActiveDate = Symbol();
7472
* @csspart header-title - The header title element of the calendar.
7573
* @csspart header-date - The header date element of the calendar.
7674
* @csspart content - The content element which contains the views and navigation elements of the calendar.
75+
* @csspart content-vertical - The content element which contains the views and navigation elements of the calendar in vertical orientation.
7776
* @csspart navigation - The navigation container element of the calendar.
7877
* @csspart months-navigation - The months navigation button element of the calendar.
7978
* @csspart years-navigation - The years navigation button element of the calendar.
@@ -610,7 +609,7 @@ export default class IgcCalendarComponent extends EventEmitterMixin<
610609
@igcActiveDateChange=${this.activeDateChanged}
611610
@igcRangePreviewDateChange=${this.rangePreviewDateChanged}
612611
part="days-view"
613-
exportparts="days-row, label, date-inner, week-number-inner, week-number, date, first, last, selected, inactive, hidden, current, weekend, range, special, disabled, single, preview"
612+
exportparts="days-row, label, date-inner, week-number-inner, week-number, date, first, last, selected, inactive, hidden, current, content-vertical, weekend, range, special, disabled, single, preview"
614613
.active=${this.activeDaysViewIndex === idx}
615614
.activeDate=${date.native}
616615
.disabledDates=${this.disabledDates}
@@ -663,17 +662,14 @@ export default class IgcCalendarComponent extends EventEmitterMixin<
663662
}
664663

665664
protected override render() {
666-
const direction = this._isDayView && this.orientation === 'horizontal';
667-
668-
const styles = {
669-
display: 'flex',
670-
flexGrow: 1,
671-
flexDirection: direction ? 'row' : 'column',
665+
const parts = {
666+
content: true,
667+
'content-vertical': this._isDayView && this.orientation === 'vertical',
672668
};
673669

674670
return html`
675671
${this.renderHeader()}
676-
<div ${ref(this.contentRef)} part="content" style=${styleMap(styles)}>
672+
<div ${ref(this.contentRef)} part=${partMap(parts)}>
677673
${choose(this.activeView, [
678674
['days', () => this.renderDaysView()],
679675
['months', () => this.renderMonthView()],

src/components/calendar/helpers.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export function getCalendarDOM(element: IgcCalendarComponent) {
7676
},
7777
},
7878
get content() {
79-
return root.querySelector<HTMLElement>('[part="content"]')!;
79+
return root.querySelector<HTMLElement>('[part~="content"]')!;
8080
},
8181
views: {
8282
get days() {

src/components/calendar/themes/calendar.base.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,18 @@
139139
padding: rem(16px);
140140
}
141141

142-
[part='content'] {
142+
[part~='content'] {
143+
display: flex;
144+
flex-grow: 1;
143145
border-radius: inherit;
144146
border-top-left-radius: 0;
145147
border-top-right-radius: 0;
146148
}
147149

150+
[part~='content-vertical'] {
151+
flex-direction: column;
152+
}
153+
148154
[part='header-date'],
149155
[part='header-title'] {
150156
margin: 0;

src/components/calendar/themes/shared/bootstrap/calendar.bootstrap.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ $theme: $bootstrap;
1313
border-radius: var-get($theme, 'border-radius');
1414
}
1515

16-
:host(igc-calendar:not([orientation='vertical'])) {
16+
[part~='content']:not([part~='content-vertical']) {
1717
[part='days-view-container'] + [part='days-view-container'] {
1818
[part='navigation'],
1919
igc-days-view::part(days-row) {

src/components/calendar/themes/shared/fluent/calendar.fluent.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ $theme: $fluent;
1313
border-radius: var-get($theme, 'border-radius');
1414
}
1515

16-
:host(igc-calendar:not([orientation='vertical'])) {
16+
[part~='content']:not([part~='content-vertical']) {
1717
[part='days-view-container'] + [part='days-view-container'] {
1818
[part='navigation'],
1919
igc-days-view {

src/components/calendar/themes/shared/indigo/calendar.indigo.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ $theme: $indigo;
2929
}
3030
}
3131

32-
:host(igc-calendar:not([orientation='vertical'])) {
32+
[part~='content']:not([part~='content-vertical']) {
3333
[part='days-view-container'] + [part='days-view-container'] {
3434
[part='navigation'],
3535
igc-days-view {

src/components/calendar/themes/shared/material/calendar.material.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $theme: $material;
1818
}
1919
}
2020

21-
:host(igc-calendar:not([orientation='vertical'])) {
21+
[part~='content']:not([part~='content-vertical']) {
2222
[part='days-view-container'] + [part='days-view-container'] {
2323
[part='navigation'],
2424
igc-days-view {

0 commit comments

Comments
 (0)