Skip to content

Commit c77beb3

Browse files
committed
Change X and arrow color on click in the Expandable page
1 parent 424d52d commit c77beb3

File tree

2 files changed

+41
-35
lines changed

2 files changed

+41
-35
lines changed

elements/pf-alert/pf-alert.css

Lines changed: 17 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,14 @@ header {
2222

2323
#container {
2424
align-items: flex-start;
25-
26-
/* רקע וצל */
2725
background-color: var(--_background-color);
28-
29-
/* גבולות */
3026
border-width: var(--pf-global--BorderWidth--md);
3127
border-style: solid;
3228
border-color: var(--_border-color, var(--pf-global--default-color--200));
3329
border-inline-start-color: transparent;
3430
border-block-end-color: transparent;
3531
border-inline-end-color: transparent;
36-
3732
margin-bottom: 1.5rem;
38-
39-
40-
41-
/* ריפוד ומרווחים */
4233
padding: var(--pf-global--spacer--md);
4334
display: grid;
4435
grid-template-columns: max-content 1fr max-content;
@@ -47,17 +38,12 @@ header {
4738
". description description"
4839
". actiongroup actiongroup";
4940
gap: var(--pf-global--spacer--xs);
50-
51-
/* טיפוגרפיה */
5241
font-family: var(--pf-global--FontFamily--text, RedHatText, 'Red Hat Text', Helvetica, Arial, sans-serif);
5342
font-size: var(--pf-global--FontSize--sm);
5443
line-height: var(--pf-global--lineHeight--md);
55-
5644
max-width: var(--pf-c-alert--MaxWidth, initial);
5745
box-shadow: var(--_box-shadow);
5846

59-
60-
/* כותרת */
6147
& header ::slotted(*) {
6248
font-family: var(--pf-global--FontFamily--text, RedHatText, 'Red Hat Text', Helvetica, Arial, sans-serif) !important;
6349
font-size: var(--pf-global--FontSize--sm) !important;
@@ -67,8 +53,6 @@ header {
6753

6854
}
6955

70-
71-
7256
#container.info {
7357
--_border-color: var(--pf-global--palette--purple-500,
7458
#2b9af3);
@@ -154,25 +138,23 @@ header {
154138
color: var(--_icon-color);
155139
}
156140

157-
#header-actions #close-button {
158-
--pf-icon--size: 16px;
159-
width: 16px;
160-
height: 16px;
161-
color: #6a6e73;
162-
}
163-
164-
#left-column pf-icon#arrow-icon {
165-
color: #6a6e73;
141+
#left-column pf-icon#arrow-icon,
142+
#header-actions pf-icon#close-button {
166143
--pf-icon--size: 16px;
167-
/* filter: drop-shadow(0 0 1px #6a6e73) drop-shadow(0 0 1px #6a6e73); */
168-
169-
}
170-
171-
/* בעת לחיצה */
172-
#left-column pf-icon#arrow-icon:active {
144+
/* פתח/סגור עבור PatternFly: עדיף להגדיר גם את משתנה הצבע של ה־icon */
145+
--pf-c-icon--Color: #6a6e73;
146+
color: #6a6e73; /* גיבוי למקרים ש־pf-icon משתמש ב־color ישיר */
147+
cursor: pointer;
148+
transition: color 0.2s ease, --pf-c-icon--Color 0.2s ease;
149+
}
150+
151+
/* מצבים: hover, active (בעת לחיצה), ומחלקת .active (שנוספה ב־JS) */
152+
#left-column pf-icon#arrow-icon:hover,
153+
#left-column pf-icon#arrow-icon:active,
154+
#left-column pf-icon#arrow-icon.active,
155+
#header-actions pf-icon#close-button:hover,
156+
#header-actions pf-icon#close-button:active,
157+
#header-actions pf-icon#close-button.active {
158+
--pf-c-icon--Color: #000000;
173159
color: #000000;
174-
/* משתנה לשחור בעת לחיצה */
175-
}
176-
#left-column pf-icon#arrow-icon:hover {
177-
color: #000000;
178160
}

elements/pf-alert/pf-alert.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,30 @@ const toasts = new Set<Required<ToastOptions>>();
6363
export class PfAlert extends LitElement {
6464
static readonly styles: CSSStyleSheet[] = [styles];
6565

66+
67+
firstUpdated(): void {
68+
const icons = this.renderRoot.querySelectorAll('#arrow-icon, #close-button');
69+
icons.forEach(icon => {
70+
icon.addEventListener('click', () => {
71+
// הסרה של active מכל האיקונים של כל הרכיבים
72+
document.querySelectorAll('pf-alert').forEach(alert => {
73+
const innerIcons = alert.renderRoot?.querySelectorAll('#arrow-icon, #close-button');
74+
innerIcons?.forEach(i => i.classList.remove('active'));
75+
});
76+
// הוספת active לאייקון הנוכחי
77+
icon.classList.add('active');
78+
});
79+
});
80+
81+
// קליק בכל מקום אחר מחזיר למצב רגיל
82+
document.addEventListener('click', (event) => {
83+
const path = event.composedPath();
84+
const clickedOnIcon = Array.from(icons).some(i => path.includes(i as EventTarget));
85+
if (!clickedOnIcon) {
86+
icons.forEach(i => i.classList.remove('active'));
87+
}
88+
});
89+
}
6690
/**
6791
* Toast a message with an rh-alert
6892
* @param options

0 commit comments

Comments
 (0)