Skip to content

Commit bddf0ed

Browse files
committed
fix(alert): changes requested after first PR
1 parent 95cd45e commit bddf0ed

File tree

4 files changed

+13
-31
lines changed

4 files changed

+13
-31
lines changed

.changeset/pf-alert.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,14 @@
22
"@patternfly/elements/pf-alert": minor
33
---
44

5-
Add `pf-alert` component to display alert messages of various types (info, warning, danger, success, cogear, neutral, custom) with optional heading, description, actions, and dismiss button. This component allows developers to consistently show alerts in their apps or demos.
5+
### Minor Changes
6+
7+
- Added `pf-alert` component for displaying alert messages of different types:
8+
- Types: info, warning, danger, success, cogear, neutral, custom
9+
- Features: optional heading, description, actions, dismiss button
10+
- Enables consistent alert messaging across apps and demos
11+
12+
```html
13+
<pf-alert type="warning" heading="Attention!">
14+
This is a warning alert with optional description and actions.
15+
</pf-alert>

elements/pf-alert/demo/inline-types.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ <h3 slot="header">Success inline alert title</h3>
1717
<h3 slot="header">Warning inline alert title</h3>
1818
</pf-alert>
1919

20+
2021
<pf-alert state="danger">
2122
<h3 slot="header">Danger inline alert title</h3>
2223
</pf-alert>

elements/pf-alert/demo/variations.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ <h3 slot="header">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curab
3737
</pf-alert>
3838

3939

40-
<pf-alert state="success">
40+
<pf-alert variant="success">
4141
<h3 slot="header">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur pellentesque neque cursus
4242
enim
4343
fringilla tincidunt. Proin lobortis aliquam dictum. Nam vel ullamcorper nulla, nec blandit dolor. Vivamus

elements/pf-alert/pf-alert.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -201,40 +201,11 @@ export class PfAlert extends LitElement {
201201
</section>
202202
`;
203203
}
204-
205-
firstUpdated(): void {
206-
const icons = this.renderRoot.querySelectorAll('#arrow-icon, #close-button');
207-
icons.forEach(icon => {
208-
icon.addEventListener('click', () => {
209-
// Remove active from all icons of all components
210-
document.querySelectorAll('pf-alert').forEach(alert => {
211-
const innerIcons = alert.renderRoot?.querySelectorAll('#arrow-icon, #close-button');
212-
innerIcons?.forEach(i => i.classList.remove('active'));
213-
});
214-
// Add active to the current icon
215-
icon.classList.add('active');
216-
});
217-
});
218-
219-
// Click anywhere else returns to normal mode
220-
document.addEventListener('click', event => {
221-
const path = event.composedPath();
222-
const clickedOnIcon = Array.from(icons).some(i => path.includes(i as EventTarget));
223-
if (!clickedOnIcon) {
224-
icons.forEach(i => i.classList.remove('active'));
225-
}
226-
});
227-
}
228204
}
229205

230-
231206
function initToaster() {
232207
const node = document.createElement('section');
233208
node.classList.add('pf-alert-toast-group');
234-
document.adoptedStyleSheets = [
235-
...document.adoptedStyleSheets ?? [],
236-
];
237-
238209
document.body.append(node);
239210
return node;
240211
}

0 commit comments

Comments
 (0)