Skip to content

Commit dea7eaf

Browse files
committed
Work in progress on pf-alert
1 parent 767cecf commit dea7eaf

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

elements/pf-alert/pf-alert.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
// ייבוא הרכיבים של PatternFly
3-
import { type CSSResult, LitElement, type TemplateResult, html, isServer, render } from 'lit';
3+
import { LitElement, type TemplateResult, html, isServer, render } from 'lit';
44
import { customElement } from 'lit/decorators/custom-element.js';
55
import { property } from 'lit/decorators/property.js';
66
import { repeat } from 'lit/directives/repeat.js';
@@ -63,29 +63,30 @@ export class PfAlert extends LitElement {
6363
static readonly styles: CSSStyleSheet[] = [styles];
6464

6565

66-
firstUpdated(): void {
67-
const icons = this.renderRoot.querySelectorAll('#arrow-icon, #close-button');
68-
icons.forEach(icon => {
69-
icon.addEventListener('click', () => {
66+
firstUpdated(): void {
67+
const icons = this.renderRoot.querySelectorAll('#arrow-icon, #close-button');
68+
icons.forEach(icon => {
69+
icon.addEventListener('click', () => {
7070
// הסרה של active מכל האיקונים של כל הרכיבים
71-
document.querySelectorAll('pf-alert').forEach(alert => {
72-
const innerIcons = alert.renderRoot?.querySelectorAll('#arrow-icon, #close-button');
73-
innerIcons?.forEach(i => i.classList.remove('active'));
71+
document.querySelectorAll('pf-alert').forEach(alert => {
72+
const innerIcons = alert.renderRoot?.querySelectorAll('#arrow-icon, #close-button');
73+
innerIcons?.forEach(i => i.classList.remove('active'));
74+
});
75+
// הוספת active לאייקון הנוכחי
76+
icon.classList.add('active');
7477
});
75-
// הוספת active לאייקון הנוכחי
76-
icon.classList.add('active');
7778
});
78-
});
7979

80-
// קליק בכל מקום אחר מחזיר למצב רגיל
81-
document.addEventListener('click', (event) => {
82-
const path = event.composedPath();
83-
const clickedOnIcon = Array.from(icons).some(i => path.includes(i as EventTarget));
84-
if (!clickedOnIcon) {
85-
icons.forEach(i => i.classList.remove('active'));
86-
}
87-
});
88-
}
80+
// קליק בכל מקום אחר מחזיר למצב רגיל
81+
document.addEventListener('click', event => {
82+
const path = event.composedPath();
83+
const clickedOnIcon = Array.from(icons).some(i => path.includes(i as EventTarget));
84+
if (!clickedOnIcon) {
85+
icons.forEach(i => i.classList.remove('active'));
86+
}
87+
});
88+
}
89+
8990
/**
9091
* Toast a message with an rh-alert
9192
* @param options
@@ -185,7 +186,6 @@ firstUpdated(): void {
185186
}
186187

187188
render(): TemplateResult<1> {
188-
189189
const _isServer = isServer && !this.hasUpdated;
190190
const hasActions = _isServer || this.#slots.hasSlotted('actions');
191191
const hasBody =
@@ -197,7 +197,7 @@ firstUpdated(): void {
197197
const showArrow = inDemo;
198198
const arrowDirection = hasDescription ? 'angle-down' : 'angle-right';
199199

200-
200+
201201
// footer slot עם האקשנים
202202
const footer = html`<footer class="${classMap({ hasActions })}"
203203
@click="${this.#onActionsClick}">

0 commit comments

Comments
 (0)