Skip to content

Commit 88c8ac3

Browse files
committed
feat(breadcrumb): add support for multiline headings
The new specs specified that title item can be customized in the multiline variant, with preferred sizing. This adds support for that in our template and adds a new Storybook control.
1 parent d95d895 commit 88c8ac3

File tree

4 files changed

+81
-8
lines changed

4 files changed

+81
-8
lines changed

.changeset/wet-laws-worry.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ There has been a major design change to the variant classes related to density a
1111
- The "compact" variant no longer exists. The `spectrum-Breadcrumbs--compact` class and associated custom properties are removed. The default (medium) breadcrumbs are now sized similar to what was previously called compact.
1212
- There is a new "large" variant, which uses the `spectrum-Breadcrumbs--large` class. This is sized similarly to what was previously the default.
1313

14-
For each breadcrumbs variant, the design spec specifies that following sizes should be used for the truncated menu action button and the separator chevron:
15-
16-
- default (medium): medium action button and Chevron100 UI icon
17-
- large: large action button and Chevron100 UI icon
18-
- multiline: small action button and Chevron75 UI icon
14+
The breadcrumb title can now be customized in the multiline variant using an additional element that uses the typography component's heading classes.
15+
See the documentation for details about this and the preferred sizing. The documentation also has been updated to include information about which
16+
icon sizes should be displayed for each t-shirt size.
1917

2018
The component has been refactored to slim down and simplify its CSS and custom properties, by changing the values of existing custom properties for large and multiline variants.
2119

components/breadcrumb/package.json

+5-1
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,18 @@
2424
"peerDependencies": {
2525
"@spectrum-css/actionbutton": ">=6",
2626
"@spectrum-css/icon": ">=7",
27-
"@spectrum-css/tokens": ">=14.0.0-next.3"
27+
"@spectrum-css/tokens": ">=14.0.0-next.3",
28+
"@spectrum-css/typography": ">=6"
2829
},
2930
"peerDependenciesMeta": {
3031
"@spectrum-css/actionbutton": {
3132
"optional": true
3233
},
3334
"@spectrum-css/icon": {
3435
"optional": true
36+
},
37+
"@spectrum-css/typography": {
38+
"optional": true
3539
}
3640
},
3741
"keywords": [

components/breadcrumb/stories/breadcrumb.stories.js

+40-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Template } from "./template";
1+
import { BreadcrumbTitleHeadings, Template } from "./template";
22

33
/**
44
* Breadcrumbs show hierarchy and navigational context for a user's location within an app.
@@ -44,6 +44,28 @@ export default {
4444
},
4545
control: "boolean"
4646
},
47+
titleHeadingSize: {
48+
name: "Breadcrumb title heading size",
49+
description: "The breadcrumb title can be customized in the multiline variant using an additional element that uses the typography component's heading classes. The preferred heading sizes are small, medium large, and extra-large. When no heading classes are used, the text will be sized the same as a large heading by default.",
50+
type: { name: "string" },
51+
table: {
52+
type: { summary: "string" },
53+
category: "Content",
54+
},
55+
control: {
56+
type: "select",
57+
labels: {
58+
undefined: "Default",
59+
s: "Small",
60+
m: "Medium",
61+
l: "Large",
62+
xl: "Extra-large",
63+
},
64+
},
65+
defaultValue: undefined,
66+
options: [undefined, "s", "m", "l", "xl"],
67+
if: { arg: "variant", eq: "multiline" },
68+
}
4769
},
4870
args: {
4971
rootClass: "spectrum-Breadcrumbs",
@@ -241,6 +263,23 @@ Disabled.parameters = {
241263
chromatic: { disableSnapshot: true },
242264
};
243265

266+
/**
267+
* For the multiline variant, the breadcrumb title can be customized using an additional element that uses the heading classes from
268+
* the [typography component](?path=/docs/components-typography). The preferred heading sizes are `.spectrum-Heading--sizeS`,
269+
* `.spectrum-Heading--sizeM`, `.spectrum-Heading--sizeL` (default), and `.spectrum-Heading--sizeXL`. If no heading element or classes are
270+
* used, the text will be sized the same as a large heading by default.
271+
*/
272+
export const MultilineTitleSizes = BreadcrumbTitleHeadings.bind({});
273+
MultilineTitleSizes.args = {
274+
...DefaultNested.args,
275+
variant: "multiline",
276+
};
277+
MultilineTitleSizes.storyName = "Multiline breadcrumb title heading sizes";
278+
MultilineTitleSizes.tags= ["!dev"];
279+
MultilineTitleSizes.parameters = {
280+
chromatic: { disableSnapshot: true },
281+
};
282+
244283
// ********* VRT ONLY ********* //
245284
/*
246285
export const WithForcedColors = BreadcrumbGroup.bind({});

components/breadcrumb/stories/template.js

+33-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Template as ActionButton } from "@spectrum-css/actionbutton/stories/template.js";
22
import { Template as Icon } from "@spectrum-css/icon/stories/template.js";
3+
import { Template as Typography } from "@spectrum-css/typography/stories/template.js";
34
import { html } from "lit";
45
import { classMap } from "lit/directives/class-map.js";
56
import { ifDefined } from "lit/directives/if-defined.js";
@@ -14,6 +15,7 @@ export const Template = (
1415
items = [],
1516
variant = "medium",
1617
isDragged = false,
18+
titleHeadingSize,
1719
} = {},
1820
context = {},
1921
) => html`
@@ -68,7 +70,11 @@ export const Template = (
6870
</div>`,
6971
() =>
7072
html`<a class="${rootClass}-itemLink" aria-current="page"
71-
>${label}</a
73+
>${ typeof titleHeadingSize == "undefined" ? label : Typography({
74+
semantics: "heading",
75+
size: titleHeadingSize,
76+
content: [label],
77+
})}</a
7278
>`,
7379
),
7480
)}
@@ -86,4 +92,30 @@ export const Template = (
8692
})}
8793
</ul>
8894
</nav>
95+
`;
96+
97+
/**
98+
* Displays all preferred sizes for breadcrumb title headings used with the multiline variant.
99+
*
100+
* TODO: make sure of Container() with headings when S2 is in sync with the main branch again.
101+
*/
102+
export const BreadcrumbTitleHeadings = (args) => html`
103+
<div style="display: flex; flex-direction: column; gap: 16px;">
104+
${[undefined, "s", "m", "l", "xl"].map((titleHeadingSize) => html`
105+
${Typography({
106+
semantics: "detail",
107+
size: "s",
108+
content: [
109+
typeof titleHeadingSize != "undefined"
110+
? `Heading size: ${titleHeadingSize}`
111+
: "Default - no heading element or classes"
112+
],
113+
customClasses: ["chromatic-ignore"],
114+
})}
115+
${Template({
116+
...args,
117+
titleHeadingSize,
118+
})}
119+
`)}
120+
</div>
89121
`;

0 commit comments

Comments
 (0)