Skip to content

Commit

Permalink
feat: configure text-underline offset to improve Arabic links
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbert committed Oct 14, 2021
1 parent ea8b376 commit 6d1c69a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
2 changes: 2 additions & 0 deletions components/link/bem.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
.utrecht-link {
color: var(--utrecht-link-color, blue);
text-decoration: var(--utrecht-link-text-decoration, underline);
text-decoration-skip-ink: all;
text-underline-offset: var(--utrecht-link-text-underline-offset);
}

.utrecht-link:visited,
Expand Down
18 changes: 18 additions & 0 deletions components/link/bem.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,21 @@ Styling via the `.utrecht-link--external` class name.
- `rel="noopener"` helps security: disable JavaScript contact via `window.opener` between the current page and the page you link to.
- `rel="noreferer"` helps privacy: normal links leak privacy sensitive data. The 3rd-party website you link to will find out what page you were on via the HTTP `Referer` header. Including `noreferer` disables the `Referer` header.
- Avoid using `target="_blank"` for external just because you don't want the visitor to leave your website, they can decide themselves to open a link in a new tab or window.

## Link in Arabic script

The underline of the link should not negatively impact the readability of the text, by crossing through any [Arabic diacritics](https://en.wikipedia.org/wiki/Arabic_diacritics). Configuring `text-decoration-skip-ink` in CSS can improve the default rendering of the underline by skipping over the diacritics.

<Canvas>
<Story
name="Arabic link"
args={{
href: "mailto:info@example.com",
textContent: "تواصل معنا من خلال البريد الإلكتروني",
mail: true,
}}
decorators={[(story) => `<div dir="rtl" lang="ar">${story()}</div>`]}
>
{Link.bind({})}
</Story>
</Canvas>
6 changes: 6 additions & 0 deletions components/link/block.tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
"syntax": "none | underline",
"inherits": true
}
},
"text-underline-offset": {
"css": {
"syntax": "<length>",
"inherits": true
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"utrecht": {
"link": {
"color": { "value": "{utrecht.color.blue.30.value}" },
"text-decoration": { "value": "underline" }
"text-decoration": { "value": "underline" },
"text-underline-offset": { "value": "3px" }
}
}
}

0 comments on commit 6d1c69a

Please sign in to comment.