@utrecht/link-button-css 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.css ADDED
@@ -0,0 +1,204 @@
1
+ /**
2
+ * @license EUPL-1.2
3
+ * Copyright (c) 2022 Robbert Broersma
4
+ */
5
+ /**
6
+ * @license EUPL-1.2
7
+ * Copyright (c) 2022 Robbert Broersma
8
+ */
9
+ /**
10
+ * @license EUPL-1.2
11
+ * Copyright (c) 2021 The Knights Who Say NIH! B.V.
12
+ * Copyright (c) 2021 Gemeente Utrecht
13
+ */
14
+ /* stylelint-disable scss/no-global-function-names */
15
+ /**
16
+ * @license EUPL-1.2
17
+ * Copyright (c) 2021 Gemeente Utrecht
18
+ * Copyright (c) 2021 Robbert Broersma
19
+ */
20
+ /* stylelint-disable-next-line block-no-empty */
21
+ /*
22
+
23
+ # CSS implementation
24
+
25
+ ## `text-decoration-skip`
26
+
27
+ `text-decoration-skip` can be helpful to avoid making some texts unreadable.
28
+ For example by obscuring Arabic diacritics.
29
+
30
+ However, the combination of a greater thickness and skipping this thick underline
31
+ leads to a very unappealing rendering of the underline. To avoid this,
32
+ `text-decoration-skip` is disabled for interactive states.
33
+
34
+ For design token configurations that have identical thickness for normal and interactive
35
+ states, this will lead to the (undesirable) effect that the focus/hover effect is switching
36
+ from an interrupted to an uninterrupted underline (for some texts).
37
+
38
+ Apart from making `skip-ink` configurable for normal/focus/hover, there is no good solution yet.
39
+
40
+ ---
41
+
42
+ Disabling `text-decoration-skip` for interactive states obscures some texts, and we assume for now
43
+ that moving the pointer away from a link or having focus elsewhere first is simple enough to
44
+ not make this too inconvenient.
45
+
46
+ ---
47
+
48
+ Some folks implement the underline of links using `border-bottom` or even using a finely crafted
49
+ `linear-gradient()` with a solid color at the bottom and transparent behind the text. These approaches
50
+ would unfortunately not be able to provide the improved readability of `text-decoration-skip`.
51
+
52
+ ## `text-decoration-thickness`
53
+
54
+ Varying `text-decoration-thickness` can be used to distinguish interactive states.
55
+
56
+ ---
57
+
58
+ `text-decoration-thickness` appears to have rendering differences between Chrome and Safari.
59
+ In Safari the line becomes thicker with extra pixels added to the bottom, while in Chrome
60
+ the underline offset also seems to increase along with the thickness, which effectively means
61
+ the underline is closer to the next line than in Safari.
62
+
63
+ ---
64
+
65
+ It might be nice to use font-relative units for `text-decoration-thickness`, and that is why we
66
+ use the `max()` function to ensure the underline remains visible for every font size.
67
+
68
+ ## `transition`
69
+
70
+ `text-decoration-thickness` could be a candidate for animating between interactive states,
71
+ however browsers don't seem to have implemented great looking supixel tweening yet.
72
+
73
+ `text-decoration-skip` also makes the transition more challenging to implement.
74
+
75
+ */
76
+ /**
77
+ * Simulate forced-colors mode.
78
+ */
79
+ /* stylelint-disable-next-line block-no-empty */
80
+ /* stylelint-disable-next-line block-no-empty */
81
+ /* stylelint-disable-next-line block-no-empty */
82
+ /* stylelint-disable-next-line block-no-empty */
83
+ /**
84
+ * Link for elements such as `<img>` or `<article>`, that are not inline elements or plain text.
85
+ *
86
+ * Changing `display: inline` to `inline-block` ensures the focus outline is rendered around the entire box.
87
+ */
88
+ /**
89
+ * @license EUPL-1.2
90
+ * Copyright (c) 2021 Gemeente Utrecht
91
+ * Copyright (c) 2021 Robbert Broersma
92
+ */
93
+ /* stylelint-disable-next-line block-no-empty */
94
+ .utrecht-link-button {
95
+ --utrecht-icon-size: var(--utrecht-link-icon-size, 1em);
96
+ color: var(--_utrecht-link-state-color, var(--utrecht-link-color, var(--_utrecht-link-forced-colors-color)));
97
+ /* Only underline `<a href="...">...</a>`, which matches `a:any-link`.
98
+ * Do not underline `<a name="">Anchor</a>`.
99
+ */
100
+ --_utrecht-link-forced-colors-color: linktext;
101
+ text-decoration-color: var(--_utrecht-link-state-text-decoration-color, var(--utrecht-link-text-decoration-color, currentColor));
102
+ text-decoration-line: var(--_utrecht-link-state-text-decoration, var(--utrecht-link-text-decoration, underline));
103
+ text-decoration-skip-ink: all;
104
+ text-decoration-thickness: max(var(--_utrecht-link-state-text-decoration-thickness, var(--utrecht-link-text-decoration-thickness)), 1px);
105
+ text-underline-offset: var(--utrecht-link-text-underline-offset);
106
+ --utrecht-icon-size: var(--utrecht-button-icon-size, 1em);
107
+ align-items: center;
108
+ cursor: pointer;
109
+ display: inline-flex;
110
+ font-family: var(--utrecht-button-font-family, var(--utrecht-document-font-family));
111
+ font-size: var(--utrecht-button-font-size, var(--utrecht-document-font-family));
112
+ font-weight: var(--utrecht-button-font-weight);
113
+ gap: var(--utrecht-button-icon-gap);
114
+ inline-size: var(--utrecht-button-inline-size, auto);
115
+ justify-content: center;
116
+ line-height: inherit;
117
+ min-block-size: var(--utrecht-button-min-block-size, 44px);
118
+ min-inline-size: var(--utrecht-button-min-inline-size, 44px);
119
+ padding-block-end: var(--utrecht-button-padding-block-end);
120
+ padding-block-start: var(--utrecht-button-padding-block-start);
121
+ padding-inline-end: var(--utrecht-button-padding-inline-end);
122
+ padding-inline-start: var(--utrecht-button-padding-inline-start);
123
+ text-transform: var(--utrecht-button-text-transform);
124
+ -webkit-user-select: none;
125
+ user-select: none;
126
+ }
127
+
128
+ .utrecht-link-button--hover, .utrecht-link-button--html-button:not(:disabled):hover {
129
+ --_utrecht-link-forced-colors-color: linktext;
130
+ --_utrecht-link-state-color: var(--utrecht-link-hover-color);
131
+ --_utrecht-link-state-text-decoration: var(--utrecht-link-hover-text-decoration);
132
+ --_utrecht-link-state-text-decoration-thickness: var(--utrecht-link-hover-text-decoration-thickness);
133
+ text-decoration-skip: none;
134
+ text-decoration-skip-ink: none;
135
+ }
136
+
137
+ .utrecht-link-button--disabled {
138
+ --_utrecht-link-forced-colors-color: GrayText;
139
+ --_utrecht-link-state-color: var(--utrecht-link-placeholder-color);
140
+ cursor: var(--utrecht-action-disabled-cursor, not-allowed);
141
+ font-weight: var(--utrecht-link-placeholder-font-weight);
142
+ text-decoration-line: none;
143
+ }
144
+
145
+ .utrecht-link-button--focus, .utrecht-link-button--html-button:not(:disabled):focus {
146
+ --_utrecht-link-state-color: var(--utrecht-link-focus-color);
147
+ --_utrecht-link-state-text-decoration: var(--utrecht-link-focus-text-decoration);
148
+ --_utrecht-link-state-text-decoration-thickness: var(--utrecht-link-focus-text-decoration-thickness);
149
+ background-color: var(--utrecht-link-focus-background-color, transparent);
150
+ text-decoration-skip: none;
151
+ text-decoration-skip-ink: none;
152
+ }
153
+
154
+ .utrecht-link-button--focus-visible, .utrecht-link-button--html-button:focus-visible {
155
+ /*
156
+ * WCAG SC 2.4.12: Focus Not Obscured
157
+ * Use `z-index` to ensure the focus ring is stacked above adjecent elements with a `background`
158
+ */
159
+ /* - The browser default focus ring should apply when these CSS custom properties are not set.
160
+ * - Make the `box-shadow` value available, so components that have their own `box-shadow`
161
+ * can combine it with the focus ring box shadow.
162
+ */
163
+ --_utrecht-focus-ring-box-shadow: 0 0 0 var(--utrecht-focus-outline-width, 0)
164
+ var(--utrecht-focus-inverse-outline-color, transparent);
165
+ box-shadow: var(--_utrecht-focus-ring-box-shadow);
166
+ outline-color: var(--utrecht-focus-outline-color, revert);
167
+ outline-offset: var(--utrecht-focus-outline-offset, revert);
168
+ outline-style: var(--utrecht-focus-outline-style, revert);
169
+ outline-width: var(--utrecht-focus-outline-width, revert);
170
+ z-index: var(--utrecht-stack-focus-z-index, 1);
171
+ }
172
+
173
+ .utrecht-link-button--active, .utrecht-link-button--html-button:not(:disabled):active {
174
+ --_utrecht-link-forced-colors-color: activetext;
175
+ --_utrecht-link-state-color: var(--utrecht-link-active-color);
176
+ }
177
+
178
+ .utrecht-link-button--inline {
179
+ --utrecht-icon-inset-block-start: var(--utrecht-icon-baseline-inset-block-start);
180
+ min-block-size: auto;
181
+ min-inline-size: auto;
182
+ padding-block-end: 0;
183
+ padding-block-start: 0;
184
+ padding-inline-end: 0;
185
+ padding-inline-start: 0;
186
+ }
187
+
188
+ .utrecht-link-button--pressed {
189
+ /* Copy `active` styles for now.
190
+ Later we can decide to:
191
+ - merge `active` and `pressed` and name the state `pressed`, or:
192
+ - merge `active` and `pressed` and name the state `active`, or:
193
+ - style `pressed` like the link state `current`, or:
194
+ - add `pressed` design tokens
195
+ */
196
+ --_utrecht-link-forced-colors-color: activetext;
197
+ --_utrecht-link-state-color: var(--utrecht-link-active-color);
198
+ }
199
+
200
+ .utrecht-link-button--html-button {
201
+ background-color: transparent;
202
+ /* reset <button> styling */
203
+ border-width: 0;
204
+ }
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ var undefined$1 = undefined;export{undefined$1 as default};
package/package.json CHANGED
@@ -1,18 +1,27 @@
1
1
  {
2
- "version": "1.0.0",
2
+ "version": "1.1.0",
3
3
  "author": "Community for NL Design System",
4
4
  "description": "Link button component for the Municipality of Utrecht based on the NL Design System architecture",
5
5
  "license": "EUPL-1.2",
6
6
  "name": "@utrecht/link-button-css",
7
7
  "files": [
8
- "dist/"
8
+ "dist/",
9
+ "src/"
9
10
  ],
10
- "devDependencies": {},
11
+ "main": "dist/index.css",
12
+ "devDependencies": {
13
+ "rollup": "3.29.4",
14
+ "@utrecht/focus-ring-css": "1.1.0",
15
+ "@utrecht/link-css": "1.1.0"
16
+ },
11
17
  "keywords": [
12
18
  "nl-design-system"
13
19
  ],
14
20
  "publishConfig": {
15
21
  "access": "public"
16
22
  },
17
- "scripts": {}
23
+ "scripts": {
24
+ "build": "rollup -c ../rollup.config.mjs",
25
+ "clean": "rimraf dist"
26
+ }
18
27
  }
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @license EUPL-1.2
3
+ * Copyright (c) 2022 Robbert Broersma
4
+ */
5
+
6
+ @import "~@utrecht/link-css/src/mixin";
7
+ @import "~@utrecht/focus-ring-css/src/mixin";
8
+
9
+ @mixin utrecht-link-button {
10
+ @include utrecht-link;
11
+ @include utrecht-link--any-link;
12
+
13
+ --utrecht-icon-size: var(--utrecht-button-icon-size, 1em);
14
+
15
+ align-items: center;
16
+ cursor: pointer;
17
+ display: inline-flex;
18
+ font-family: var(--utrecht-button-font-family, var(--utrecht-document-font-family));
19
+ font-size: var(--utrecht-button-font-size, var(--utrecht-document-font-family));
20
+ font-weight: var(--utrecht-button-font-weight);
21
+ gap: var(--utrecht-button-icon-gap);
22
+ inline-size: var(--utrecht-button-inline-size, auto);
23
+ justify-content: center;
24
+ line-height: inherit;
25
+ min-block-size: var(--utrecht-button-min-block-size, 44px);
26
+ min-inline-size: var(--utrecht-button-min-inline-size, 44px);
27
+ padding-block-end: var(--utrecht-button-padding-block-end);
28
+ padding-block-start: var(--utrecht-button-padding-block-start);
29
+ padding-inline-end: var(--utrecht-button-padding-inline-end);
30
+ padding-inline-start: var(--utrecht-button-padding-inline-start);
31
+ text-transform: var(--utrecht-button-text-transform);
32
+ -webkit-user-select: none;
33
+ user-select: none;
34
+ }
35
+
36
+ @mixin utrecht-link-button--html-button {
37
+ background-color: transparent;
38
+
39
+ /* reset <button> styling */
40
+ border-width: 0;
41
+ }
42
+
43
+ @mixin utrecht-link-button--pressed {
44
+ /* Copy `active` styles for now.
45
+ Later we can decide to:
46
+ - merge `active` and `pressed` and name the state `pressed`, or:
47
+ - merge `active` and `pressed` and name the state `active`, or:
48
+ - style `pressed` like the link state `current`, or:
49
+ - add `pressed` design tokens
50
+ */
51
+ @include utrecht-link--active;
52
+ }
53
+
54
+ @mixin utrecht-link-button--hover {
55
+ @include utrecht-link--hover;
56
+ }
57
+
58
+ @mixin utrecht-link-button--active {
59
+ @include utrecht-link--active;
60
+ }
61
+
62
+ @mixin utrecht-link-button--disabled {
63
+ @include utrecht-link--placeholder;
64
+ }
65
+
66
+ @mixin utrecht-link-button--focus {
67
+ @include utrecht-link--focus;
68
+ }
69
+
70
+ @mixin utrecht-link-button--focus-visible {
71
+ @include utrecht-link--focus-visible;
72
+ }
73
+
74
+ @mixin utrecht-link-button--inline {
75
+ --utrecht-icon-inset-block-start: var(--utrecht-icon-baseline-inset-block-start);
76
+
77
+ min-block-size: auto;
78
+ min-inline-size: auto;
79
+ padding-block-end: 0;
80
+ padding-block-start: 0;
81
+ padding-inline-end: 0;
82
+ padding-inline-start: 0;
83
+ }
package/src/index.scss ADDED
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @license EUPL-1.2
3
+ * Copyright (c) 2022 Robbert Broersma
4
+ */
5
+
6
+ @import "./mixin";
7
+
8
+ .utrecht-link-button {
9
+ @include utrecht-link-button;
10
+ }
11
+
12
+ .utrecht-link-button--hover {
13
+ @include utrecht-link-button--hover;
14
+ }
15
+
16
+ .utrecht-link-button--disabled {
17
+ @include utrecht-link-button--disabled;
18
+ }
19
+
20
+ .utrecht-link-button--focus {
21
+ @include utrecht-link-button--focus;
22
+ }
23
+
24
+ .utrecht-link-button--focus-visible {
25
+ @include utrecht-link-button--focus-visible;
26
+ }
27
+
28
+ .utrecht-link-button--active {
29
+ @include utrecht-link-button--active;
30
+ }
31
+
32
+ .utrecht-link-button--inline {
33
+ @include utrecht-link-button--inline;
34
+ }
35
+
36
+ .utrecht-link-button--pressed {
37
+ @include utrecht-link-button--pressed;
38
+ }
39
+
40
+ .utrecht-link-button--html-button {
41
+ @include utrecht-link-button--html-button;
42
+
43
+ &:focus-visible {
44
+ @extend .utrecht-link-button--focus-visible;
45
+ }
46
+
47
+ &:not(:disabled):hover {
48
+ @extend .utrecht-link-button--hover;
49
+ }
50
+
51
+ &:not(:disabled):focus {
52
+ @extend .utrecht-link-button--focus;
53
+ }
54
+
55
+ &:not(:disabled):active {
56
+ @extend .utrecht-link-button--active;
57
+ }
58
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "utrecht": {
3
+ "link-button": {}
4
+ }
5
+ }