-
Notifications
You must be signed in to change notification settings - Fork 106
feat(alert): add <pf-alert> element
#2955
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 18 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
ee76f59
feat(alert): create pf-alert element
chubara62372 107f8be
feat(alert): add pf-alert component with demo, functionality, styling…
chubara62372 95cd45e
Update elements/pf-alert/README.md
chubara62372 bddf0ed
fix(alert): changes requested after first PR
chubara62372 3f0e7b5
Update .changeset/pf-alert.md
chubara62372 6b397c9
Update elements/pf-alert/demo/custom-icon.html
chubara62372 67bd66c
fix(alert): remove section/toast, update tests
chubara62372 a366f25
fix(alert): expandable
chubara62372 403517e
fix(alert): replace state with status
chubara62372 a387ad2
fix(alert) write access permission
chubara62372 5408d1f
fix(alert): rename state property to status
chubara62372 13f9454
fix(alert): fix alert element
chubara62372 ed07f83
fix(alert): fix alert new
chubara62372 1837fcd
fix(alert): fix alert new -no --verfy
chubara62372 2f096c6
fix(alert): fix alert new files -no --verfy
chubara62372 3f23e1d
fix(alert): fix pf alert new -no --verfy
chubara62372 56e3f85
fix(alert): fix pf-alert
chubara62372 621690e
fix(alert): fix readme.md
chubara62372 a4dae5b
Merge branch 'main' into pf-alert-new
bennypowers 91d5d04
docs: update changeset
bennypowers 53b3bd9
refactor: docs, dom, css
bennypowers de35dd4
Merge branch 'main' into pf-alert-new
bennypowers 5081b41
feat(alert): plain, inline
bennypowers d95dc90
feat(alert): add title-text and title-level attrs
bennypowers 54af59f
test: update test
bennypowers 20be7c0
fix: attribution
bennypowers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| --- | ||
| "@patternfly/elements": minor | ||
| --- | ||
|
|
||
| ### Minor Changes | ||
|
|
||
| - Added `pf-alert` component for displaying alert messages of different types: | ||
| - Types: info, warning, danger, success, neutral, custom | ||
| - Features: optional title, description, actions, dismiss button | ||
| - Enables consistent alert messaging across apps and demos | ||
|
|
||
| ```html | ||
| <pf-alert ouia-id="CustomAlert" variant="warning" onClose> | ||
| <h3 slot="title">Custom alert title</h3> | ||
| <span>This is the alert description.</span> | ||
| <div slot="actionLinks"> | ||
| <pf-button>Action 1</pf-button> | ||
| <pf-button>Action 2</pf-button> | ||
| </div> | ||
| </pf-alert> |
|
bennypowers marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| # pf-alert | ||
|
|
||
| The `pf-alert` web component displays PatternFly-styled alerts. It can be used inline in pages or as a toast notification (if a static helper is provided separately). Alerts support several visual **variants** (for example: `info`, `success`, `warning`, `danger`), an optional title slot, body content, and an **action links** slot for interactive controls. Alerts can also be **closable** and **expandable**. | ||
|
bennypowers marked this conversation as resolved.
|
||
|
|
||
| ## Installation | ||
|
|
||
| Import the element in your page or application as an ES module: | ||
|
|
||
| ```html | ||
| <script type="module"> | ||
| import '@patternfly/elements/pf-alert/pf-alert.js'; | ||
| </script> | ||
| ``` | ||
|
|
||
| ## Basic usage | ||
|
|
||
| Inline alert example: | ||
|
|
||
| ```html | ||
| <pf-alert variant="success"> | ||
| <span slot="title">Operation Success</span> | ||
|
|
||
| The operation completed successfully. | ||
| </pf-alert> | ||
|
|
||
| <pf-alert variant="info" onClose> | ||
| <span slot="title">System Update</span> | ||
|
|
||
| A new system update is available. | ||
|
|
||
| <div slot="actionLinks"> | ||
| <pf-button plain>Update Now</pf-button> | ||
| <pf-button plain>Later</pf-button> | ||
| </div> | ||
| </pf-alert> | ||
| ``` | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <div class="alerts-page"> | ||
|
|
||
|
chubara62372 marked this conversation as resolved.
Outdated
|
||
| <pf-alert ouia-id="CustomAlert"> | ||
|
chubara62372 marked this conversation as resolved.
Outdated
|
||
| <h3 slot="title">Custom alert title</h3> | ||
| </pf-alert> | ||
|
|
||
| <pf-alert variant="info" ouia-id="InfoAlert"> | ||
| <h3 slot="title">Info alert title</h3> | ||
| </pf-alert> | ||
|
|
||
| <pf-alert variant="success" ouia-id="SuccessAlert"> | ||
| <h3 slot="title">Success alert title</h3> | ||
| </pf-alert> | ||
|
|
||
| <pf-alert variant="warning" ouia-id="WarningAlert"> | ||
| <h3 slot="title">Warning alert title</h3> | ||
| </pf-alert> | ||
|
|
||
| <pf-alert variant="danger" ouia-id="DangerAlert"> | ||
| <h3 slot="title">Danger alert title</h3> | ||
| </pf-alert> | ||
| </div> | ||
|
|
||
| <script type="module"> | ||
| import '@patternfly/elements/pf-alert/pf-alert.js'; | ||
| </script> | ||
| <style> | ||
|
chubara62372 marked this conversation as resolved.
Outdated
|
||
| .alerts-page pf-alert::part(container) { | ||
| background-color: #fff; | ||
| box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25); | ||
| } | ||
| </style> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| <pf-button variant="secondary" id="addAlertButton">Add alert</pf-button> | ||
| <pf-button variant="secondary" id="removeAllAlertsButton">Remove all alerts</pf-button> | ||
|
|
||
| <div id="alert-container" style="margin-top: 20px;"> | ||
| </div> | ||
|
|
||
| <script type="module"> | ||
| import '@patternfly/elements/pf-alert/pf-alert.js'; | ||
| import '@patternfly/elements/pf-button/pf-button.js'; | ||
|
|
||
| const addAlertButton = document.getElementById('addAlertButton'); | ||
| const removeAllAlertsButton = document.getElementById('removeAllAlertsButton'); | ||
| const alertContainer = document.getElementById('alert-container'); | ||
|
|
||
| let alertCounter = 0; | ||
|
|
||
| function addTimeoutAlert() { | ||
| alertCounter++; | ||
| const timeoutMilliseconds = 8000; | ||
|
|
||
| const newAlert = document.createElement('pf-alert'); | ||
| newAlert.setAttribute('variant', 'neutral'); | ||
| newAlert.setAttribute('timeout', timeoutMilliseconds.toString()); | ||
| newAlert.innerHTML = ` | ||
| <h4 slot="title">Default timeout Alert</h4> | ||
| This alert will dismiss after ${timeoutMilliseconds/1000} seconds. | ||
| <a href="#" slot="actionLinks">View details</a> | ||
| <a href="#" slot="actionLinks" data-action="ignore">Ignore</a> | ||
| `; | ||
|
|
||
| alertContainer.prepend(newAlert); | ||
|
|
||
| newAlert.addEventListener('click', (event) => { | ||
| if (event.target.dataset.action === 'ignore') { | ||
| event.preventDefault(); | ||
| newAlert.remove(); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| if (addAlertButton) { | ||
| addAlertButton.addEventListener('click', addTimeoutAlert); | ||
| } | ||
|
|
||
| if (removeAllAlertsButton) { | ||
| removeAllAlertsButton.addEventListener('click', () => { | ||
| if (alertContainer) { | ||
| alertContainer.innerHTML = ''; | ||
| } | ||
| }); | ||
| } | ||
| </script> | ||
|
|
||
| <style> | ||
| pf-alert::part(container) { | ||
| background-color: #fff !important; | ||
| box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25); | ||
|
|
||
| } | ||
|
|
||
| #addAlertButton { | ||
| margin-inline-end: -0.25rem; | ||
| } | ||
| </style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| <div class="alerts-page"> | ||
|
|
||
|
bennypowers marked this conversation as resolved.
Outdated
|
||
| <pf-alert variant="success"> | ||
| <h3 slot="title">Success alert title</h3> | ||
| <p>Success alert description. This should tell the user more information about the alert.</p> | ||
| <a href="#" slot="actionLinks">View details</a> | ||
| <a href="#" slot="actionLinks">Ignore</a> | ||
| </pf-alert> | ||
|
|
||
| <pf-alert variant="success"> | ||
| <pf-icon icon="check-circle" slot="icon"></pf-icon> | ||
| <h3 slot="title">Success alert title</h3> | ||
| <p>Success alert description. This should tell the user more information about the alert. | ||
| <a href="#">This is a link.</a> | ||
| </p> | ||
| </pf-alert> | ||
|
|
||
| <pf-alert variant="success" onClose> | ||
| <h3 slot="title">Success alert title</h3> | ||
| <p>Short alert description.</p> | ||
| </pf-alert> | ||
|
|
||
| <pf-alert variant="success"> | ||
| <div slot="title">div success alert title</div> | ||
| </pf-alert> | ||
|
|
||
| <pf-alert variant="success"> | ||
| <h6 slot="title">h6 Success alert title</h6> | ||
| <p>Short alert description.</p> | ||
| </pf-alert> | ||
|
|
||
|
bennypowers marked this conversation as resolved.
Outdated
|
||
| </div> | ||
|
|
||
| <script type="module"> | ||
| import '@patternfly/elements/pf-alert/pf-alert.js'; | ||
| import '@patternfly/elements/pf-button/pf-button.js'; | ||
|
|
||
|
bennypowers marked this conversation as resolved.
Outdated
|
||
| </script> | ||
| <style> | ||
|
bennypowers marked this conversation as resolved.
Outdated
|
||
| .alerts-page pf-alert::part(container) { | ||
| background-color: #fff; | ||
| box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25); | ||
| } | ||
|
|
||
| pf-alert p a { | ||
| color: #06c; | ||
| text-decoration: none; | ||
| } | ||
|
|
||
| pf-alert p a:active, | ||
| pf-alert p a:hover { | ||
| text-decoration: underline; | ||
| color: #004080; | ||
|
|
||
| } | ||
|
bennypowers marked this conversation as resolved.
Outdated
|
||
| </style> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| <div class="alerts-page"> | ||
|
|
||
| <pf-alert variant="neutral"> | ||
| <pf-icon icon="users" slot="icon"></pf-icon> | ||
| <h3 slot="title">Default alert title</h3> | ||
| </pf-alert> | ||
|
|
||
| <pf-alert variant="info"> | ||
| <pf-icon icon="box" slot="icon"></pf-icon> | ||
| <h3 slot="title">Info alert title</h3> | ||
| </pf-alert> | ||
|
|
||
| <pf-alert variant="success"> | ||
| <pf-icon icon="database" slot="icon"></pf-icon> | ||
| <h3 slot="title">Success alert title</h3> | ||
| </pf-alert> | ||
|
|
||
| <pf-alert variant="warning"> | ||
| <pf-icon icon="server" slot="icon"></pf-icon> | ||
| <h3 slot="title">Warning alert title</h3> | ||
| </pf-alert> | ||
|
|
||
| <pf-alert variant="danger"> | ||
| <pf-icon icon="laptop" slot="icon"></pf-icon> | ||
| <h3 slot="title">Danger alert title</h3> | ||
| </pf-alert> | ||
| </div> | ||
|
|
||
| <script type="module"> | ||
| import '@patternfly/elements/pf-alert/pf-alert.js'; | ||
| </script> | ||
| <style> | ||
| .alerts-page pf-alert::part(container) { | ||
| background-color: #fff; | ||
| box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25); | ||
| } | ||
|
|
||
| </style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| <div class="alerts-page"> | ||
| <pf-alert variant="success" onClose **isExpandable**> | ||
|
bennypowers marked this conversation as resolved.
Outdated
|
||
| <h3 slot="title">Success alert title</h3> | ||
| <p slot="isExpandable">Success alert description. This should tell the user more information about the alert.</p> | ||
| </pf-alert> | ||
| </div> | ||
|
|
||
|
|
||
| <pf-alert variant="success"> | ||
| <h3 slot="title">Success alert title</h3> | ||
| <p slot="isExpandable">Success alert description. This should tell the user more information about the alert.</p> | ||
| <a href="#" slot="actionLinks">View details</a> | ||
| <a href="#" slot="actionLinks">Ignore</a> | ||
| </pf-alert> | ||
|
|
||
| <script type="module"> | ||
| import '@patternfly/elements/pf-alert/pf-alert.js'; | ||
| import '@patternfly/elements/pf-button/pf-button.js'; | ||
| </script> | ||
|
|
||
| <style> | ||
| .alerts-page pf-alert::part(container) { | ||
| background-color: #fff; | ||
| box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25); | ||
| } | ||
| </style> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| {% renderOverview %} | ||
| <pf-alert></pf-alert> | ||
| {% endrenderOverview %} | ||
|
|
||
| {% band header="Usage" %}{% endband %} | ||
|
|
||
| {% renderSlots %}{% endrenderSlots %} | ||
|
|
||
| {% renderAttributes %}{% endrenderAttributes %} | ||
|
|
||
| {% renderMethods %}{% endrenderMethods %} | ||
|
|
||
| {% renderEvents %}{% endrenderEvents %} | ||
|
|
||
| {% renderCssCustomProperties %}{% endrenderCssCustomProperties %} | ||
|
|
||
| {% renderCssParts %}{% endrenderCssParts %} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.