- Notifications
You must be signed in to change notification settings - Fork 106
feat(label-group): create pf-label-group element#2949
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
Open
saraDahanCode wants to merge 28 commits into patternfly:mainChoose a base branch from saraDahanCode:create-pf-lable-group
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.
Uh oh!
There was an error while loading. Please reload this page.
Open
Changes from all commits
Commits
Show all changes
28 commits Select commit Hold shift + click to select a range
d86e8ac feat(label-group): add new label-group-element
7f82f28 chore(label-group): minor updates
9b251d6 feat(label-group): add new functions and features for label management
8514436 chore: add changeset for pf-label-group element
8e3236a docs(label-group): add demos for closeable,overflow,vertical,header o…
751df4c fix: correct config path
5528dd3 chore: small fixes after review
72c0833 chore: push current state for debugging build errors
64688ae chore(label-group): resolve merge conflicts and update package-lock.json
616b18d chore(label-group): fix errors
12c0d2a chore(label-group): resolve patch conflict keeping upstream version
bc5f6c9 chore(label-group): resolve patch conflict keeping upstream version
5c721a7 docs(label-group): update changeset to follow changelog format
e211096 chore(label-group): fix whitespace and formatting in demos
89c762f Revert changes to package-lock.json per PR review
16212ee fix(label-group): make collapsedText placeholder generic
141781e fix(label-group): wrap #labels getter with server check to avoid DOM …
9f82c0b fix(label-group): wrap #labels getter with server check to avoid DOM …
fb079ed fix(label-group): guard DOM access for SSR
06ada58 docs: update README with latest instructions
7348fd0 chore(label-group): update pf-label-group.ts
37a1cb6 feat(label-group): add Functionality
0dcec75 chore(label-group): apply the reqeasted changes
2eeae64 feat(label-group): add demo to add label
Michal7290 626f9f2 Merge remote-tracking branch 'sara/create-pf-lable-group' into create…
Michal7290 8cfa3ef feat(label-group): change the demos
Michal7290 b00fa46 Merge pull request #1 from Michal7290/create-pf-lable-group
saraDahanCode cffdff2 chore(label-group): transferring the insertion logic from TS to Demos
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
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,21 @@ | ||
| --- | ||
| "@patternfly/elements": minor | ||
| --- | ||
| ✨ Added `<pf-label-group>`. | ||
| A label group displays multiple labels together, helping users visualize related categories, filters, or items. | ||
| Each label can be removed individually, and the entire group can also be cleared at once. | ||
| The element automatically handles overflow for long lists of labels and supports both horizontal and vertical layouts. | ||
| Use this when you need to show multiple tags, filters, or categorized items that users can remove, add, or adjust dynamically. | ||
| Avoid using it for single, standalone labels — consider using `<pf-label>` instead. | ||
| ```html | ||
| <pf-label-group label="Filters" add-label-mode="fromList"> | ||
| <pf-label removable>Security</pf-label> | ||
| <pf-label removable>Performance</pf-label> | ||
| <pf-label removable>Networking</pf-label> | ||
| </pf-label-group> | ||
| ``` |
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
saraDahanCode marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page.
bennypowers marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading. Please reload this page. |
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,62 @@ | ||
| # Label Group | ||
| A label group is a collection of labels that can be grouped by category and used to represent one or more values assigned to a single attribute. | ||
| When the number of labels exceeds `numLabels`, additional labels are hidden under an overflow label. | ||
| ## Installation | ||
| Load `<pf-label-group>` via CDN: | ||
| ```html | ||
| <script src="https://jspm.dev/@patternfly/elements/pf-label-group/pf-label-group.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-label-group/pf-label-group.js' | ||
| ``` | ||
| --- | ||
| ## Usage | ||
| ```html | ||
| <pf-label-group num-labels="2"> | ||
| <span slot="category">Fruit Types</span> | ||
| <pf-label>Apple</pf-label> | ||
| <pf-label>Banana</pf-label> | ||
| <pf-label>Orange</pf-label> | ||
| </pf-label-group> | ||
| ``` | ||
| Displays a group of labels, showing only the first two and an overflow label like “1 more” that expands on click. | ||
| ## Adding Labels | ||
| `<pf-label-group>` supports adding new labels dynamically through the `addLabelMode` attribute: | ||
| - `none` (default): No label addition. | ||
| - `autoNoEdit`: Adds labels automatically without user editing. | ||
| - `fromList`: Allows adding labels from a predefined list. | ||
| - `customForm`: Lets users add custom labels via a form. | ||
| Example: | ||
| ```html | ||
| <pf-label-group add-label-mode="fromList"> | ||
| <span slot="category">Filters</span> | ||
| <pf-label removable>Security</pf-label> | ||
| <pf-label removable>Performance</pf-label> | ||
| </pf-label-group> | ||
| Use this feature when you want users to dynamically add new tags or filters to the group. | ||
| --- | ||
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,11 @@ | ||
| <pf-label-group open> | ||
| <pf-label color="blue">Blue Label</pf-label> | ||
| <pf-label color="green">Green Label</pf-label> | ||
| <pf-label color="orange">Orange Label</pf-label> | ||
| </pf-label-group> | ||
| <script type="module"> | ||
| import '@patternfly/elements/pf-label-group/pf-label-group.js' | ||
| import '@patternfly/elements/pf-label/pf-label.js' | ||
| import '@patternfly/elements/pf-button/pf-button.js' | ||
| </script> |
38 changes: 38 additions & 0 deletions 38 elements/pf-label-group/demo/label-group-add-label-auto.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,38 @@ | ||
| <pf-label-group id="label-group" closeable> | ||
| <h2 slot="category">group name</h2> | ||
| <pf-label color="red" icon="info-circle" removable>label-1</pf-label> | ||
| <pf-label color="green" icon="info-circle" removable>label-2</pf-label> | ||
| <pf-label color="blue" icon="info-circle" removable>label-3</pf-label> | ||
| <pf-label id="add-button" color="blue" variant="outline" dismissible="false" > | ||
| Add label </pf-label> | ||
| </pf-label-group> | ||
| <script type="module"> | ||
| import '@patternfly/elements/pf-label-group/pf-label-group.js' | ||
| import '@patternfly/elements/pf-label/pf-label.js' | ||
| import '@patternfly/elements/pf-button/pf-button.js' | ||
| import '@patternfly/elements/pf-modal/pf-modal.js' | ||
| import '@patternfly/elements/pf-dropdown/pf-dropdown.js' | ||
| document.getElementById('add-button').addEventListener('click', () =>{ | ||
| const labelGroup = document.getElementById('label-group'); | ||
| const newLabel = document.createElement('pf-label'); | ||
| newLabel.setAttribute('color', 'grey'); | ||
| newLabel.setAttribute('icon', 'info-circle'); | ||
| newLabel.setAttribute('removable', 'true'); | ||
| newLabel.textContent = `new-label`; | ||
| const firstLabel = labelGroup.querySelector('pf-label:not([slot])'); | ||
| if (firstLabel) labelGroup.insertBefore(newLabel, firstLabel); | ||
| else labelGroup.appendChild(newLabel); | ||
| }); | ||
| </script> | ||
| <style> | ||
| #add-button{ | ||
| cursor: pointer; | ||
| align-items: center; | ||
| gap: 4px; | ||
| transition: border 0.2s ease; | ||
| border-radius: 0.99rem; | ||
| } | ||
| </style> |
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
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.