-
Notifications
You must be signed in to change notification settings - Fork 14
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(styles): tokenize the Link component styles #3590
Merged
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
3c4889c
chore(style): delete the initial link styles
735e706
feat(token): text-link token was implemented
441368e
feat(token): import link.scss to the _index.scss
11d7d5e
fix(style): remove unnecessary mixin usage for the link
9b39668
Merge branch 'main' into 3424-component-text-link
a570b13
chore(docs): implement the documentation for the link component
6990166
chore(changeset): implement a changeset
53ebf2a
Merge branch 'main' into 3424-component-text-link
120da6f
feat(styles): use focus-style mixin for link focus
4466e46
fix(import): Eliminate the import of the styles
7227e98
Merge branch 'main' into 3424-component-text-link
gfellerph 41666ee
chore(styles): remove redundant &:focus selector
cda79ca
chore(docs): add random UUID to the link stories
52676e6
fix(changeset): adjust the changeset statement
0164e0d
chore(snapshot): create the LinkSnapshot
3f2f547
fix(docs): remove redundant info
6e0d6fb
fix(docs): set data-color-mode attribute in link snapshot stories
0cb8fcd
fix(styles): update high-contrast mode link styling
0d2a377
fix(styles): adjust the style for the visited state in the high-contr…
361f044
chore(styles): refine the Link styles in high-contrast mode
46f0ca1
Update .changeset/lazy-gorillas-admire.md
alionazherdetska 8b5e12f
Merge branch '3424-component-text-link' of https://github.com/swisspo…
8778447
Merge branch 'main' into 3424-component-text-link
3012ac7
Merge branch 'main' into 3424-component-text-link
oliverschuerch f9aab11
Merge branch '3424-component-text-link' of https://github.com/swisspo…
5206224
chore(docs): move link element to Typography category
1d74aae
fix(style): change the hover effect on high contrast mode as in W3C
c079a2c
Delete .idea/indexLayout.xml
alionazherdetska 6f6100c
Merge branch 'main' into 3424-component-text-link
c917caf
chore(component): link component was renamed to anchor, token assignm…
cc21ca3
Update packages/styles/src/elements/anchor.scss
alionazherdetska 76eb978
fix(linting): redundant coma was removed
2106fd1
chore: relocated the component to "Foundations/Typography/Link"
531b418
Merge branch 'main' into 3424-component-text-link
alionazherdetska File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-styles': minor | ||
'@swisspost/design-system-documentation': minor | ||
--- | ||
|
||
Updated the Link component styles to align with the new design, added a documentation page outlining the usage of the component. |
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
7 changes: 7 additions & 0 deletions
7
packages/documentation/cypress/snapshots/components/link.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('Link', () => { | ||
it('default', () => { | ||
cy.visit('/iframe.html?id=snapshots--link'); | ||
cy.get('a', { timeout: 30000 }).should('be.visible'); | ||
cy.percySnapshot('Links', { widths: [400] }); | ||
}); | ||
}); |
21 changes: 21 additions & 0 deletions
21
packages/documentation/src/stories/components/link/link.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,21 @@ | ||
import { Canvas, Controls, Meta } from '@storybook/blocks'; | ||
import * as LinkStories from './link.stories'; | ||
import StylesPackageImport from '@/shared/styles-package-import.mdx'; | ||
|
||
<Meta of={LinkStories} /> | ||
|
||
<div className="docs-title"> | ||
# Link | ||
|
||
<nav> | ||
<link-design of={JSON.stringify(LinkStories)}></link-design> | ||
</nav> | ||
</div> | ||
<div className="lead"> | ||
Use links to navigate users to another location, such as a different site, resource, or section within the same page. | ||
</div> | ||
|
||
<Canvas sourceState="shown" of={LinkStories.Default} /> | ||
<div className="hide-col-default"> | ||
<Controls of={LinkStories.Default} /> | ||
</div> |
40 changes: 40 additions & 0 deletions
40
packages/documentation/src/stories/components/link/link.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,40 @@ | ||
import type { Args, StoryContext, StoryObj } from '@storybook/web-components'; | ||
import meta, { Default } from './link.stories'; | ||
import { html } from 'lit'; | ||
import { bombArgs } from '@/utils'; | ||
|
||
const { id, ...metaWithoutId } = meta; | ||
|
||
export default { | ||
...metaWithoutId, | ||
title: 'Snapshots', | ||
}; | ||
|
||
type Story = StoryObj; | ||
|
||
export const Link: Story = { | ||
render: (_args: Args, context: StoryContext) => { | ||
return html` | ||
<div> | ||
${['bg-white', 'bg-dark'].map( | ||
bg => html` | ||
<div | ||
class="${bg} d-flex flex-column gap-regular p-regular mt-regular" | ||
data-color-mode="${bg === 'bg-white' ? 'light' : 'dark'}" | ||
> | ||
${bombArgs({ | ||
text: ['Link Text', 'Lorem ipsum dolor sit amet consectetur'], | ||
href: ['https://example.com', 'https://imgur.com/FKmX7dt'], | ||
}).map((args: Args) => | ||
Default.render?.( | ||
{ ...context.args, ...args, text: `${args.text}`, href: `${args.href}` }, | ||
context, | ||
), | ||
)} | ||
</div> | ||
`, | ||
)} | ||
</div> | ||
`; | ||
}, | ||
}; |
52 changes: 52 additions & 0 deletions
52
packages/documentation/src/stories/components/link/link.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,52 @@ | ||
import type { Args, StoryObj } from '@storybook/web-components'; | ||
import { html } from 'lit/static-html.js'; | ||
import { MetaComponent } from '@root/types'; | ||
|
||
const meta: MetaComponent = { | ||
id: '6f359d06-bca5-4983-b588-c8c790531642', | ||
title: 'Foundations/Typography/Link', | ||
tags: ['package:HTML'], | ||
parameters: { | ||
badges: [], | ||
design: { | ||
type: 'figma', | ||
url: 'https://www.figma.com/design/JIT5AdGYqv6bDRpfBPV8XR/Foundations-%26-Components-Next-Level?node-id=2016-47948', | ||
}, | ||
}, | ||
args: { | ||
text: 'Link Text', | ||
href: 'https://imgur.com/FKmX7dt', | ||
}, | ||
argTypes: { | ||
text: { | ||
name: 'Text', | ||
description: 'Defines the text within the link.', | ||
control: { | ||
type: 'text', | ||
}, | ||
table: { | ||
category: 'General', | ||
}, | ||
}, | ||
href: { | ||
name: 'Href', | ||
description: 'Defines the target URL for the link.', | ||
control: { | ||
type: 'text', | ||
}, | ||
table: { | ||
category: 'General', | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj; | ||
|
||
export const Default: Story = { | ||
render: (args: Args) => { | ||
return html` <a href="${args.href}">${args.text}</a> `; | ||
}, | ||
}; |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
@use 'reset'; | ||
@use 'body'; | ||
@use 'anchor'; | ||
@use 'paragraph'; | ||
@use 'heading'; | ||
@use 'fieldset-legend'; |
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 @@ | ||
@use '../functions/tokens'; | ||
@use '../tokens/elements'; | ||
@use '../mixins/utilities'; | ||
|
||
tokens.$default-map: elements.$post-link; | ||
|
||
a { | ||
text-decoration: tokens.get('link-decoration'); | ||
border-radius: tokens.get('link-border-radius'); | ||
color: inherit; | ||
|
||
&:hover { | ||
color: tokens.get('link-hover-fg'); | ||
} | ||
|
||
@include utilities.focus-style( | ||
$offset: tokens.get('link-focus-outline-offset'), | ||
$width: tokens.get('link-focus-outline-width'), | ||
$color: tokens.get('link-focus-outline-color'), | ||
$style: tokens.get('link-focus-outline-style') | ||
); | ||
|
||
@include utilities.high-contrast-mode() { | ||
&, | ||
&:focus { | ||
color: LinkText !important; | ||
} | ||
|
||
&:hover { | ||
text-decoration-thickness: 2px; | ||
} | ||
|
||
&:visited { | ||
color: VisitedText; | ||
} | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you create a new snapshot file you also need to create the matching visual regression test here: https://github.com/swisspost/design-system/tree/main/packages/documentation/cypress/snapshots/components
*.snapshot.stories.ts
file creates this page: https://preview-3590--swisspost-design-system-next.netlify.app/iframe.html?id=snapshots--link&viewMode=storycypress/*.snapshot.ts
files uses this page to take snapshots that are compared every time we release changes