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

refactor(ui5-li-notification, ui5-li-notification-group): migrate templates from HBS to JSX #10429

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 1 addition & 1 deletion packages/base/src/UI5Element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ type KebabToCamel<T extends string> = T extends `${infer H}-${infer J}${infer K}
: T;
type KebabToPascal<T extends string> = Capitalize<KebabToCamel<T>>;

type GlobalHTMLAttributeNames = "accesskey" | "autocapitalize" | "autofocus" | "autocomplete" | "contenteditable" | "contextmenu" | "class" | "dir" | "draggable" | "enterkeyhint" | "hidden" | "id" | "inputmode" | "lang" | "nonce" | "part" | "exportparts" | "pattern" | "slot" | "spellcheck" | "style" | "tabIndex" | "tabindex" | "title" | "translate" | "ref";
type GlobalHTMLAttributeNames = "accesskey" | "autocapitalize" | "autofocus" | "autocomplete" | "contenteditable" | "contextmenu" | "class" | "dir" | "draggable" | "enterkeyhint" | "hidden" | "id" | "inputmode" | "lang" | "nonce" | "part" | "exportparts" | "pattern" | "slot" | "spellcheck" | "style" | "tabIndex" | "tabindex" | "title" | "translate" | "ref" | "inert" | "role";
type ElementProps<I> = Partial<Omit<I, keyof HTMLElement>>;
type Convert<T> = { [Property in keyof T as `on${KebabToPascal<string & Property>}` ]: IsAny<T[Property], any, (e: CustomEvent<T[Property]>) => void> }

Expand Down
54 changes: 0 additions & 54 deletions packages/fiori/src/NotificationListGroupItem.hbs

This file was deleted.

14 changes: 7 additions & 7 deletions packages/fiori/src/NotificationListGroupItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import customElement from "@ui5/webcomponents-base/dist/decorators/customElement
import property from "@ui5/webcomponents-base/dist/decorators/property.js";
import slot from "@ui5/webcomponents-base/dist/decorators/slot.js";
import event from "@ui5/webcomponents-base/dist/decorators/event-strict.js";
import jsxRenderer from "@ui5/webcomponents-base/dist/renderer/JsxRenderer.js";
import Button from "@ui5/webcomponents/dist/Button.js";
import BusyIndicator from "@ui5/webcomponents/dist/BusyIndicator.js";
import Icon from "@ui5/webcomponents/dist/Icon.js";
Expand All @@ -14,8 +15,8 @@ import NotificationListItemBase from "./NotificationListItemBase.js";
import type NotificationListItem from "./NotificationListItem.js";

// Icons
import "@ui5/webcomponents-icons/dist/navigation-right-arrow.js";
import "@ui5/webcomponents-icons/dist/navigation-down-arrow.js";
import iconNavigationRightArrow from "@ui5/webcomponents-icons/dist/navigation-right-arrow.js";
import iconNavigationDownArrow from "@ui5/webcomponents-icons/dist/navigation-down-arrow.js";

// Texts
import {
Expand All @@ -26,11 +27,10 @@ import {
} from "./generated/i18n/i18n-defaults.js";

// Templates
import NotificationListGroupItemTemplate from "./generated/templates/NotificationListGroupItemTemplate.lit.js";
import NotificationListGroupItemTemplate from "./NotificationListGroupItemTemplate.js";

// Styles
import NotificationListGroupItemCss from "./generated/themes/NotificationListGroupItem.css.js";
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";

type NotificationListGroupItemToggleEventDetail = {
item: NotificationListGroupItem,
Expand Down Expand Up @@ -73,7 +73,7 @@ type NotificationListGroupItemToggleEventDetail = {
@customElement({
tag: "ui5-li-notification-group",
languageAware: true,
renderer: litRender,
renderer: jsxRenderer,
styles: [
NotificationListGroupItemCss,
],
Expand Down Expand Up @@ -139,7 +139,7 @@ class NotificationListGroupItem extends NotificationListItemBase {
super.onBeforeRendering();

this.items.forEach(item => {
item._ariaLevel = "2";
item._ariaLevel = 2;
});

if (this.loading) {
Expand Down Expand Up @@ -203,7 +203,7 @@ class NotificationListGroupItem extends NotificationListItemBase {
}

get groupCollapsedIcon() {
return this.collapsed ? "navigation-right-arrow" : "navigation-down-arrow";
return this.collapsed ? iconNavigationRightArrow : iconNavigationDownArrow;
}

toggleCollapsed() {
Expand Down
73 changes: 73 additions & 0 deletions packages/fiori/src/NotificationListGroupItemTemplate.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import BusyIndicator from "@ui5/webcomponents/dist/BusyIndicator.js";
import type NotificationListGroupItem from "./NotificationListGroupItem.js";
import Icon from "@ui5/webcomponents/dist/Icon.js";
import NotificationListGroupList from "./NotificationListGroupList.js";

export default function NotificationListItemTemplate(this: NotificationListGroupItem) {
return (
<li
class="ui5-nli-group-root ui5-nli-focusable"
onFocusIn={this._onfocusin}
onKeyDown={this._onkeydown}
tabindex={this.forcedTabIndex ? parseInt(this.forcedTabIndex) : undefined}
aria-labelledby={this.ariaLabelledBy}
aria-description={this.accInvisibleText}
aria-level={1}
>
{this.loading && (
<span
id={`${this._id}-loading`}
class="ui5-hidden-text"
>
{this.loadingText}
</span>
)}
<BusyIndicator
delay={this.loadingDelay}
active={this.loading}
inert={this.loading}
class="ui5-nli-loading"
>
<div class="ui5-nli-group-content-wrapper">
<div
class={{
"ui5-nli-group-header": true,
"ui5-nli-group-header-expanded": this._expanded,
}}
onClick={this._onHeaderToggleClick}
onKeyDown={this._onkeydown}
role="button"
aria-expanded={this._expanded}
aria-controls={`${this._id}-notificationsList`}
title={this.toggleIconAccessibleName}>
<Icon
name={this.groupCollapsedIcon}
class="ui5-nli-group-toggle-icon"
mode="Decorative"
/>
<div
id={`${this._id}-title-text`}
class="ui5-nli-group-title-text"
part="title-text"
role="heading"
aria-level={2}
>
{this.titleText}
</div>
<div class="ui5-nli-group-divider"></div>
</div>
<NotificationListGroupList
id={`${this._id}-notificationsList`}
class="ui5-nli-group-items"
role="list"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we use accessibleRole, inherited in NotificationListGroupList from List, not just role.
Also, accessibleRole is "list" by default.

aria-labelledby={`${this._id}-title-text`}
growing={this.growing}
onLoadMore={this._onLoadMore}
>
<slot></slot>
</NotificationListGroupList>
</div>
</BusyIndicator>
</li>
);
}
108 changes: 0 additions & 108 deletions packages/fiori/src/NotificationListItem.hbs

This file was deleted.

Loading
Loading