Skip to content

Commit 9b251d6

Browse files
author
Sara Dahan
committed
feat(label-group): add new functions and features for label management
1 parent 7f82f28 commit 9b251d6

File tree

3 files changed

+189
-141
lines changed

3 files changed

+189
-141
lines changed
Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,16 @@
1-
<pf-label-group removable add-label>
2-
<pf-label icon="info-circle" removable>Gold icon</pf-label>
3-
<pf-label icon="info-circle" removable>Gold icon</pf-label>
4-
<h2 slot="header">label group </h2>
51

2+
<pf-label-group removable num-labels="3" orientation="horizontal">
3+
<h2 slot="category-name">Very very very long textttttttttt</h2>
4+
5+
<pf-label icon="info-circle" removable>label-1</pf-label>
6+
<pf-label icon="info-circle" removable>label-2</pf-label>
7+
<pf-label icon="info-circle" removable>label-3</pf-label>
8+
<pf-label icon="info-circle" removable>label-4</pf-label>
9+
<pf-label icon="info-circle" removable>label-5</pf-label>
610
</pf-label-group>
711

812
<script type="module">
913
import '@patternfly/elements/pf-label-group/pf-label-group.js';
1014
import '@patternfly/elements/pf-label/pf-label.js';
1115
import '@patternfly/elements/pf-button/pf-button.js';
12-
13-
const container = document.querySelector('pf-label-group');
14-
container.addEventListener('close', function(event) {
15-
event.target.remove();
16-
});
17-
18-
19-
container.addEventListener('add-label' , function(event) {
20-
21-
22-
console.log('Add label button clicked');
23-
} );
2416
</script>
25-
26-
<style>
27-
pf-label-group {
28-
/* insert demo styles */
29-
}
30-
</style>
Lines changed: 47 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,12 @@
1+
12
:host {
23
display: flex;
3-
flex-direction: row; /* ברירת מחדל = horizontal */
4+
flex-direction: row;
45
position: relative;
56
gap: 0.5rem;
67
border: 0;
78
}
89

9-
:host([orientation="horizontal"]) #container {
10-
flex-direction: row;
11-
}
12-
13-
:host([orientation="vertical"]) {
14-
flex-direction: column;
15-
}
16-
17-
:host([orientation="vertical"]) #container {
18-
flex-direction: column;
19-
}
20-
21-
:host([removable]) span[part="close-button"] {
22-
display: inline-flex;
23-
align-items: center;
24-
cursor: pointer;
25-
margin-left: auto;
26-
}
27-
28-
/* Container styles */
29-
#container {
30-
display: flex;
31-
align-items: center;
32-
gap: var(--pf-c-label--m-compact--c-button--MarginLeft, var(--pf-global--spacer--xs, 0.25rem));
33-
padding: var(--pf-c-label--PaddingTop, var(--pf-global--spacer--xs, 0.25rem))
34-
var(--pf-c-label--PaddingRight, var(--pf-global--spacer--sm, 0.5rem))
35-
var(--pf-c-label--PaddingBottom, var(--pf-global--spacer--xs, 0.25rem))
36-
var(--pf-c-label--PaddingLeft, var(--pf-global--spacer--sm, 0.5rem));
37-
font-size: var(--pf-c-label--FontSize, var(--pf-global--FontSize--sm, 0.875rem));
38-
color: var(--pf-c-label__content--Color, var(--pf-global--Color--100, #151515));
39-
background-color: var(--pf-c-label--BackgroundColor, var(--pf-global--BackgroundColor--100, #fff));
40-
border-radius: var(--pf-c-label--BorderRadius, 0em);
41-
max-width: 100%;
42-
position: relative;
43-
--pf-global--icon--FontSize--sm: 14px;
44-
}
45-
46-
#container::before {
47-
position: absolute;
48-
top: 0;
49-
right: 0;
50-
bottom: 0;
51-
left: 0;
52-
pointer-events: none;
53-
content: "";
54-
border-radius: var(--pf-c-label--BorderRadius, 0em);
55-
border: var(--pf-c-label__content--before--BorderWidth, 1px) solid var(--pf-c-label__content--before--BorderColor, var(--pf-global--palette--black-300, #d2d2d2));
56-
}
57-
58-
/* Icons */
59-
pf-icon, ::slotted(pf-icon) {
60-
color: currentColor;
61-
}
62-
63-
[part=icon] {
64-
display: none;
65-
pointer-events: none;
66-
}
67-
68-
svg {
69-
vertical-align: -0.125em;
70-
fill: currentColor;
71-
height: 1em;
72-
width: 1em;
73-
}
74-
75-
/* Button inside label */
7610
pf-button {
7711
--pf-c-button--FontSize: var(--pf-c-label__c-button--FontSize, var(--pf-global--FontSize--xs, 0.75rem));
7812
--pf-c-button--PaddingTop: var(--pf-c-label__c-button--PaddingTop, var(--pf-global--spacer--xs, 0.25rem));
@@ -85,26 +19,60 @@ pf-button {
8519
var(--pf-c-label__c-button--MarginLeft, 0.25rem);
8620
}
8721

88-
/* Compact modifier */
8922
.compact {
9023
--pf-c-label--PaddingTop: var(--pf-c-label--m-compact--PaddingTop, 0);
9124
--pf-c-label--PaddingRight: var(--pf-c-label--m-compact--PaddingRight, var(--pf-global--spacer--sm, 0.5rem));
9225
--pf-c-label--PaddingBottom: var(--pf-c-label--m-compact--PaddingBottom, 0);
9326
--pf-c-label--PaddingLeft: var(--pf-c-label--m-compact--PaddingLeft, var(--pf-global--spacer--sm, 0.5rem));
9427
--pf-global--icon--FontSize--sm: 12px;
9528
}
29+
9630
.add-label-btn {
97-
background-color: #fff;
98-
color: #0066cc;
99-
border: 1px solid #d2d2d2;
100-
border-radius: 9999px;
101-
padding: 0px 2px; /* ריווח קטן יותר */
102-
font-size: 9px; /* טקסט קטן יותר */
31+
background-color: #fff;
32+
color: #0066cc;
33+
border: 1px solid #d2d2d2;
34+
border-radius: 9999px;
35+
padding: 0px 2px;
36+
font-size: 9px;
10337
cursor: pointer;
104-
font-weight: 500;
38+
font-weight: 500;
10539
}
10640

107-
10841
.add-label-btn:hover {
109-
background-color: #f5f5f5;
110-
}
42+
background-color: #f5f5f5;
43+
}
44+
45+
#outer {
46+
display: flex;
47+
flex-wrap: wrap;
48+
gap: 0.25rem;
49+
padding: 0.5rem;
50+
border: 1px solid #d2d2d2;
51+
border-radius: 6px;
52+
background-color: #fff;
53+
}
54+
55+
:host([orientation="horizontal"]) #outer {
56+
flex-direction: row;
57+
}
58+
59+
:host([orientation="vertical"]) #outer {
60+
flex-direction: column;
61+
align-items: flex-start;
62+
}
63+
64+
/* הכותרת ב-slotted category-name */
65+
::slotted([slot="category-name"]) {
66+
display: inline-block;
67+
max-width: 16ch; /* מגביל את הרוחב כדי שיוכל להיחתך */
68+
overflow: hidden;
69+
text-overflow: ellipsis;
70+
white-space: nowrap;
71+
vertical-align: middle;
72+
cursor: default;
73+
}
74+
75+
/* מאפשר להוסיף tooltip טבעי של הדפדפן */
76+
::slotted([slot="category-name"][title]):hover {
77+
/* אין צורך בסגנון נוסף – הדפדפן מציג tooltip לבד */
78+
}

0 commit comments

Comments
 (0)