Skip to content

Commit 531e067

Browse files
jawinnpfulton
authored andcommitted
feat(taggroup)!: migrate to spectrum-tokens
BREAKING CHANGE: migrates TagGroup to use `@adobe/spectrum-tokens` Update build related files to migrate to use of core tokens. Use new global tokens for margin, and simplify usage. Adds mod prefixed custom properties and improves docs with mod section and description text pulled from the tag guidelines. Updates example markup and migration guide. fix(taggroup): allow tag items to wrap to the next line Tag group flex items were not previously wrapping and would overflow and cut off at smaller screen sizes. This now follows the tag guidelines to wrap items to the next line. And adds a story that shows wrapping. CSS-500
1 parent 4ca408d commit 531e067

File tree

10 files changed

+130
-78
lines changed

10 files changed

+130
-78
lines changed

components/taggroup/gulpfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
module.exports = require("@spectrum-css/component-builder");
1+
module.exports = require('@spectrum-css/component-builder-simple');

components/taggroup/index.css

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,19 @@ governing permissions and limitations under the License.
1111
*/
1212

1313
.spectrum-TagGroup {
14-
/* todo: get this added back to DNA */
15-
--spectrum-taggroup-tag-gap-x: var(--spectrum-global-dimension-size-100);
16-
--spectrum-taggroup-tag-gap-y: var(--spectrum-global-dimension-size-100);
14+
--spectrum-tag-group-item-margin-block: var(--spectrum-spacing-75);
15+
--spectrum-tag-group-item-margin-inline: var(--spectrum-spacing-75);
1716
}
1817

1918
.spectrum-TagGroup {
2019
display: inline-flex;
21-
20+
flex-wrap: wrap;
2221
margin: 0;
2322
padding: 0;
2423
list-style: none;
2524
}
2625

2726
.spectrum-TagGroup-item {
28-
margin-block: calc(var(--spectrum-taggroup-tag-gap-y)/2);
29-
margin-inline: calc(var(--spectrum-taggroup-tag-gap-x)/2);
27+
margin-block: var(--mod-tag-group-item-margin-block, var(--spectrum-tag-group-item-margin-block));
28+
margin-inline: var(--mod-tag-group-item-margin-inline, var(--spectrum-tag-group-item-margin-inline));
3029
}

components/taggroup/metadata/mods.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
| Modifiable Custom Properties |
2+
| ------------------------------------ |
3+
| `--mod-tag-group-item-margin-block` |
4+
| `--mod-tag-group-item-margin-inline` |

components/taggroup/metadata/taggroup.yml

Lines changed: 58 additions & 49 deletions
Large diffs are not rendered by default.

components/taggroup/package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@spectrum-css/taggroup",
3-
"version": "3.3.64",
4-
"description": "The Spectrum CSS tags component",
3+
"version": "4.0.0-beta.0",
4+
"description": "The Spectrum CSS tag group component",
55
"license": "Apache-2.0",
66
"author": "Adobe",
77
"homepage": "https://opensource.adobe.com/spectrum-css/taggroup",
@@ -18,17 +18,17 @@
1818
"build": "gulp"
1919
},
2020
"peerDependencies": {
21-
"@spectrum-css/clearbutton": ">=1",
22-
"@spectrum-css/tag": ">=6",
23-
"@spectrum-css/vars": ">=9"
21+
"@spectrum-css/clearbutton": ">=5",
22+
"@spectrum-css/tag": ">=8",
23+
"@spectrum-css/tokens": ">=11"
2424
},
2525
"devDependencies": {
26-
"@spectrum-css/avatar": "^6.0.48",
27-
"@spectrum-css/clearbutton": "^2.0.0",
28-
"@spectrum-css/component-builder": "^4.0.14",
26+
"@spectrum-css/avatar": "^6.0.47",
27+
"@spectrum-css/clearbutton": "^5.0.0",
28+
"@spectrum-css/component-builder-simple": "^2.0.17",
2929
"@spectrum-css/icon": "^4.0.1",
30-
"@spectrum-css/tag": "^8.0.1",
31-
"@spectrum-css/vars": "^9.0.8",
30+
"@spectrum-css/tag": "^8.0.0",
31+
"@spectrum-css/tokens": "^11.2.2",
3232
"gulp": "^4.0.0"
3333
},
3434
"publishConfig": {

components/taggroup/skin.css

Lines changed: 0 additions & 11 deletions
This file was deleted.

components/taggroup/stories/taggroup.stories.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ export default {
3737
},
3838
control: "boolean",
3939
},
40+
customStyles: {
41+
description: "Custom styles for testing the story, applied to the parent element.",
42+
table: {
43+
type: { summary: "object" },
44+
category: "Storybook Only",
45+
},
46+
if: { arg: 'customStyles' }
47+
}
4048
},
4149
args: {
4250
rootClass: "spectrum-TagGroup",
@@ -88,3 +96,42 @@ Removable.args = {
8896
},
8997
],
9098
};
99+
100+
export const OverflowItems = Template.bind({});
101+
OverflowItems.parameters = {
102+
docs: {
103+
description: {
104+
story:
105+
"When horizontal space is limited in a tag group, the individual tags wrap to form another line.",
106+
},
107+
},
108+
};
109+
OverflowItems.args = {
110+
size: "m",
111+
isRemovable: true,
112+
isEmphasized: false,
113+
customStyles: {'max-width': '300px'},
114+
items: [
115+
{
116+
label: "Tag 1 Example",
117+
},
118+
{
119+
label: "Tag 2 Example",
120+
},
121+
{
122+
label: "Tag 3 Example",
123+
},
124+
{
125+
label: "Tag 4",
126+
},
127+
{
128+
label: "Tag 5",
129+
},
130+
{
131+
label: "Tag 6",
132+
},
133+
{
134+
label: "Tag 7",
135+
},
136+
],
137+
};

components/taggroup/stories/template.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
import { html } from "lit";
22
import { classMap } from "lit/directives/class-map.js";
3+
import { styleMap } from "lit/directives/style-map.js";
34
import { ifDefined } from "lit/directives/if-defined.js";
45

56
import { Template as Tag } from "@spectrum-css/tag/stories/template.js";
67

78
import "../index.css";
8-
import "../skin.css";
99

1010
export const Template = ({
1111
rootClass = "spectrum-TagGroup",
1212
ariaLabel,
1313
items,
1414
isRemovable = false,
1515
customClasses = [],
16+
customStyles = {},
1617
...globals
1718
}) => {
1819
return html`
@@ -21,6 +22,7 @@ export const Template = ({
2122
[rootClass]: true,
2223
...customClasses.reduce((a, c) => ({ ...a, [c]: true }), {}),
2324
})}
25+
style=${styleMap(customStyles)}
2426
role="list"
2527
aria-label=${ifDefined(ariaLabel)}
2628
>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@container (--system: express) {}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@container (--system: spectrum) {}

0 commit comments

Comments
 (0)