Skip to content

Commit 5528dd3

Browse files
author
Sara Dahan
committed
chore: small fixes after review
1 parent 751df4c commit 5528dd3

File tree

6 files changed

+37
-32
lines changed

6 files changed

+37
-32
lines changed

.changeset/yummy-eagles-itch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"@patternfly/elements": minor
33
---
44

5-
Introduce <pf-label-group> element with:
5+
Introduce `<pf-label-group>` element with:
66
- Removable labels and option to remove entire group
77
- Overflow handling for labels and title
88
- Horizontal and vertical layout support

elements/pf-label-group/README.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,23 @@
11
# Label Group
2-
Add a description of the component here.
2+
# <pf-label-group>
33

4-
## Usage
5-
Describe how best to use this web component along with best practices.
4+
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.
5+
When the number of labels exceeds `numLabels`, additional labels are hidden under an overflow label.
66

7-
```html
8-
<pf-label-group>
7+
---
8+
## Usage
99

10+
```html
11+
<pf-label-group num-labels="2">
12+
<span slot="category">Fruit Types</span>
13+
<pf-label>Apple</pf-label>
14+
<pf-label>Banana</pf-label>
15+
<pf-label>Orange</pf-label>
1016
</pf-label-group>
1117
```
18+
19+
Displays a group of labels, showing only the first two and an overflow label like “1 more” that expands on click.
20+
21+
---
22+
23+

elements/pf-label-group/demo/label-group-closeable.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
2-
<pf-label-group closeable >
1+
<pf-label-group closeable>
32
<h2 slot="category-name">group name</h2>
4-
<pf-label color="red" icon="info-circle" removable>label-3</pf-label>
5-
<pf-label color="green" icon="info-circle" removable>label-4</pf-label>
6-
<pf-label color="blue" icon="info-circle" removable>label-5</pf-label>
3+
<pf-label color="red" icon="info-circle" removable>label-1</pf-label>
4+
<pf-label color="green" icon="info-circle" removable>label-2</pf-label>
5+
<pf-label color="blue" icon="info-circle" removable>label-3</pf-label>
76
</pf-label-group>
87

98
<script type="module">

elements/pf-label-group/pf-label-group.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import '@patternfly/elements/pf-button/pf-button.js';
77

88
import styles from './pf-label-group.css';
99

10+
import { state } from 'lit/decorators/state.js';
1011
import { query } from 'lit/decorators/query.js';
1112
import { queryAssignedNodes } from 'lit/decorators/query-assigned-nodes.js';
1213
import { observes } from '@patternfly/pfe-core/decorators/observes.js';
@@ -35,12 +36,12 @@ const REMAINING_RE = /\$\{\s*remaining\s*\}/g;
3536
*
3637
* @fires expand - Fired when label group is expanded to show all labels
3738
*
38-
* @slot category-name - Category name text for label group category. If supplied, label group will have category styling applied
39+
* @slot category - Category name text for label group category. If supplied, label group will have category styling applied
3940
* @slot - Default slot for `<pf-label>` elements
4041
*
4142
* @example
4243
* <pf-label-group num-labels="2 ">
43-
* <span slot="category-name">Fruit Types</span>
44+
* <span slot="category">Fruit Types</span>
4445
* <pf-label>Apple</pf-label>
4546
* <pf-label>Banana</pf-label>
4647
* <pf-label>Orange</pf-label>
@@ -57,7 +58,6 @@ export class PfLabelGroup extends LitElement {
5758

5859
/**
5960
* Orientation of the label group.
60-
* @default 'horizontal'
6161
*/
6262
@property() orientation: 'horizontal' | 'vertical' = 'horizontal';
6363

@@ -103,12 +103,12 @@ export class PfLabelGroup extends LitElement {
103103
*/
104104
@property({ reflect: true, type: Boolean }) closeable = false;
105105

106-
@property() private _overflowText = '';
106+
@state() private _overflowText = '';
107107

108108
@query('#close-button') private _button?: HTMLButtonElement;
109109

110110
@queryAssignedNodes({
111-
slot: 'category-name',
111+
slot: 'category',
112112
flatten: true,
113113
})
114114
private _categorySlotted?: HTMLElement[];
@@ -134,7 +134,7 @@ export class PfLabelGroup extends LitElement {
134134

135135
return html`
136136
<div id="outer" class="${classMap({ 'has-category': hasCategory, empty })}" role="toolbar">
137-
<slot id="category" name="category-name" @slotchange="${this.#onCategorySlotChange}">
137+
<slot id="category" name="category" @slotchange="${this.#onCategorySlotChange}">
138138
<span class="visually-hidden label-text" ?hidden="${!this.accessibleLabel}">
139139
${this.accessibleLabel ?? ''}
140140
</span>
@@ -143,18 +143,18 @@ export class PfLabelGroup extends LitElement {
143143
<slot id="labels" @slotchange="${this.#onSlotchange}"></slot>
144144
145145
${this._overflowText ?
146-
html`<pf-label
146+
html`<pf-label
147147
id="overflow"
148148
aria-controls="labels"
149149
overflow-label
150150
@click="${this.#onMoreClick}"
151151
>
152152
${this._overflowText}
153153
</pf-label>`
154-
: ''}
154+
: ''}
155155
156156
${this.closeable ?
157-
html`<pf-button
157+
html`<pf-button
158158
id="close-button"
159159
plain
160160
icon="times-circle"
@@ -163,7 +163,7 @@ export class PfLabelGroup extends LitElement {
163163
aria-describedby="category"
164164
@click="${this.#onCloseClick}"
165165
></pf-button>`
166-
: ''}
166+
: ''}
167167
</div>
168168
`;
169169
}
@@ -239,8 +239,8 @@ export class PfLabelGroup extends LitElement {
239239
this._overflowText = rem < 1 ?
240240
''
241241
: this.open ?
242-
this.expandedText
243-
: this.collapsedText.replace(REMAINING_RE, rem.toString());
242+
this.expandedText
243+
: this.collapsedText.replace(REMAINING_RE, rem.toString());
244244

245245
if (rem < 1 && this.open) {
246246
this.open = false;

package-lock.json

Lines changed: 2 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,5 @@
326326
"./core/*",
327327
"./elements",
328328
"./tools/*"
329-
],
330-
"dependencies": {
331-
"@patternfly/icons": "^1.0.3"
332-
}
329+
]
333330
}

0 commit comments

Comments
 (0)