Skip to content

Commit 5408d1f

Browse files
committed
fix(alert): rename state property to status
1 parent a387ad2 commit 5408d1f

File tree

2 files changed

+32
-30
lines changed

2 files changed

+32
-30
lines changed

elements/pf-alert/pf-alert.ts

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class AlertCloseEvent extends Event {
3838
super('close', { bubbles: true, cancelable: true });
3939
}
4040
}
41-
let toaster: HTMLElement;
41+
// let toaster: HTMLElement;
4242
const toasts = new Set<Required<ToastOptions>>();
4343

4444

@@ -62,9 +62,9 @@ export class PfAlert extends LitElement {
6262
#slots = new SlotController(this, 'header', null, 'actions');
6363

6464
get #icon() {
65-
const internalStatus = this.closest('.demo-with-arrows') &&
66-
this.status === 'neutral' && this.classList.contains('cogear-demo')
67-
? 'cogear'
65+
const internalStatus = this.closest('.demo-with-arrows')
66+
&& this.status === 'neutral' && this.classList.contains('cogear-demo') ?
67+
'cogear'
6868
: this.status;
6969
switch (internalStatus) {
7070
// @ts-expect-error: support for deprecated props
@@ -77,25 +77,25 @@ export class PfAlert extends LitElement {
7777
}
7878
}
7979

80-
#aliasState(state: string) {
81-
switch (state.toLowerCase()) {
82-
// the first three are deprecated pre-DPO status names
83-
case 'note': return 'info';
84-
case 'default': return 'neutral';
85-
case 'error': return 'danger';
86-
// the following are DPO-approved status names
87-
case 'danger':
88-
case 'warning':
89-
case 'custom':
90-
case 'neutral':
91-
case 'info':
92-
case 'success':
93-
case 'cogear':
94-
return state.toLowerCase() as this['status'];
95-
default:
96-
return 'neutral';
97-
}
98-
}
80+
// #aliasState(state: string) {
81+
// switch (state.toLowerCase()) {
82+
// // the first three are deprecated pre-DPO status names
83+
// case 'note': return 'info';
84+
// case 'default': return 'neutral';
85+
// case 'error': return 'danger';
86+
// // the following are DPO-approved status names
87+
// case 'danger':
88+
// case 'warning':
89+
// case 'custom':
90+
// case 'neutral':
91+
// case 'info':
92+
// case 'success':
93+
// case 'cogear':
94+
// return state.toLowerCase() as this['status'];
95+
// default:
96+
// return 'neutral';
97+
// }
98+
// }
9999

100100
connectedCallback(): void {
101101
super.connectedCallback();
@@ -114,8 +114,10 @@ export class PfAlert extends LitElement {
114114
const inDemo = this.closest('.demo-with-arrows') !== null;
115115
const hasDescription = this.querySelector('p') !== null;
116116
const showArrow = inDemo;
117-
const internalStatus = (this.closest('.demo-with-arrows') && this.classList.contains('cogear-demo'))
118-
? 'cogear'
117+
const internalStatus = (
118+
this.closest('.demo-with-arrows')
119+
&& this.classList.contains('cogear-demo')) ?
120+
'cogear'
119121
: this.status;
120122
const arrowDirection = hasDescription ? 'angle-down' : 'angle-right';
121123
const footer = html`<footer class="${classMap({ hasActions })}"

elements/pf-alert/test/pf-alert.e2e.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ test.describe(tagName, () => {
113113
});
114114

115115

116-
test('visual states and variants', async ({ page }) => {
117-
// Test each state renders
118-
for (const state of ['success', 'warning', 'danger', 'info']) {
119-
const alert = await page.locator(`pf-alert[state="${state}"]`).first();
116+
test('visual statuses and variants', async ({ page }) => {
117+
// Test each status renders
118+
for (const status of ['success', 'warning', 'danger', 'info']) {
119+
const alert = await page.locator(`pf-alert[status ="${status}"]`).first();
120120
if (await alert.count() > 0) {
121-
// Verify icon exists for state
121+
// Verify icon exists for status
122122
const icon = await alert.locator('#icon');
123123
expect(await icon.count()).toBe(1);
124124
}

0 commit comments

Comments
 (0)