-
Notifications
You must be signed in to change notification settings - Fork 105
feat(helper-text): add pf-helper-text element #2947
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
Draft
dali327519294
wants to merge
6
commits into
patternfly:main
Choose a base branch
from
dali327519294:feat/pf-helper-text
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5de6b70
feat: create pf-helper-text element
dali327519294 9a6f275
style(helper-text): improved demo page for more accurate alignment wi…
dali327519294 325d17b
refactor(docs): improve pf-helper-text code, translate comments, alig…
dali327519294 d868e40
docs(helper-text): add detailed documentation with examples and icon …
dali327519294 db4dee5
feat(helper-text): implement pf-helper-text component and refactor demos
dali327519294 1445eef
Merge remote-tracking branch 'upstream/main' into feat/pf-helper-text
dali327519294 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
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,151 @@ | ||
| # `<pf-helper-text>` | ||
|
|
||
| The **pf-helper-text** component provides contextual feedback messages for form fields or other UI elements. | ||
| It visually communicates states such as success, warning, error, or informational messages. | ||
| The component can display a default status icon or a fully custom icon provided through a slot or property. | ||
|
|
||
| Read more about dropdown in the [PatternFly Elements Dropdown | ||
| documentation](https://patternflyelements.org/components/dropdown) | ||
|
|
||
| --- | ||
| ## Installation | ||
|
|
||
| Load `<pf-helper-text>` via CDN: | ||
|
|
||
| ```html | ||
| <script src="https://jspm.dev/@patternfly/elements/pf-helper-text/pf-helper-text.js"></script> | ||
|
|
||
| <script src="https://jspm.dev/@patternfly/elements/pf-icon/pf-icon.js"></script> | ||
| ``` | ||
|
|
||
| Or, if you are using [NPM](https://npm.im), install it | ||
|
|
||
| ```bash | ||
| npm install @patternfly/elements | ||
| ``` | ||
|
|
||
| Then once installed, import it to your application: | ||
|
|
||
| ```js | ||
| import '@patternfly/elements/pf-helper-text/pf-helper-text.js'; | ||
| import '@patternfly/elements/pf-icon/pf-icon.js'; | ||
|
|
||
| ``` | ||
|
|
||
| ## Usage | ||
|
|
||
| ```html | ||
| <script type="module"> | ||
| import '@patternfly/elements/pf-icon/pf-icon.js'; | ||
| import '@patternfly/elements/pf-helper-text/pf-helper-text.js'; | ||
|
|
||
| // Optional: add FontAwesome icon set | ||
| PfIcon.addIconSet('fas', (set, icon) => { | ||
| return new URL(`@fortawesome/fontawesome-free/svgs/solid/${icon}.svg`, import.meta.url); | ||
| }); | ||
| </script> | ||
|
|
||
| <pf-helper-text> | ||
| This is default helper text | ||
| </pf-helper-text> | ||
|
|
||
| <pf-helper-text status="indeterminate" icon="minus" icon-set="fas"> | ||
| This is indeterminate helper text | ||
| </pf-helper-text> | ||
|
|
||
| <pf-helper-text status="warning" icon="exclamation-triangle" icon-set="fas"> | ||
| This is warning helper text | ||
| </pf-helper-text> | ||
|
|
||
| <pf-helper-text status="success" icon="check-circle" icon-set="fas"> | ||
| This is success helper text | ||
| </pf-helper-text> | ||
|
|
||
| <pf-helper-text status="error" icon="exclamation-circle" icon-set="fas"> | ||
| This is error helper text | ||
| </pf-helper-text> | ||
|
|
||
| <style> | ||
| pf-helper-text { | ||
| display: block; | ||
| margin: 1rem 0; | ||
| font-family: var(--pf-global--FontFamily--sans-serif, Arial, sans-serif); | ||
| } | ||
|
|
||
| pf-helper-text:not([status]) { | ||
| color: var(--pf-global--Color--100, #151515); | ||
| } | ||
| pf-helper-text[status="indeterminate"] { | ||
| color: var(--pf-global--Color--200, #6a6e73); | ||
| } | ||
| pf-helper-text[status="warning"] { | ||
| color: var(--pf-global--warning-color--100, #f0ab00); | ||
| } | ||
| pf-helper-text[status="success"] { | ||
| color: var(--pf-global--success-color--100, #3e8635); | ||
| } | ||
| pf-helper-text[status="error"] { | ||
| color: var(--pf-global--danger-color--100, #c9190b); | ||
| } | ||
|
|
||
| pf-helper-text [slot="icon"], | ||
| pf-icon { | ||
| fill: currentColor; | ||
| } | ||
| </style> | ||
|
|
||
|
|
||
| ``` | ||
| ## Slots | ||
|
|
||
| | Name | Description | | ||
| |------------|----------------------------------------------------------------------------------------| | ||
| | `icon` | Optional named slot for providing a custom icon.<br>Overrides the default status icon. | | ||
| | (default) | Default unnamed slot for the helper text content (text or other inline elements). | | ||
|
|
||
| Properties | ||
|
|
||
| |Name | Type | Default | Description| | ||
| | ----- |-----------------------------------------------------|---------|-------------------------- | ||
| |status |'default','success','warning','error','indeterminate'|'default'| Defines the visual state of the helper text and determines which default icon is shown if no custom icon is provided.| | ||
| |icon | string |undefined| Custom icon name to display. Overrides the default icon derived from status. Requires pf-icon to be imported.| | ||
| |iconSet| string |undefined| Icon set to use when specifying a custom icon (e.g., 'fas').| | ||
|
|
||
| ## Events | ||
|
|
||
| | Event Name | Description | | ||
| | ------------ | -------------------------------------------------------------------------------- | | ||
| | `icon-load` | Fired when a custom or default icon successfully loads. | | ||
| | `icon-error` | Fired if the icon fails to load. The event’s `detail` contains the error object. | | ||
|
|
||
| ## Default Icons by Status | ||
|
|
||
| | Status | Default Icon | | ||
| | --------------- | ---------------------- | | ||
| | `default` | *(none)* | | ||
| | `indeterminate` | `minus-circle` | | ||
| | `warning` | `exclamation-triangle` | | ||
| | `success` | `circle-check` | | ||
| | `error` | `exclamation-circle` | | ||
|
|
||
| ## Notes | ||
|
|
||
| Providing a custom <slot name="icon"> overrides the default icon. | ||
|
|
||
| Icons are lazy-loaded (loading="lazy") to optimize performance. | ||
|
|
||
| The pf-icon element must be imported if using built-in icons. | ||
|
|
||
| The component emits icon-load and icon-error events to track icon state. | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
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,40 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en" class="pf-m-redhat-font"> | ||
| <head> | ||
| <meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
| <title>pf-helper-text — Dynamic list</title> | ||
| <link rel="stylesheet" href="https://unpkg.com/@patternfly/patternfly/patternfly.css" crossorigin="anonymous" /> | ||
| <link rel="stylesheet" href="https://unpkg.com/@patternfly/elements/pf-styles/demo.css" crossorigin="anonymous" /> | ||
| <style>body{margin:0;background:var(--pf-global--BackgroundColor--100);color:var(--pf-global--Color--100); | ||
| font-family:var(--pf-global--FontFamily--text,"Red Hat Text",Arial,sans-serif);line-height:1.5} | ||
| pf-demo{display:block;padding:2rem;max-width:700px;margin-inline:auto} | ||
| h2{font-size:var(--pf-global--FontSize--xl);font-weight:var(--pf-global--FontWeight--bold);margin-bottom:1rem} | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <pf-demo> | ||
| <h2>Dynamic list</h2> | ||
| <pf-helper-text component="ul" live role="list"> | ||
| <pf-helper-text-item icon="check-circle" icon-set="fas" status="success" is-dynamic> | ||
| Must be at least 14 characters | ||
| </pf-helper-text-item> | ||
| <pf-helper-text-item icon="exclamation-circle" icon-set="fas" status="error" is-dynamic> | ||
| Cannot contain any variation of the word "redhat" | ||
| </pf-helper-text-item> | ||
| <pf-helper-text-item icon="check-circle" icon-set="fas" status="success" is-dynamic> | ||
| Must include at least 3 of the following: lowercase letter, uppercase letters, numbers, symbols | ||
| </pf-helper-text-item> | ||
| </pf-helper-text> | ||
| </pf-demo> | ||
|
|
||
| <script type="module"> | ||
| import '@patternfly/elements/pf-helper-text/pf-helper-text.js'; | ||
| import '@patternfly/elements/pf-helper-text/pf-helper-text-item.js'; | ||
| import '@patternfly/elements/pf-icon/pf-icon.js'; | ||
| import { PfIcon } from '@patternfly/elements/pf-icon/pf-icon.js'; | ||
| PfIcon.addIconSet('fas', (set, icon) => | ||
| new URL('/node_modules/@fortawesome/fontawesome-free/svgs/solid/' + icon + '.svg', window.location.origin) | ||
| ); | ||
| </script> | ||
| </body> | ||
| </html> |
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,107 @@ | ||
|
|
||
| <!DOCTYPE html> | ||
| <html lang="en" class="pf-m-redhat-font"> | ||
| <head> | ||
| <meta charset="utf-8" /> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
| <title>pf-helper-text — Dynamic</title> | ||
|
|
||
| <!-- PatternFly core styles --> | ||
| <link | ||
| rel="stylesheet" | ||
| href="https://unpkg.com/@patternfly/patternfly/patternfly.css" | ||
| crossorigin="anonymous" | ||
| /> | ||
|
|
||
| <!-- PatternFly Elements demo layout --> | ||
| <link | ||
| rel="stylesheet" | ||
| href="https://unpkg.com/@patternfly/elements/pf-styles/demo.css" | ||
| crossorigin="anonymous" | ||
| /> | ||
|
|
||
| <style> | ||
| body { | ||
| margin: 0; | ||
| background-color: var(--pf-global--BackgroundColor--100); | ||
| color: var(--pf-global--Color--100); | ||
| font-family: var(--pf-global--FontFamily--text, "Red Hat Text", Arial, sans-serif); | ||
| line-height: 1.5; | ||
| } | ||
|
|
||
| pf-demo { | ||
| display: block; | ||
| padding: 2rem; | ||
| max-width: 700px; | ||
| margin-inline: auto; | ||
| } | ||
|
|
||
| h2 { | ||
| font-size: var(--pf-global--FontSize--xl); | ||
| font-weight: var(--pf-global--FontWeight--bold); | ||
| margin-bottom: 1rem; | ||
| } | ||
|
|
||
| pf-helper-text { | ||
| display: block; | ||
| margin-block: 0.25rem; | ||
| } | ||
|
|
||
| pf-helper-text-item { | ||
| display: flex; | ||
| align-items: center; | ||
| font-size: var(--pf-c-helper-text--FontSize, 0.875rem); | ||
| gap: var(--pf-c-helper-text--Gap, 0.25rem); | ||
| } | ||
|
|
||
| pf-icon { | ||
| fill: currentColor; | ||
| width: 1em; | ||
| height: 1em; | ||
| } | ||
| </style> | ||
| </head> | ||
|
|
||
| <body> | ||
| <pf-demo> | ||
| <h2>Dynamic</h2> | ||
|
|
||
| <pf-helper-text> | ||
| <pf-helper-text-item icon="minus" icon-set="fas" status="default" is-dynamic> | ||
| This is default helper text | ||
| </pf-helper-text-item> | ||
|
|
||
| <pf-helper-text-item icon="minus" icon-set="fas" status="indeterminate" is-dynamic> | ||
| This is indeterminate helper text | ||
| </pf-helper-text-item> | ||
|
|
||
| <pf-helper-text-item icon="exclamation-triangle" icon-set="fas" status="warning" is-dynamic> | ||
| This is warning helper text | ||
| </pf-helper-text-item> | ||
|
|
||
| <pf-helper-text-item icon="check-circle" icon-set="fas" status="success" is-dynamic> | ||
| This is success helper text | ||
| </pf-helper-text-item> | ||
|
|
||
| <pf-helper-text-item icon="exclamation-circle" icon-set="fas" status="error" is-dynamic> | ||
| This is error helper text | ||
| </pf-helper-text-item> | ||
| </pf-helper-text> | ||
| </pf-demo> | ||
|
|
||
| <script type="module"> | ||
| import '@patternfly/elements/pf-helper-text/pf-helper-text.js'; | ||
| import '@patternfly/elements/pf-helper-text/pf-helper-text-item.js'; | ||
| import '@patternfly/elements/pf-icon/pf-icon.js'; | ||
| import { PfIcon } from '@patternfly/elements/pf-icon/pf-icon.js'; | ||
|
|
||
| // ✅ טעינת סט האייקונים של Font Awesome | ||
| PfIcon.addIconSet('fas', (set, icon) => { | ||
| return new URL( | ||
| '/node_modules/@fortawesome/fontawesome-free/svgs/solid/' + icon + '.svg', | ||
| window.location.origin | ||
| ); | ||
| }); | ||
| </script> | ||
| </body> | ||
| </html> |
Empty file.
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.