-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 1242-component-menu-button
- Loading branch information
Showing
29 changed files
with
1,149 additions
and
311 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@swisspost/design-system-documentation': minor | ||
'@swisspost/design-system-styles': minor | ||
--- | ||
|
||
Updated vertical-align utility |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@swisspost/design-system-documentation': minor | ||
'@swisspost/design-system-styles': minor | ||
--- | ||
|
||
Added the skiplinks component to styles and documentation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
packages/components/src/components/post-breadcrumb-item/post-breadcrumb-item.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
packages/components/src/components/post-breadcrumb-item/post-breadcrumb-item.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
packages/components/src/components/post-breadcrumb-item/readme.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/)* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/documentation/cypress/e2e/components/skiplinks.cy.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
describe('Skiplinks', () => { | ||
beforeEach(() => { | ||
cy.visit('/iframe.html?id=snapshots--skiplinks'); | ||
cy.get('.skiplinks-container', { timeout: 30000 }).should('be.visible'); | ||
}); | ||
|
||
it('should take no space by default and be visible on focus', () => { | ||
cy.get('.skiplinks a[href="#navigation"]').should(el => { | ||
const clipValue = el.css('clip'); | ||
const width = el.width(); | ||
|
||
expect(clipValue).to.equal('rect(0px, 0px, 0px, 0px)'); | ||
expect(width).to.equal(0); | ||
}); | ||
cy.get('.skiplinks a[href="#navigation"]').focus(); | ||
cy.get('.skiplinks a[href="#navigation"]').should(el => { | ||
const clipValue = el.css('clip'); | ||
const width = el.width(); | ||
|
||
expect(clipValue).to.equal('auto'); | ||
expect(width).to.be.greaterThan(20); | ||
}); | ||
}); | ||
}); |
7 changes: 7 additions & 0 deletions
7
packages/documentation/cypress/snapshots/components/skiplinks.snapshot.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
describe('Skiplinks', () => { | ||
it('default', () => { | ||
cy.visit('/iframe.html?id=2fc3b456-19ba-4ede-b1bc-499518f829b1--default'); | ||
cy.get('.skiplinks-container', { timeout: 30000 }).should('be.visible'); | ||
cy.percySnapshot('Skiplinks', { widths: [1440] }); | ||
}); | ||
}); |
7 changes: 7 additions & 0 deletions
7
packages/documentation/cypress/snapshots/utilities/vertical-align.snapshot.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
describe('Vetical Align', () => { | ||
it('vertica-align', () => { | ||
cy.visit('/iframe.html?id=snapshots--vertical-align'); | ||
cy.get('.vertical-align-example', { timeout: 30000 }).should('be.visible'); | ||
cy.percySnapshot('Vertical Align', { widths: [1440] }); | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
packages/documentation/src/stories/components/skiplinks/skiplinks.docs.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Canvas, Controls, Meta } from '@storybook/blocks'; | ||
import * as Skiplinks from './skiplinks.stories.ts'; | ||
import StylesPackageImport from '@/shared/styles-package-import.mdx'; | ||
|
||
<Meta of={Skiplinks} /> | ||
|
||
<div className="docs-title"> | ||
# Skiplinks | ||
</div> | ||
|
||
<div className="lead"> | ||
People using keyboard, screen readers, switch controls and other assistive technologies use skip | ||
links to reach main content or other important sections easier and faster. | ||
</div> | ||
|
||
For the skiplinks to work, don't forget to add corresponding ID to the element that needs to be skipped to. | ||
|
||
<Canvas sourceState="shown" of={Skiplinks.Default} /> | ||
|
||
<StylesPackageImport components={['skiplinks']} /> |
18 changes: 18 additions & 0 deletions
18
packages/documentation/src/stories/components/skiplinks/skiplinks.snapshot.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import type { StoryObj } from '@storybook/web-components'; | ||
import meta, { renderSkiplinks } from './skiplinks.stories'; | ||
import { html } from 'lit'; | ||
|
||
const { id, ...metaWithoutId } = meta; | ||
|
||
export default { | ||
...metaWithoutId, | ||
title: 'Snapshots', | ||
}; | ||
|
||
type Story = StoryObj; | ||
|
||
export const Skiplinks: Story = { | ||
render: () => { | ||
return html`<div class="skiplinks-container">${renderSkiplinks()}</div> `; | ||
}, | ||
}; |
41 changes: 41 additions & 0 deletions
41
packages/documentation/src/stories/components/skiplinks/skiplinks.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import type { StoryObj } from '@storybook/web-components'; | ||
import { html } from 'lit/static-html.js'; | ||
import { MetaExtended } from '@root/types'; | ||
|
||
const meta: MetaExtended = { | ||
id: '2fc3b456-19ba-4ede-b1bc-499518f829b1', | ||
title: 'Components/Skiplinks', | ||
tags: ['package:HTML'], | ||
render: renderSkiplinks, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj; | ||
|
||
export function renderSkiplinks() { | ||
return html` | ||
<div class="skiplinks"> | ||
<a href="#navigation" target="_self">Navigation</a> | ||
<a href="#main-content" target="_self">Main</a> | ||
</div> | ||
<div id="navigation" role="navigation"> | ||
Navigation | ||
<ul> | ||
<li> | ||
<a href="#">Link</a> | ||
</li> | ||
</ul> | ||
</div> | ||
<div id="main-content" role="main" tabindex="-1"> | ||
Main content | ||
<ul> | ||
<li> | ||
<a href="#">Link</a> | ||
</li> | ||
</ul> | ||
</div> | ||
`; | ||
} | ||
|
||
export const Default: Story = {}; |
Oops, something went wrong.