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

feat(ui5-calendar-legend): introduce ui5-calendar-legend component #7706

Merged
merged 44 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
8159d55
feat(ui5-calendar-legend): introduce ui5-calendar-legend component
hinzzx Oct 13, 2023
43f0263
feat(ui5-calendar-legend): add imports for all themes
hinzzx Oct 16, 2023
8610049
feat(ui5-calendar-legend): fix failing test
hinzzx Oct 16, 2023
c092439
feat(ui5-calendar-legend): implement changes from discussion
hinzzx Oct 25, 2023
0a4207a
feat(ui5-calendar-legend): remove redunant story
hinzzx Oct 26, 2023
e80f16b
feat(ui5-calendar-legend): remove extra row
hinzzx Oct 26, 2023
a473e5d
feat(ui5-calendar-legend): address code review comments
hinzzx Oct 31, 2023
6845552
feat(ui5-calendar-legend): remove outdated docs
hinzzx Oct 31, 2023
d85d293
feat(ui5-calendar-legend): fix namings
hinzzx Oct 31, 2023
3a6e9d7
feat(ui5-calendar-legend): address code review comments
hinzzx Oct 31, 2023
cb5e76f
feat(ui5-calendar-legend): remove unused method
hinzzx Nov 1, 2023
931fa82
feat(ui5-calendar-legend): add custom types, and align itemNavigation…
hinzzx Nov 9, 2023
f4a2457
feat(ui5-calendar-legend): remove types for new CEM
hinzzx Nov 9, 2023
524b77a
Merge branch 'main' into feat-calendar-legend
hinzzx Nov 10, 2023
6c30084
feat(ui5-calendar-legend): change property name from placeholder to text
hinzzx Nov 10, 2023
a9a52dd
feat(ui5-calendar-legend): address code review
hinzzx Nov 14, 2023
6474ac2
feat(ui5-calendar-legend): add special days styling at bottom of day …
hinzzx Nov 27, 2023
b5b88cb
feat(ui5-calendar-legend): fix wrong parameter value
hinzzx Nov 28, 2023
6d1e7f7
feat(ui5-calendar-legend): address vd review comments
hinzzx Dec 3, 2023
61a2e95
Merge branch 'main' into feat-calendar-legend
hinzzx Dec 5, 2023
1c8a8af
Merge branch 'main' into feat-calendar-legend
hinzzx Dec 19, 2023
6602372
feat(ui5-calendar-legend): connect calendar legend with calendar
hinzzx Dec 19, 2023
a757bbf
feat(ui5-calendar-legend): add tests, stories and clear some code
hinzzx Dec 21, 2023
a77a6a6
feat(ui5-calendar-legend): fix failing test and remove redunant code
hinzzx Dec 21, 2023
9c31803
feat(ui5-calendar-legend): fix special dates validation method
hinzzx Dec 22, 2023
47db636
feat(ui5-calendar-legend): address code review comments
hinzzx Jan 9, 2024
49f3216
feat(ui5-calendar-legend): resolve merge conficts
hinzzx Jan 12, 2024
c07aaa7
feat(ui5-calendar-legend): adapt jsdoc for new cem
hinzzx Jan 17, 2024
99343c4
Merge branch 'main' into feat-calendar-legend
hinzzx Jan 23, 2024
0822d41
feat(ui5-calendar-legend): add event generic type desc
hinzzx Jan 23, 2024
1a8e079
feat(ui5-calendar-legend): address code review comments
hinzzx Jan 31, 2024
57c3e38
feat(ui5-calendar-legend): fix JSDocs
hinzzx Jan 31, 2024
80a15de
feat(ui5-calendar-legend): fix JSDocs
hinzzx Jan 31, 2024
e9dc480
fix(ui5-calendar-legend): fix failing test
hinzzx Jan 31, 2024
8c42787
feat(ui5-calendar-legend): address code review comments
hinzzx Feb 4, 2024
334bc53
Merge branch 'main' into feat-calendar-legend
hinzzx Feb 5, 2024
65831fd
feat(ui5-calendar-legend): change tabIndex property
hinzzx Feb 5, 2024
19037ae
feat(ui5-calendar-legend): fix sb stories
hinzzx Feb 5, 2024
de80841
feat(ui5-calendar-legend): remove unused code
hinzzx Feb 5, 2024
633e8de
feat(ui5-calendar-legend): address code review comments
hinzzx Feb 8, 2024
09f873d
fix(ui5-calendar-legend): better naming
hinzzx Feb 8, 2024
256fa50
feat(ui5-calendar-legend): address code review comments
hinzzx Feb 12, 2024
890375b
feat(ui5-calendar-legend): address code review comments
hinzzx Feb 12, 2024
a6d5a73
feat(ui5-calendar-legend): fix jsdoc
hinzzx Feb 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/main/bundle.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import Badge from "./dist/Badge.js";
import Breadcrumbs from "./dist/Breadcrumbs.js";
import BusyIndicator from "./dist/BusyIndicator.js";
import Button from "./dist/Button.js";
import CalendarLegend from "./dist/CalendarLegend.js";
import CalendarLegendStandardItem from "./dist/CalendarLegendStandardItem.js";
import Card from "./dist/Card.js";
import CardHeader from "./dist/CardHeader.js";
import Carousel from "./dist/Carousel.js";
Expand Down
3 changes: 3 additions & 0 deletions packages/main/src/CalendarLegend.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<div class="ui5-calendar-legend-root">
<slot></slot>
</div>
131 changes: 131 additions & 0 deletions packages/main/src/CalendarLegend.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
import slot from "@ui5/webcomponents-base/dist/decorators/slot.js";
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
import CalendarLegendStandardItemsType from "./types/StandardCalendarLegendItemsType.js";
import CalendarLegendTemplate from "./generated/templates/CalendarLegendTemplate.lit.js";

// Styles
import CalendarLegendCss from "./generated/themes/CalendarLegend.css.js";
import CalendarLegendStandardItem from "./CalendarLegendStandardItem.js";

/**
* @class CalendarLegend
hinzzx marked this conversation as resolved.
Show resolved Hide resolved
*
* <h3 class="comment-api-title">Overview</h3>
*
* The <code>ui5-calendar-legend</code> component is used to display a legend of special calendar dates
* with their corresponding textual descriptions and types.
*
* <h3>ES6 Module Import</h3>
*
* <code>import "@ui5/webcomponents/dist/CalendarLegend.js";</code>
*
* @constructor
* @author SAP SE
* @alias sap.ui.webc.main.CalendarLegend
* @extends sap.ui.webc.base.UI5Element
* @tagname ui5-calendar-legend
* @public
*/
@customElement({
tag: "ui5-calendar-legend",
renderer: litRender,
styles: CalendarLegendCss,
template: CalendarLegendTemplate,
dependencies: [CalendarLegendStandardItem],
})
class CalendarLegend extends UI5Element {
/**
* Defines the items of the component.
*
* @type {CalendarLegendStandardItem[]}
* @slot
* @public
*/
@slot({ type: HTMLElement, invalidateOnChildChange: true, "default": true })
items!: Array<CalendarLegendStandardItem>

constructor() {
super();
}

onBeforeRendering() {
this._ensureMaxItemsCount();
this._addDefaultItemsIfNeeded();
this._removeDuplicateTypes();

this.items.forEach(item => {
if (!(item.type in CalendarLegendStandardItemsType)) {
item.remove();
}
});
}

/**
* Ensures that there are no more than 4 items.
* If there are more, removes the items after the 4th one.
* <br><br>
*
* Note: Change/Remove this method when Custom Calendar Legend items are introduced.
*
* @private
*/
_ensureMaxItemsCount() {
while (this.items.length > 4) {
hinzzx marked this conversation as resolved.
Show resolved Hide resolved
this.items[this.items.length - 1].remove();
this.items.pop();
}
}

/**
* Adds default items if none are present.
* @private
*/
_addDefaultItemsIfNeeded() {
if (this.items.length === 0) {
const itemsToAdd = this._generateDefaultItems();
itemsToAdd.forEach(item => {
this.appendChild(item);
});
}
}

/**
* Generates default items.
* @returns {HTMLElement[]} Array of items to add.
* @private
*/
_generateDefaultItems() {
const types = Object.values(CalendarLegendStandardItemsType);
const itemsToAdd: Array<HTMLElement> = [];

types.forEach(type => {
const item = document.createElement("ui5-cal-legend-standard-item");
item.setAttribute("type", type);
item.textContent = type;
hinzzx marked this conversation as resolved.
Show resolved Hide resolved
itemsToAdd.push(item);
});

return itemsToAdd;
}

/**
* Removes items with duplicate types, keeping only the first occurrence.
* @private
*/
_removeDuplicateTypes() {
const types = new Set();
this.items.forEach(item => {
if (types.has(item.type)) {
item.remove();
} else {
types.add(item.type);
}
});
}
}

CalendarLegend.define();

export default CalendarLegend;
4 changes: 4 additions & 0 deletions packages/main/src/CalendarLegendStandardItem.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div class="ui5-cal-legend-standard-item-root" type="{{type}}">
<div class="ui5-cal-legend-standard-item-box"></div>
<div class="ui5-cal-legend-standard-item-text">{{effectiveText}}</div>
</div>
72 changes: 72 additions & 0 deletions packages/main/src/CalendarLegendStandardItem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
import property from "@ui5/webcomponents-base/dist/decorators/property.js";
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
import CalendarLegendStandardItemsType from "./types/StandardCalendarLegendItemsType.js";

import CalendarLegendStandardItemTemplate from "./generated/templates/CalendarLegendStandardItemTemplate.lit.js";

// Styles
import CalendarLegendStandardItemCss from "./generated/themes/CalendarLegendStandardItem.css.js";

/**
* @class
*
* <h3 class="comment-api-title">Overview</h3>
* The <code>ui5-cal-legend-standard-item</code> represents a standard legend item used within the <code>ui5-calendar-legend</code> component.
*
* <h3>Custom Text Override</h3>
hinzzx marked this conversation as resolved.
Show resolved Hide resolved
* If you provide `textContent` or use the item as <code><ui5-cal-legend-standard-item type="Today">Text here</ui5-cal-legend-standard-item></code>,
* it will override the default text provided by the `type`. This allows for customization of the legend item text.
*
* <h3>Usage</h3>
*
* The <code>ui5-cal-legend-standard-item</code> is intended to be used within the <code>ui5-calendar-legend</code> component.
*
* <h3>ES6 Module Import</h3>
*
* <code>import "@ui5/webcomponents/dist/CalendarLegendStandardItem.js";</code>
*
* @constructor
* @author SAP SE
* @alias sap.ui.webc.main.CalendarLegendStandardItem
* @extends sap.ui.webc.base.UI5Element
* @tagname ui5-cal-legend-standard-item
* @public
*/
@customElement({
tag: "ui5-cal-legend-standard-item",
hinzzx marked this conversation as resolved.
Show resolved Hide resolved
renderer: litRender,
styles: CalendarLegendStandardItemCss,
template: CalendarLegendStandardItemTemplate,
dependencies: [],
})

class CalendarLegendStandardItem extends UI5Element {
/**
* Defines the type of the Calendar Legend Standard Item.
*
* @type {string}
* @name sap.ui.webc.main.CalendarLegendStandardItem.prototype.type
* @defaultvalue ""
* @public
*/
@property()
type!: `${CalendarLegendStandardItemsType}`;
hinzzx marked this conversation as resolved.
Show resolved Hide resolved

get effectiveText() {
const typeExists = `${this.type}` in CalendarLegendStandardItemsType;

if ((typeExists && this.textContent === "")) {
return this.type;
}

if (this.type && typeExists && this.textContent) {
return this.textContent;
}
}
}

CalendarLegendStandardItem.define();

export default CalendarLegendStandardItem;
12 changes: 12 additions & 0 deletions packages/main/src/themes/CalendarLegend.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.ui5-calendar-legend-root {
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 0.5rem;
padding: var(--_ui5-calendar-legend-root-padding);
margin: 0.5rem 0;
max-width: var(--_ui5-calendar-legend-root-width);
background-color: var(--sapList_Background);
}
54 changes: 54 additions & 0 deletions packages/main/src/themes/CalendarLegendStandardItem.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
.ui5-cal-legend-standard-item-root {
display: flex;
flex-direction: row;
flex-wrap: wrap;
width: 7.5rem;
vertical-align: middle;
white-space: pre-line;
text-overflow: ellipsis;
overflow: hidden;
cursor: default;
}

.ui5-cal-legend-standard-item-box {
display: inline-block;
vertical-align: top;
box-sizing: border-box;
height: 1rem;
width: 1rem;
margin: var(--_ui5_cal-legend-standard-item-box-margin);
}

.ui5-cal-legend-standard-item-text {
font-size: 0.875rem;
line-height: 1.25rem;
color: var(--sapContent_LabelColor);
font-weight: normal;
font-family: var(--sapFontFamily);
font-size: var(--sapFontSmallSize);
vertical-align: middle;
white-space: pre-line;
text-overflow: ellipsis;
overflow: hidden;
cursor: default;
}

:host([type="Today"]) .ui5-cal-legend-standard-item-box {
border-color: var(--sapLegend_CurrentDateTime);
border: 0.125rem solid var(--sapLegend_CurrentDateTime);
}

:host([type="Selected"]) .ui5-cal-legend-standard-item-box {
background: var(--sapContent_Selected_Background);
border: 0.0625rem solid var(--sapContent_FocusColor);
}

:host([type="Working"]) .ui5-cal-legend-standard-item-box {
background: var(--sapLegend_WorkingBackground);
border: 0.0625rem solid #758ca4;
hinzzx marked this conversation as resolved.
Show resolved Hide resolved
}

:host([type="NonWorking"]) .ui5-cal-legend-standard-item-box {
background: var(--sapLegend_NonWorkingBackground);
border: 0.0625rem solid #758ca4;
}
4 changes: 4 additions & 0 deletions packages/main/src/themes/base/CalendarLegend-parameters.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
:root {
--_ui5-calendar-legend-root-padding: 0.75rem;
--_ui5-calendar-legend-root-width: 18.5rem;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
:root {
--_ui5_cal-legend-standard-item-box-margin: 0.25rem 0.5rem 0.25rem 0.25rem;
}
7 changes: 7 additions & 0 deletions packages/main/src/themes/base/sizes-parameters.css
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@
--_ui5_calendar_header_arrow_button_width: 2rem;
--_ui5_calendar_header_padding: 0;

/* Calendar Legend */
--_ui5-calendar-legend-root-padding: 0.5rem;
--_ui5-calendar-legend-root-width: 16.75rem;

/* Calendar Legend Standard Item */
--_ui5_cal-legend-standard-item-box-margin: 0.125rem 0.5rem 0.125rem 0.125rem;

/* CheckBox */
--_ui5_checkbox_root_side_padding: var(--_ui5_checkbox_wrapped_focus_padding);
--_ui5_checkbox_wrapped_content_margin_top: var(--_ui5_checkbox_compact_wrapped_label_margin_top);
Expand Down
2 changes: 2 additions & 0 deletions packages/main/src/themes/sap_belize/parameters-bundle.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
@import "./BrowserScrollbar-parameters.css";
@import "../base/BusyIndicator-parameters.css";
@import "../base/Button-parameters.css";
@import "../base/CalendarLegend-parameters.css";
@import "../base/CalendarLegendStandardItem-parameters.css";
@import "../base/DatePicker-parameters.css";
@import "./DayPicker-parameters.css";
@import "./Dialog-parameters.css";
Expand Down
2 changes: 2 additions & 0 deletions packages/main/src/themes/sap_belize_hcb/parameters-bundle.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
@import "../base/BusyIndicator-parameters.css";
@import "./Button-parameters.css";
@import "./CalendarHeader-parameters.css";
@import "../base/CalendarLegend-parameters.css";
@import "../base/CalendarLegendStandardItem-parameters.css";
@import "./Carousel-parameters.css";
@import "./Card-parameters.css";
@import "./CheckBox-parameters.css";
Expand Down
2 changes: 2 additions & 0 deletions packages/main/src/themes/sap_belize_hcw/parameters-bundle.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
@import "./BrowserScrollbar-parameters.css";
@import "../base/BusyIndicator-parameters.css";
@import "./Button-parameters.css";
@import "../base/CalendarLegend-parameters.css";
@import "../base/CalendarLegendStandardItem-parameters.css";
@import "./CalendarHeader-parameters.css";
@import "./Carousel-parameters.css";
@import "./Card-parameters.css";
Expand Down
2 changes: 2 additions & 0 deletions packages/main/src/themes/sap_fiori_3/parameters-bundle.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
@import "../base/BusyIndicator-parameters.css";
@import "./Button-parameters.css";
@import "../base/Card-parameters.css";
@import "../base/CalendarLegend-parameters.css";
@import "../base/CalendarLegendStandardItem-parameters.css";
@import "../base/Carousel-parameters.css";
@import "./CheckBox-parameters.css";
@import "../base/ColorPalette-parameters.css";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
@import "../base/BrowserScrollbar-parameters.css";
@import "../base/BusyIndicator-parameters.css";
@import "./Button-parameters.css";
@import "../base/CalendarLegend-parameters.css";
@import "../base/CalendarLegendStandardItem-parameters.css";
@import "../base/Card-parameters.css";
@import "../base/Carousel-parameters.css";
@import "./CheckBox-parameters.css";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
@import "../base/BrowserScrollbar-parameters.css";
@import "../base/BusyIndicator-parameters.css";
@import "./Button-parameters.css";
@import "../base/CalendarLegend-parameters.css";
@import "../base/CalendarLegendStandardItem-parameters.css";
@import "./CalendarHeader-parameters.css";
@import "./Carousel-parameters.css";
@import "./Card-parameters.css";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
@import "../base/BrowserScrollbar-parameters.css";
@import "../base/BusyIndicator-parameters.css";
@import "./Button-parameters.css";
@import "../base/CalendarLegend-parameters.css";
@import "../base/CalendarLegendStandardItem-parameters.css";
@import "./CalendarHeader-parameters.css";
@import "./Carousel-parameters.css";
@import "./Card-parameters.css";
Expand Down
2 changes: 2 additions & 0 deletions packages/main/src/themes/sap_horizon/parameters-bundle.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
@import "../base/BrowserScrollbar-parameters.css";
@import "./BusyIndicator-parameters.css";
@import "./Button-parameters.css";
@import "../base/CalendarLegend-parameters.css";
@import "../base/CalendarLegendStandardItem-parameters.css";
@import "../base/Card-parameters.css";
@import "./Card-parameters.css";
@import "./Carousel-parameters.css";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
@import "../base/BrowserScrollbar-parameters.css";
@import "./BusyIndicator-parameters.css";
@import "./Button-parameters.css";
@import "../base/CalendarLegend-parameters.css";
@import "../base/CalendarLegendStandardItem-parameters.css";
@import "../base/Card-parameters.css";
@import "./Card-parameters.css";
@import "./Carousel-parameters.css";
Expand Down
Loading