generated from nl-design-system/example
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
130 additions
and
0 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,3 @@ | ||
# URL component | ||
|
||
Component to display URLs in a page. |
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,14 @@ | ||
/** | ||
* @license EUPL-1.2 | ||
* Copyright (c) 2021 Robbert Broersma | ||
*/ | ||
|
||
export const defaultArgs = { | ||
link: false, | ||
url: '', | ||
}; | ||
|
||
export const URLTemplate = ({ url = '', link = false }) => | ||
link | ||
? `<a class="utrecht-link utrecht-url" href="${url}" dir="ltr">${url}</a>` | ||
: `<span class="utrecht-url" dir="ltr">${url}</span>`; |
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,9 @@ | ||
/** | ||
* @license EUPL-1.2 | ||
* Copyright (c) 2021 Robbert Broersma | ||
* Copyright (c) 2021 Gemeente Utrecht | ||
*/ | ||
|
||
.utrecht-url { | ||
font-variant-ligatures: none; | ||
} |
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,103 @@ | ||
<!-- | ||
@license EUPL-1.2 | ||
Copyright (c) 2021 Robbert Broersma | ||
--> | ||
|
||
import { ArgsTable, Canvas, Meta, Story } from "@storybook/addon-docs"; | ||
import { defaultArgs, URLTemplate } from "./bem"; | ||
import "./bem.scss"; | ||
|
||
<Meta | ||
title="CSS Component/URL" | ||
argTypes={{ | ||
url: { | ||
description: "URL", | ||
control: "text", | ||
}, | ||
link: { | ||
description: "Link", | ||
control: "boolean", | ||
}, | ||
}} | ||
parameters={{ | ||
docs: { | ||
transformSource: (_src, { args }) => URLTemplate(args), | ||
}, | ||
percy: { skip: true }, | ||
status: { | ||
type: "WORK IN PROGRESS", | ||
}, | ||
}} | ||
/> | ||
|
||
# URL | ||
|
||
<Canvas> | ||
<Story | ||
args={{ | ||
...defaultArgs, | ||
link: true, | ||
url: "https://example.com/", | ||
}} | ||
name="URL" | ||
> | ||
{URLTemplate.bind({})} | ||
</Story> | ||
</Canvas> | ||
|
||
<ArgsTable story="URL" /> | ||
|
||
## URL with mixed left-to-right path | ||
|
||
When displaying an URL in HTML, explicitly mark the text directionality as left-to-right using `dir="ltr"`, to prevent trailing non-word characters such as `/` to be misplaced in a right-to-left document. A trailing slash might end up before `http:` when the URL is in right-to-left text such as Arabic. To maintain the correct rendering even in automated translations of a document, specifically mark URLs as `dir="ltr"` even when the document as a whole is already configured as such using `<html dir="ltr">`. | ||
|
||
<Canvas> | ||
<Story | ||
args={{ | ||
...defaultArgs, | ||
url: "https://example.com/الأمثلة/", | ||
}} | ||
name="URL with right-to-left path" | ||
parameters={{ | ||
percy: { skip: true }, | ||
}} | ||
> | ||
{URLTemplate.bind({})} | ||
</Story> | ||
</Canvas> | ||
|
||
## URL with mixed left-to-right top-level domain | ||
|
||
<Canvas> | ||
<Story | ||
args={{ | ||
...defaultArgs, | ||
url: "https://example.شبكة/", | ||
}} | ||
name="URL with right-to-left top-level domain" | ||
parameters={{ | ||
percy: { skip: true }, | ||
}} | ||
> | ||
{URLTemplate.bind({})} | ||
</Story> | ||
</Canvas> | ||
|
||
## URL with common ligatures in top-level-domain | ||
|
||
It can be helpful to avoid rendering characters together as a ligatures, such as displaying `fi` as `fi`. The CSS property [`font-variant-ligatures`](https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant-ligatures) can be used to disable ligatures. | ||
|
||
<Canvas> | ||
<Story | ||
args={{ | ||
...defaultArgs, | ||
url: "https://example.fi/", | ||
}} | ||
parameters={{ | ||
percy: { skip: false }, | ||
}} | ||
name="URL with common ligatures in top-level-domain" | ||
> | ||
{URLTemplate.bind({})} | ||
</Story> | ||
</Canvas> |
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