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(components): create the post-breadcrumb-item #3659

Merged
merged 37 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
0d8afc5
feat(component): implemented the initial layout of the breadcrumb-ite…
Oct 3, 2024
4e05d2e
chore(styles): added basic styles
Oct 3, 2024
a5ac920
chore(styles): added focus/hover states
Oct 3, 2024
faefad9
chore(component): autogenerated files for BreadcrumbItem component we…
Oct 3, 2024
e936173
Merge branch 'main' into 3277-component-breadcrumb-item
Oct 4, 2024
179c486
chore(styles): remove redundant breadcrumb-item styles
Oct 4, 2024
2cc54b8
Merge branch 'main' into 3277-component-breadcrumb-item
Oct 4, 2024
9355a72
chore(styles): Link styles for high-contrast mode were added
Oct 4, 2024
af86bf4
fix(styles): refine breadcrumb focus styles
Oct 4, 2024
4d53205
chore(component): export `post-breadcrumb-item` in index.ts
Oct 4, 2024
2836c6b
fix(import): remove redundant import
Oct 7, 2024
bf6ee06
fix(commit): revert last commit
Oct 7, 2024
4a8250d
Merge branch 'main' into 3277-component-breadcrumb-item
Oct 7, 2024
953cd75
Merge branch 'main' into 3277-component-breadcrumb-item
Oct 16, 2024
9e4f696
chore(tokens): the prefix post was eliminated for token usages in app…
Oct 16, 2024
5825177
fix(prop): the prop url was changed to optional
Oct 16, 2024
b7b9956
fix(checkUrl): checkUrl function was updated
Oct 16, 2024
3e1cd77
chore(changeset): the changeset for creating post-breadcrumb-item was…
Oct 16, 2024
e39dd76
fix(prop): url property wes refactored to optional for the post-bread…
Oct 16, 2024
937bead
chore(styles): styles for post-breadcrumb-item were refactored
Oct 16, 2024
be1ecbd
Merge branch 'main' into 3277-component-breadcrumb-item
Oct 18, 2024
8f5ed1b
Merge branch 'main' into 3277-component-breadcrumb-item
alionazherdetska Oct 29, 2024
c03d0aa
fix(component.d.ts): missing semi-colon was added
Oct 29, 2024
0b0fb2d
fix(component.d.ts): missing semi colons were added
Oct 29, 2024
a1cd858
fix(assertion): unnecessary assertion was removed
Oct 29, 2024
e8ab78f
fix(function): checkUrl function was refactored to the initial state
Oct 29, 2024
a013f53
chore: the file refactored automatically to list interfaces alphabeti…
Oct 29, 2024
0995fef
Update .changeset/proud-cheetahs-act.md
alionazherdetska Oct 29, 2024
e503834
chore(component): added `constructUrl` helper function to handle URL …
Oct 29, 2024
3e50b18
Merge branch '3277-component-breadcrumb-item' of https://github.com/s…
Oct 29, 2024
19a1c1d
Merge branch 'main' into 3277-component-breadcrumb-item
Oct 30, 2024
4d054a3
chore(component): constructing the absolute path out of relative was …
Oct 30, 2024
2679324
Merge branch 'main' into 3277-component-breadcrumb-item
Nov 4, 2024
826cd2f
chore(styles): applying focus styles of post-breadcrumb-item was refa…
Nov 4, 2024
9e9bdf8
fix(functions): checkurl was substituted with checkEmtyorUrl
Nov 4, 2024
d7bf7b5
fix(lint): linting file was fixed
Nov 4, 2024
8b30c84
fix(redundant): removed redundant
alionazherdetska Nov 11, 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/proud-cheetahs-act.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@swisspost/design-system-components': major
'@swisspost/design-system-styles': major
---

Removed the `.breadcrumb-item` class, which previously handled styling for breadcrumb items. Introduced a new `post-breadcrumb-item` that should be used in place of the `.breadcrumb-item` class.
21 changes: 21 additions & 0 deletions packages/components/src/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ export namespace Components {
*/
"userid"?: string;
}
interface PostBreadcrumbItem {
/**
* The optional URL to which the breadcrumb item will link.
*/
"url"?: string | URL;
}
/**
* @class PostCardControl - representing a stencil component
*/
Expand Down Expand Up @@ -430,6 +436,12 @@ declare global {
prototype: HTMLPostAvatarElement;
new (): HTMLPostAvatarElement;
};
interface HTMLPostBreadcrumbItemElement extends Components.PostBreadcrumbItem, HTMLStencilElement {
}
var HTMLPostBreadcrumbItemElement: {
prototype: HTMLPostBreadcrumbItemElement;
new (): HTMLPostBreadcrumbItemElement;
};
interface HTMLPostCardControlElementEventMap {
"postInput": { state: boolean; value: string };
"postChange": { state: boolean; value: string };
Expand Down Expand Up @@ -593,6 +605,7 @@ declare global {
"post-accordion-item": HTMLPostAccordionItemElement;
"post-alert": HTMLPostAlertElement;
"post-avatar": HTMLPostAvatarElement;
"post-breadcrumb-item": HTMLPostBreadcrumbItemElement;
"post-card-control": HTMLPostCardControlElement;
"post-collapsible": HTMLPostCollapsibleElement;
"post-collapsible-trigger": HTMLPostCollapsibleTriggerElement;
Expand Down Expand Up @@ -675,6 +688,12 @@ declare namespace LocalJSX {
*/
"userid"?: string;
}
interface PostBreadcrumbItem {
/**
* The optional URL to which the breadcrumb item will link.
*/
"url"?: string | URL;
}
/**
* @class PostCardControl - representing a stencil component
*/
Expand Down Expand Up @@ -914,6 +933,7 @@ declare namespace LocalJSX {
"post-accordion-item": PostAccordionItem;
"post-alert": PostAlert;
"post-avatar": PostAvatar;
"post-breadcrumb-item": PostBreadcrumbItem;
"post-card-control": PostCardControl;
"post-collapsible": PostCollapsible;
"post-collapsible-trigger": PostCollapsibleTrigger;
Expand All @@ -938,6 +958,7 @@ declare module "@stencil/core" {
"post-accordion-item": LocalJSX.PostAccordionItem & JSXBase.HTMLAttributes<HTMLPostAccordionItemElement>;
"post-alert": LocalJSX.PostAlert & JSXBase.HTMLAttributes<HTMLPostAlertElement>;
"post-avatar": LocalJSX.PostAvatar & JSXBase.HTMLAttributes<HTMLPostAvatarElement>;
"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
@@ -0,0 +1,44 @@
@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/mixins/utilities';

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

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

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

post-icon {
height: tokens.get('breadcrum-icon-size');
width: tokens.get('breadcrum-icon-size');
}

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

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

&:visited {
color: VisitedText !important;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { Component, Element, h, Host, Prop, Watch } from '@stencil/core';
import { version } from '@root/package.json';
import { checkEmptyOrUrl } from '@/utils';

/**
* @slot default - Slot for placing the text inside the breadcrumb item.
*/
@Component({
tag: 'post-breadcrumb-item',
styleUrl: 'post-breadcrumb-item.scss',
shadow: true,
})
export class PostBreadcrumbItem {
@Element() host: HTMLPostBreadcrumbItemElement;

/**
* The optional URL to which the breadcrumb item will link.
*/
@Prop() url?: string | URL;

private validUrl?: string;

@Watch('url')
validateUrl() {
try {
this.validUrl = this.constructUrl(this.url);
} catch (error) {
this.validUrl = undefined;
}
}

// Helper to construct a valid URL string or return undefined
private constructUrl(value: unknown): string | undefined {
const hasBaseURL = /^https?:\/\//.test(String(this.url));
if (typeof value === 'string') {
const urlString = hasBaseURL
? value
: `${window.location.origin}${value}`;
checkEmptyOrUrl(urlString, 'The "url" property of the post-breadcrumb-item is invalid');
return urlString;
} return undefined;
}

connectedCallback() {
this.validateUrl();
}

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" />
<slot></slot>
</BreadcrumbTag>
</Host>
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# post-breadcrumb-item



<!-- Auto Generated Below -->


## Properties

| Property | Attribute | Description | Type | Default |
| -------- | --------- | -------------------------------------------------------- | --------------- | ----------- |
| `url` | `url` | The optional URL to which the breadcrumb item will link. | `URL \| string` | `undefined` |


## Slots

| Slot | Description |
| ----------- | ----------------------------------------------------- |
| `"default"` | Slot for placing the text inside the breadcrumb item. |


## Dependencies

### Depends on

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

### Graph
```mermaid
graph TD;
post-breadcrumb-item --> post-icon
style post-breadcrumb-item fill:#f9f,stroke:#333,stroke-width:4px
```

----------------------------------------------

*Built with [StencilJS](https://stenciljs.com/)*
2 changes: 2 additions & 0 deletions packages/components/src/components/post-icon/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ some content
### Used by

- [post-alert](../post-alert)
- [post-breadcrumb-item](../post-breadcrumb-item)
- [post-card-control](../post-card-control)
- [post-rating](../post-rating)
- [post-tag](../post-tag)
Expand All @@ -31,6 +32,7 @@ some content
```mermaid
graph TD;
post-alert --> post-icon
post-breadcrumb-item --> post-icon
post-card-control --> post-icon
post-rating --> post-icon
post-tag --> post-icon
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export { Components, JSX } from './components';
export { PostAccordion } from './components/post-accordion/post-accordion';
export { PostAccordionItem } from './components/post-accordion-item/post-accordion-item';
export { PostAlert } from './components/post-alert/post-alert';
export { PostBreadcrumbItem } from './components/post-breadcrumb-item/post-breadcrumb-item';
export { PostAvatar } from './components/post-avatar/post-avatar';
export { PostCardControl } from './components/post-card-control/post-card-control';
export { PostCollapsible } from './components/post-collapsible/post-collapsible';
Expand Down
21 changes: 0 additions & 21 deletions packages/styles/src/components/breadcrumb.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,3 @@
font-weight: type.$font-weight-normal;
white-space: nowrap;
}

.breadcrumb-item {
alionazherdetska marked this conversation as resolved.
Show resolved Hide resolved
display: flex;
align-items: center;

.ppm-breadcrumb-divider {
fill: breadcrumbs.$breadcrumb-divider-color;
}

a {
display: flex;
align-content: center;
align-items: center;
color: breadcrumbs.$breadcrumb-link-color;
text-decoration: none;

&:hover {
color: breadcrumbs.$breadcrumb-hover-color;
}
}
}