Skip to content

Commit ee76f59

Browse files
committed
feat(alert): create pf-alert element
1 parent 916823a commit ee76f59

File tree

8 files changed

+115
-0
lines changed

8 files changed

+115
-0
lines changed

elements/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"./pf-accordion/pf-accordion-header.js": "./pf-accordion/pf-accordion-header.js",
1616
"./pf-accordion/pf-accordion-panel.js": "./pf-accordion/pf-accordion-panel.js",
1717
"./pf-accordion/pf-accordion.js": "./pf-accordion/pf-accordion.js",
18+
"./pf-alert/pf-alert.js": "./pf-alert/pf-alert.js",
1819
"./pf-avatar/pf-avatar.js": "./pf-avatar/pf-avatar.js",
1920
"./pf-back-to-top/pf-back-to-top.js": "./pf-back-to-top/pf-back-to-top.js",
2021
"./pf-background-image/pf-background-image.js": "./pf-background-image/pf-background-image.js",

elements/pf-alert/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Alert
2+
Add a description of the component here.
3+
4+
## Usage
5+
Describe how best to use this web component along with best practices.
6+
7+
```html
8+
<pf-alert>
9+
10+
</pf-alert>
11+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<pf-alert></pf-alert>
2+
3+
<script type="module">
4+
import '@patternfly/elements/pf-alert/pf-alert.js';
5+
</script>
6+
7+
<style>
8+
pf-alert {
9+
/* insert demo styles */
10+
}
11+
</style>
12+

elements/pf-alert/docs/pf-alert.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{% renderOverview %}
2+
<pf-alert></pf-alert>
3+
{% endrenderOverview %}
4+
5+
{% band header="Usage" %}{% endband %}
6+
7+
{% renderSlots %}{% endrenderSlots %}
8+
9+
{% renderAttributes %}{% endrenderAttributes %}
10+
11+
{% renderMethods %}{% endrenderMethods %}
12+
13+
{% renderEvents %}{% endrenderEvents %}
14+
15+
{% renderCssCustomProperties %}{% endrenderCssCustomProperties %}
16+
17+
{% renderCssParts %}{% endrenderCssParts %}

elements/pf-alert/pf-alert.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
:host {
2+
display: block;
3+
}

elements/pf-alert/pf-alert.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { LitElement, html, type TemplateResult } from 'lit';
2+
import { customElement } from 'lit/decorators/custom-element.js';
3+
4+
import styles from './pf-alert.css';
5+
6+
/**
7+
* Alert
8+
* @slot - Place element content here
9+
*/
10+
@customElement('pf-alert')
11+
export class PfAlert extends LitElement {
12+
static readonly styles: CSSStyleSheet[] = [styles];
13+
14+
render(): TemplateResult<1> {
15+
return html`
16+
<slot></slot>
17+
`;
18+
}
19+
}
20+
21+
declare global {
22+
interface HTMLElementTagNameMap {
23+
'pf-alert': PfAlert;
24+
}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { test } from '@playwright/test';
2+
import { PfeDemoPage } from '@patternfly/pfe-tools/test/playwright/PfeDemoPage.js';
3+
import { SSRPage } from '@patternfly/pfe-tools/test/playwright/SSRPage.js';
4+
5+
const tagName = 'pf-alert';
6+
7+
test.describe(tagName, () => {
8+
test('snapshot', async ({ page }) => {
9+
const componentPage = new PfeDemoPage(page, tagName);
10+
await componentPage.navigate();
11+
await componentPage.snapshot();
12+
});
13+
14+
test('ssr', async ({ browser }) => {
15+
const fixture = new SSRPage({
16+
tagName,
17+
browser,
18+
demoDir: new URL('../demo/', import.meta.url),
19+
importSpecifiers: [
20+
`@patternfly/elements/${tagName}/${tagName}.js`,
21+
],
22+
});
23+
await fixture.snapshots();
24+
});
25+
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { expect, html } from '@open-wc/testing';
2+
import { createFixture } from '@patternfly/pfe-tools/test/create-fixture.js';
3+
import { PfAlert } from '@patternfly/elements/pf-alert/pf-alert.js';
4+
5+
describe('<pf-alert>', function() {
6+
describe('simply instantiating', function() {
7+
let element: PfAlert;
8+
it('imperatively instantiates', function() {
9+
expect(document.createElement('pf-alert')).to.be.an.instanceof(PfAlert);
10+
});
11+
12+
it('should upgrade', async function() {
13+
element = await createFixture<PfAlert>(html`<pf-alert></pf-alert>`);
14+
const klass = customElements.get('pf-alert');
15+
expect(element)
16+
.to.be.an.instanceOf(klass)
17+
.and
18+
.to.be.an.instanceOf(PfAlert);
19+
});
20+
});
21+
});

0 commit comments

Comments
 (0)