Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ui5-calendar): switch to two column layout on Islamic or Persian secondary calendar type #8453

Merged
merged 10 commits into from
May 10, 2024
3 changes: 2 additions & 1 deletion packages/main/src/MonthPicker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import MonthPickerTemplate from "./generated/templates/MonthPickerTemplate.lit.j
import monthPickerStyles from "./generated/themes/MonthPicker.css.js";

const PAGE_SIZE = 12; // total months on a single page
const ROW_SIZE = 3; // months per row (4 rows of 3 months each)
let ROW_SIZE = 3; // months per row (4 rows of 3 months each)
hinzzx marked this conversation as resolved.
Show resolved Hide resolved

type Month = {
timestamp: string,
Expand Down Expand Up @@ -117,6 +117,7 @@ class MonthPicker extends CalendarPart implements ICalendarPicker {

onBeforeRendering() {
this._buildMonths();
ROW_SIZE = this.secondaryCalendarType === "Islamic" || this.secondaryCalendarType === "Persian" ? 2 : 3;
}

onAfterRendering() {
Expand Down
21 changes: 21 additions & 0 deletions packages/main/src/themes/MonthPicker.css
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,24 @@
align-items: center;
width: 100%;
}

/* Switching to a two column layout */
:host([secondary-calendar-type="Persian"]) .ui5-mp-root,
:host([secondary-calendar-type="Islamic"]) .ui5-mp-root {
display: grid;
padding: 1rem 0 1rem;
grid-template-columns: repeat(2, 1fr);
gap: var(--_ui5_monthpicker_item_margin);
}

:host([secondary-calendar-type="Persian"]) .ui5-mp-item,
:host([secondary-calendar-type="Islamic"]) .ui5-mp-item {
margin: 0;
width: auto;
}

:host([secondary-calendar-type="Persian"]) .ui5-mp-quarter,
:host([secondary-calendar-type="Islamic"]) .ui5-mp-quarter {
width: 100%;
display: contents;
}