Skip to content
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

feat(component): breadcrumb #4065

Merged
merged 73 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
83af2d8
feat(component): introduced different implementation
alionazherdetska Nov 19, 2024
d7a492f
feat(component): refactored the component
alionazherdetska Nov 19, 2024
e86d577
chore: autogenerated files
alionazherdetska Nov 19, 2024
4987f1c
chore: autogenerated files
alionazherdetska Nov 19, 2024
6841892
chore: autogenerated file
alionazherdetska Nov 19, 2024
d22d45b
fix(component): breadcrumb was refactored and renamed
alionazherdetska Nov 19, 2024
90a9312
fix(post-menu): Refactor post-menu to use getRoot for shadow DOM comp…
alionazherdetska Nov 28, 2024
5edc4f0
Merge branch 'main' into 3207-component_breadcrumb
alionazherdetska Nov 28, 2024
6b5adf1
fix(post-menu): fixed post-menu
alionazherdetska Nov 28, 2024
39d042e
Merge branch 'main' into 3207-component_breadcrumb
alionazherdetska Dec 2, 2024
4950ed5
chore(component): made some adjustements for the component
alionazherdetska Dec 2, 2024
d3addef
Merge branch 'main' into 3207-component_breadcrumb
alionazherdetska Dec 2, 2024
49b91fc
chore(introduced alternative implementation)
alionazherdetska Dec 2, 2024
183dff1
chore(component): implemented the rendering of the last item
alionazherdetska Dec 2, 2024
eae5391
chore(component): adjusted the implementation of checkConcatenation
alionazherdetska Dec 3, 2024
b01b65d
Merge branch 'main' into 3207-component_breadcrumb
alionazherdetska Dec 3, 2024
8a17215
chore(docs): added the documentation for breadrcumb
alionazherdetska Dec 3, 2024
fcd616c
chore(component): substituted the dropdown with post-menu component
alionazherdetska Dec 3, 2024
ad09b13
chore: autogenerated files
alionazherdetska Dec 3, 2024
f915a40
chore(styles): added new styles for the component
alionazherdetska Dec 3, 2024
0d902bb
chore(component): implemented render post-breadrumb-items inside the …
alionazherdetska Dec 3, 2024
a9a0877
chore(componnent): refactored the post-menu
alionazherdetska Dec 4, 2024
2fbdd93
chore(styles): removed default styles from a tag
alionazherdetska Dec 4, 2024
9ce3b8f
fix(styles): moved defining the focus styles from the host to the bre…
alionazherdetska Dec 4, 2024
6927c4c
chore(component): added the mutation observer to be able to change th…
alionazherdetska Dec 4, 2024
1d71fa4
chore(styles): added the styles for post-menu and focus styles
alionazherdetska Dec 4, 2024
d02acda
chore(readme): autigenerated one
alionazherdetska Dec 4, 2024
d1401b9
chore(styles): added the vorder-radius on focus for breadrumb-items
alionazherdetska Dec 5, 2024
1602a4c
chore(component): added `part` attribute to the <post-menu> component
alionazherdetska Dec 5, 2024
6a9aecd
chore(component): removed redundant logs
alionazherdetska Dec 5, 2024
ac93738
chore(styles): disabled pointer-events for the last breadrumb-item
alionazherdetska Dec 5, 2024
13ffcbb
chore: autogenerated file
alionazherdetska Dec 5, 2024
9936f57
feat: add keyboard navigation for breadcrumb item
alionazherdetska Dec 5, 2024
271b84f
fix(styles): improced the structure of the style file
alionazherdetska Dec 5, 2024
c011aba
chore(component): improved the structure of the code
alionazherdetska Dec 5, 2024
e1ca0ea
chore(styles): added missing tokens
alionazherdetska Dec 5, 2024
ccbfd49
chore(styles): added missing tokens
alionazherdetska Dec 5, 2024
6cfe335
chore(docs): removed redundant props from post breadrumb item stories
alionazherdetska Dec 5, 2024
dcfc23e
chore(tests): added snapshots for breadrumb
alionazherdetska Dec 5, 2024
9e7911a
chore(component): introduced componentWillLoad lifecyclehook
alionazherdetska Dec 6, 2024
61d23fc
fix(docs): avoided nested <p> tags in Storybook MDX documentation
alionazherdetska Dec 6, 2024
59f0634
chore(docs): updated the names of the stories
alionazherdetska Dec 6, 2024
1f17171
fix(lint): fixed the linting
alionazherdetska Dec 6, 2024
94b0080
fix(styles): removed duplicate
alionazherdetska Dec 6, 2024
8c25cdb
chore(snapshots): added snapshots to the stories
alionazherdetska Dec 6, 2024
46f9c8b
chore(breadrumb-item): excluded chevron from the breadrumb-item hover…
alionazherdetska Dec 8, 2024
9cf9262
chore(component): refactored concatenation to be more flexible
alionazherdetska Dec 8, 2024
141d839
chore: autogenerated files
alionazherdetska Dec 8, 2024
4f08283
chore(changeset): introduced a changeset
alionazherdetska Dec 8, 2024
1170ba0
fix(docs): reverted redundant to this PR changes
alionazherdetska Dec 8, 2024
b622c11
chore(icons): updated the home icon to the UI one
alionazherdetska Dec 8, 2024
63d2ff8
chore(validation): added the validation for home-url
alionazherdetska Dec 8, 2024
766c70d
chore(component): removed redundant console logs
alionazherdetska Dec 8, 2024
9438314
chore(component): added comments to the props
alionazherdetska Dec 8, 2024
f3c091c
chore(component): added export of component to index.tsx
alionazherdetska Dec 8, 2024
2d88656
Merge branch 'main' into 3207-component_breadcrumb
alionazherdetska Dec 9, 2024
02caaaf
chore(clean-up): deleted redundant comments and improved css style
alionazherdetska Dec 9, 2024
a0186cd
Merge branch '3207-component_breadcrumb' of https://github.com/swissp…
alionazherdetska Dec 9, 2024
57bccd6
chore: autogenerated files
alionazherdetska Dec 9, 2024
1a814c3
chore(fix): adjusted the styles of the breadrumb and breadcrumb-item
alionazherdetska Dec 9, 2024
51e7265
chore(styles): added the hover for the button
alionazherdetska Dec 9, 2024
d5a8c7e
fix(styles): adjusted focus-styles
alionazherdetska Dec 9, 2024
0ff21c9
chore(component): improved the code and styles
alionazherdetska Dec 9, 2024
1317e36
fix(styles): removed duplicate post-icon
alionazherdetska Dec 9, 2024
a373105
Merge branch 'main' into 3207-component_breadcrumb
alionazherdetska Dec 13, 2024
9188fb1
Merge branch 'main' into 3207-component_breadcrumb
alionazherdetska Dec 13, 2024
e227e8e
fix(styles): corrected typo
alionazherdetska Dec 13, 2024
ad58fd9
chore: autogenerated files
alionazherdetska Dec 13, 2024
071322c
Update packages/components/src/components/post-breadcrumb-item/post-b…
alionazherdetska Dec 13, 2024
39d7745
Update packages/components/src/components/post-breadcrumb-item/post-b…
alionazherdetska Dec 13, 2024
9d1db5d
fix(component): removed post-icon from the dropdown-menu
alionazherdetska Dec 13, 2024
8333ae3
fix(styles): removed nesting from scss
alionazherdetska Dec 13, 2024
c167a2b
Merge branch 'main' into 3207-component_breadcrumb
alionazherdetska Dec 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/real-gorillas-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@swisspost/design-system-documentation': minor
'@swisspost/design-system-components': minor
---

Added the `post-breadcrumb` component to provide a standalone breadcrumb navigation solution.
29 changes: 29 additions & 0 deletions packages/components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,16 @@ export namespace Components {
*/
"type": BannerType;
}
interface PostBreadcrumb {
/**
* The text label for the home breadcrumb item.
*/
"homeText": string;
/**
* The URL for the home breadcrumb item.
*/
"homeUrl": string;
}
interface PostBreadcrumbItem {
/**
* The optional URL to which the breadcrumb item will link.
Expand Down Expand Up @@ -529,6 +539,12 @@ declare global {
prototype: HTMLPostBannerElement;
new (): HTMLPostBannerElement;
};
interface HTMLPostBreadcrumbElement extends Components.PostBreadcrumb, HTMLStencilElement {
}
var HTMLPostBreadcrumbElement: {
prototype: HTMLPostBreadcrumbElement;
new (): HTMLPostBreadcrumbElement;
};
interface HTMLPostBreadcrumbItemElement extends Components.PostBreadcrumbItem, HTMLStencilElement {
}
var HTMLPostBreadcrumbItemElement: {
Expand Down Expand Up @@ -798,6 +814,7 @@ declare global {
"post-avatar": HTMLPostAvatarElement;
"post-back-to-top": HTMLPostBackToTopElement;
"post-banner": HTMLPostBannerElement;
"post-breadcrumb": HTMLPostBreadcrumbElement;
"post-breadcrumb-item": HTMLPostBreadcrumbItemElement;
"post-card-control": HTMLPostCardControlElement;
"post-closebutton": HTMLPostClosebuttonElement;
Expand Down Expand Up @@ -894,6 +911,16 @@ declare namespace LocalJSX {
*/
"type"?: BannerType;
}
interface PostBreadcrumb {
/**
* The text label for the home breadcrumb item.
*/
"homeText"?: string;
/**
* The URL for the home breadcrumb item.
*/
"homeUrl"?: string;
}
interface PostBreadcrumbItem {
/**
* The optional URL to which the breadcrumb item will link.
Expand Down Expand Up @@ -1194,6 +1221,7 @@ declare namespace LocalJSX {
"post-avatar": PostAvatar;
"post-back-to-top": PostBackToTop;
"post-banner": PostBanner;
"post-breadcrumb": PostBreadcrumb;
"post-breadcrumb-item": PostBreadcrumbItem;
"post-card-control": PostCardControl;
"post-closebutton": PostClosebutton;
Expand Down Expand Up @@ -1231,6 +1259,7 @@ declare module "@stencil/core" {
"post-avatar": LocalJSX.PostAvatar & JSXBase.HTMLAttributes<HTMLPostAvatarElement>;
"post-back-to-top": LocalJSX.PostBackToTop & JSXBase.HTMLAttributes<HTMLPostBackToTopElement>;
"post-banner": LocalJSX.PostBanner & JSXBase.HTMLAttributes<HTMLPostBannerElement>;
"post-breadcrumb": LocalJSX.PostBreadcrumb & JSXBase.HTMLAttributes<HTMLPostBreadcrumbElement>;
"post-breadcrumb-item": LocalJSX.PostBreadcrumbItem & JSXBase.HTMLAttributes<HTMLPostBreadcrumbItemElement>;
/**
* @class PostCardControl - representing a stencil component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,45 @@
@use '@swisspost/design-system-styles/mixins/media';
@use '@swisspost/design-system-styles/functions/tokens';
@use '@swisspost/design-system-styles/tokens/components';
@use '@swisspost/design-system-styles/tokens/helpers';
@use '@swisspost/design-system-styles/tokens/elements';
alionazherdetska marked this conversation as resolved.
Show resolved Hide resolved
@use '@swisspost/design-system-styles/mixins/utilities';

tokens.$default-map: components.$post-breadcrumb;

:host {
display: inline-block;
@include utilities.focus-style;
}

.breadcrumb-item {
display: inline-flex;
display: flex;
align-items: center;
justify-content: center;
padding-block: tokens.get('breadcrumb-padding-block-text');
justify-content: start;
gap: tokens.get('breadcrumb-gap-inline-inner');
color: tokens.get('breadcrumb-enabled-fg');
text-decoration: tokens.get('breadcrumb-link-enabled-text-decoration');

post-icon {
box-sizing: border-box;
height: tokens.get('breadcrum-icon-size');
width: tokens.get('breadcrum-icon-size');
padding-block: tokens.get('breadcrumb-padding-block-icon-link');
padding-inline: tokens.get('breadcrumb-padding-inline-icon-link');
}
}

.breadcrumb-item {
white-space: nowrap;
line-height: 150%;
padding-block: tokens.get('breadcrumb-padding-block-text');
font-size: tokens.get('body-font-size', elements.$post-body);
alionazherdetska marked this conversation as resolved.
Show resolved Hide resolved
color: tokens.get('breadcrumb-enabled-fg');
text-decoration: tokens.get('breadcrumb-link-enabled-text-decoration');
@include utilities.focus-style();

&:hover {
color: tokens.get('breadcrumb-hover-fg');
text-decoration: tokens.get('breadcrumb-link-hover-text-decoration');
}

&:focus-visible {
border-radius: tokens.get('focus-border-radius', helpers.$post-focus);
}

@include utilities.high-contrast-mode() {
&,
&:focus,
Expand Down
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

Breadcrumb items in the dropdown should not have a visible arrow.

Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,24 @@ export class PostBreadcrumbItem {
this.validateUrl();
}

private handleKeyDown(event: KeyboardEvent) {
if (event.key === 'Enter' || event.key === ' ') {
const linkElement = this.host.shadowRoot?.querySelector('a');
if (linkElement) {
event.preventDefault();
(linkElement as HTMLElement).click();
}
}
}

render() {
const BreadcrumbTag = this.validUrl ? 'a' : 'span';

return (
<Host data-version={version}>
<BreadcrumbTag class="breadcrumb-item" {...(this.validUrl ? { href: this.validUrl } : {})}>
<post-icon name="2111" class="breadcrumb-item-icon" />
<post-icon name="2111" class="breadcrumb-item-icon" />
<BreadcrumbTag class="breadcrumb-item" {...(this.validUrl ? { href: this.validUrl } : {})}
onKeyDown={(event) => this.handleKeyDown(event)}>
<slot></slot>
</BreadcrumbTag>
</Host>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@

## Dependencies

### Used by

- [post-breadcrumb](../post-breadcrumb)

### Depends on

- [post-icon](../post-icon)
Expand All @@ -29,6 +33,7 @@
```mermaid
graph TD;
post-breadcrumb-item --> post-icon
post-breadcrumb --> post-breadcrumb-item
style post-breadcrumb-item fill:#f9f,stroke:#333,stroke-width:4px
```

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
@use 'sass:map';
@use '@swisspost/design-system-styles/mixins/media';
@use '@swisspost/design-system-styles/functions/tokens';
@use '@swisspost/design-system-styles/tokens/components';
@use '@swisspost/design-system-styles/tokens/elements';
@use '@swisspost/design-system-styles/mixins/utilities';
@use '@swisspost/design-system-styles/core' as post;
@use '@swisspost/design-system-styles/tokens/helpers';

tokens.$default-map: components.$post-breadcrumb;

:host {
display: flex;
align-items: center;
}

.breadcrumbs-nav {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nesting all of these styles creates unnecessary specific selectors in CSS. Every level of nesting will add specificity to a selector: .breadcrumbs-nav .breadcrumbs-list li a etc.. Because we're in a shadow root, we don't need to be this specific.

Use nesting only if you need to make the selector more specific like ul > li needs the ul part to work.

display: flex;
align-items: center;

.hidden-items {
gap: tokens.get('breadcrumb-gap-inline-outer');
position: absolute;
height: 0;
overflow: hidden;
white-space: nowrap;
}

.breadcrumbs-list {
display: flex;
flex-wrap: nowrap;
position: relative;
margin: 0;
padding: 0;
list-style: none;
align-items: center;
height: 100%;
gap: tokens.get('breadcrumb-gap-inline-outer');

post-icon {
display: inline-block;
box-sizing: border-box;
color: tokens.get('breadcrumb-enabled-fg');
height: tokens.get('breadcrum-icon-size');
width: tokens.get('breadcrum-icon-size');
}

.breadcrumb-item-icon {
padding-block: tokens.get('breadcrumb-padding-block-icon-link');
padding-inline: tokens.get('breadcrumb-padding-inline-icon-link');
}

li {
a {
display: flex;
align-items: center;
@include utilities.focus-style;

&:focus {
border-radius: tokens.get('focus-border-radius', helpers.$post-focus);
}

.home-icon {
padding-block: tokens.get('breadcrumb-padding-block-icon-home');
padding-inline: tokens.get('breadcrumb-padding-inline-icon-home');

&:hover {
color: tokens.get('breadcrumb-hover-fg');
}

@include utilities.high-contrast-mode() {
a,
&:focus,
&:hover {
color: CanvasText !important;
}
}
}
}
}
.menu-trigger-wrapper {
display: flex;
align-items: center;
gap: tokens.get('breadcrumb-gap-inline-inner');

.actual-menu {
display: flex;
align-items: center;

post-menu-trigger {
display: flex;
align-items: center;
padding-block: tokens.get('breadcrumb-padding-block-text');
@include utilities.focus-style;

&:focus {
border-radius: tokens.get('focus-border-radius', helpers.$post-focus);
}

button {
background: none;
border: none;
line-height: 150%;
font-size: tokens.get('body-font-size', elements.$post-body);
cursor: pointer;
padding: 0;
color: tokens.get('breadcrumb-enabled-fg');

&:hover {
color: tokens.get('breadcrumb-hover-fg');
}

@include utilities.high-contrast-mode() {
a,
&:focus,
&:hover {
color: LinkText !important;
}
}
}
}

post-menu::part(popover-container) {
display: flex;
flex-direction: column;
align-items: start;
padding: 0.3rem;
gap: tokens.get('breadcrumb-gap-inline-outer');

::slotted(post-menu-item:not(:last-child)) {
margin-bottom: tokens.get('breadcrumb-gap-inline-outer');
}
}

.breadcrumb-item {
display: flex;
align-items: center;
justify-content: center;
gap: tokens.get('breadcrumb-gap-inline-inner');

a {
text-decoration: none;
color: inherit;
line-height: 150%;
padding-block: tokens.get('breadcrumb-padding-block-text');
font-size: tokens.get('body-font-size', elements.$post-body);
@include utilities.focus-style;

&:hover {
color: tokens.get('breadcrumb-hover-fg');
text-decoration: tokens.get('breadcrumb-link-hover-text-decoration');
}

&:focus-visible {
border-radius: tokens.get('focus-border-radius', helpers.$post-focus);
}
}

span {
&:hover {
color: tokens.get('breadcrumb-hover-fg');
text-decoration: tokens.get('breadcrumb-link-hover-text-decoration');
}

&:focus-visible {
border-radius: tokens.get('focus-border-radius', helpers.$post-focus);
}
}

@include utilities.high-contrast-mode() {
a,
&:focus,
&:hover {
color: LinkText !important;
}

&:visited {
color: VisitedText !important;
}
}
}
}
}

post-breadcrumb-item:last-of-type {
pointer-events: none;
color: tokens.get('breadcrumb-selected-fg');
font-weight: tokens.get('breadcrumb-selected-font-weight');
text-decoration: tokens.get('breadcrumb-link-selected-text-decoration');

&:hover {
color: tokens.get('breadcrumb-selected-fg');
text-decoration: none;
}
}

.visually-hidden {
@include post.visually-hidden();
}
}
}
Loading
Loading