@bonniernews/dn-design-system-web 1.0.0-alpha.2 → 1.0.0-alpha.20
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/CHANGELOG.md +158 -0
- package/assets/form-field/form-field.njk +6 -4
- package/assets/form-field/form-field.scss +1 -0
- package/components/badge/badge.scss +1 -1
- package/components/button/README.md +2 -2
- package/components/button/button.njk +27 -8
- package/components/button/button.scss +134 -58
- package/components/button-toggle/README.md +54 -0
- package/components/button-toggle/button-toggle.js +9 -0
- package/components/button-toggle/button-toggle.njk +63 -0
- package/components/button-toggle/button-toggle.scss +219 -0
- package/components/checkbox/README.md +1 -0
- package/components/checkbox/checkbox.njk +13 -18
- package/components/checkbox/checkbox.scss +26 -34
- package/components/divider/divider.njk +1 -3
- package/components/divider/divider.scss +5 -9
- package/components/icon-button/README.md +2 -2
- package/components/icon-button/icon-button.njk +11 -0
- package/components/icon-button/icon-button.scss +21 -3
- package/components/list-item/README-accordion.md +0 -1
- package/components/list-item/README-checkbox.md +0 -1
- package/components/list-item/README-radio.md +0 -1
- package/components/list-item/README-switch.md +0 -1
- package/components/list-item/README.md +0 -1
- package/components/list-item/list-item.njk +2 -7
- package/components/list-item/list-item.scss +1 -10
- package/components/radio-button/README.md +12 -8
- package/components/radio-button/radio-button.njk +34 -32
- package/components/radio-button/radio-button.scss +33 -12
- package/components/spinner/README.md +36 -0
- package/components/spinner/spinner.njk +33 -0
- package/components/spinner/spinner.scss +143 -0
- package/components/text-button/README.md +1 -1
- package/components/text-button/text-button.njk +21 -2
- package/components/text-button/text-button.scss +8 -3
- package/components/text-button-toggle/README.md +50 -0
- package/components/text-button-toggle/text-button-toggle.js +9 -0
- package/components/text-button-toggle/text-button-toggle.njk +51 -0
- package/components/text-button-toggle/text-button-toggle.scss +131 -0
- package/foundations/base.scss +1 -0
- package/foundations/helpers/README-links.md +23 -0
- package/foundations/helpers/links.scss +27 -0
- package/foundations/helpers/loading.scss +21 -0
- package/foundations/helpers/shadows.scss +45 -0
- package/foundations/helpers/typography.scss +9 -6
- package/foundations/shadows.scss +22 -0
- package/foundations/typography/fonts.scss +310 -0
- package/foundations/variables/colorsDnDarkTokens.scss +11 -7
- package/foundations/variables/colorsDnLightTokens.scss +5 -1
- package/foundations/variables/colorsTokensList.scss +4 -0
- package/foundations/variables/decorations.scss +1 -0
- package/foundations/variables/shadowsDnDarkTokens.scss +10 -0
- package/foundations/variables/shadowsDnLightTokens.scss +10 -0
- package/foundations/variables/shadowsTokensList.scss +1 -0
- package/foundations/variables/spacingLayout.scss +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,164 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 1.0.0-alpha.20 (2023-01-13)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **web:** helper for link styling ([#563](https://github.com/BonnierNews/dn-design-system/issues/563)) ([0895152](https://github.com/BonnierNews/dn-design-system/commit/0895152a9f9aa1e23b6ff9fbbea2a87f1f62f1eb))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## 1.0.0-alpha.19 (2023-01-12)
|
|
16
|
+
|
|
17
|
+
**Note:** Version bump only for package @bonniernews/dn-design-system-web
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
## [1.0.0-alpha.18](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@1.0.0-alpha.17...@bonniernews/dn-design-system-web@1.0.0-alpha.18) (2023-01-12)
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
### Bug Fixes
|
|
27
|
+
|
|
28
|
+
* **web:** adjust font weight for variable font ([#551](https://github.com/BonnierNews/dn-design-system/issues/551)) ([019e691](https://github.com/BonnierNews/dn-design-system/commit/019e6917d9826644d7f8112272a81093e348ed1a))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## [1.0.0-alpha.17](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@1.0.0-alpha.16...@bonniernews/dn-design-system-web@1.0.0-alpha.17) (2023-01-11)
|
|
33
|
+
|
|
34
|
+
**Note:** Version bump only for package @bonniernews/dn-design-system-web
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
## [1.0.0-alpha.16](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@1.0.0-alpha.15...@bonniernews/dn-design-system-web@1.0.0-alpha.16) (2023-01-05)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### Bug Fixes
|
|
44
|
+
|
|
45
|
+
* **web:** remove large container variants of list items ([#548](https://github.com/BonnierNews/dn-design-system/issues/548)) ([bf699c9](https://github.com/BonnierNews/dn-design-system/commit/bf699c92a9cca51dc1f662b95047c58954d0f058))
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
## 1.0.0-alpha.15 (2023-01-05)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
### Bug Fixes
|
|
53
|
+
|
|
54
|
+
* **web:** update tests to include checkbox radio ([#546](https://github.com/BonnierNews/dn-design-system/issues/546)) ([bed3718](https://github.com/BonnierNews/dn-design-system/commit/bed3718fa6d9074294e5665af80e204d9ca5dee2))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
## [1.0.0-alpha.14](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@1.0.0-alpha.13...@bonniernews/dn-design-system-web@1.0.0-alpha.14) (2023-01-04)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
### Bug Fixes
|
|
62
|
+
|
|
63
|
+
* **web:** update radiobuttons can have attribues on each radiobutton ([#543](https://github.com/BonnierNews/dn-design-system/issues/543)) ([be47d7f](https://github.com/BonnierNews/dn-design-system/commit/be47d7fbe2fca6d70935cff1640a8627b45ff99d))
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
## [1.0.0-alpha.13](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@1.0.0-alpha.12...@bonniernews/dn-design-system-web@1.0.0-alpha.13) (2023-01-04)
|
|
68
|
+
|
|
69
|
+
**Note:** Version bump only for package @bonniernews/dn-design-system-web
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
## 1.0.0-alpha.12 (2023-01-04)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
### Features
|
|
79
|
+
|
|
80
|
+
* **web:** toggle buttons for standard and text buttons ([#535](https://github.com/BonnierNews/dn-design-system/issues/535)) ([216e51e](https://github.com/BonnierNews/dn-design-system/commit/216e51edc0aa1cef80d8b25b00da7f0c1139a428))
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
## 1.0.0-alpha.11 (2023-01-02)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
### Bug Fixes
|
|
88
|
+
|
|
89
|
+
* **web:** wrap checkbox and radiobutton in form-field ([#458](https://github.com/BonnierNews/dn-design-system/issues/458)) ([18169ed](https://github.com/BonnierNews/dn-design-system/commit/18169edc295dc9ec7c92b690e98d306b0903bdbb))
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
## [1.0.0-alpha.10](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@1.0.0-alpha.9...@bonniernews/dn-design-system-web@1.0.0-alpha.10) (2022-12-23)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
### Features
|
|
97
|
+
|
|
98
|
+
* **web:** add static white filled and outline button ([#534](https://github.com/BonnierNews/dn-design-system/issues/534)) ([d50c4f3](https://github.com/BonnierNews/dn-design-system/commit/d50c4f37a5ca429168a28416d05b38dd7cf4847f))
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
## [1.0.0-alpha.9](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@1.0.0-alpha.8...@bonniernews/dn-design-system-web@1.0.0-alpha.9) (2022-12-22)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
### Bug Fixes
|
|
106
|
+
|
|
107
|
+
* **web:** add spinner to buttons ([#530](https://github.com/BonnierNews/dn-design-system/issues/530)) ([945a08d](https://github.com/BonnierNews/dn-design-system/commit/945a08d957ae794dc29dc15806849de807b979c3))
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
## [1.0.0-alpha.8](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@1.0.0-alpha.7...@bonniernews/dn-design-system-web@1.0.0-alpha.8) (2022-12-21)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
### Features
|
|
115
|
+
|
|
116
|
+
* **web:** new variant on icon button - elevated ([#526](https://github.com/BonnierNews/dn-design-system/issues/526)) ([98bc55d](https://github.com/BonnierNews/dn-design-system/commit/98bc55d98a43d99cda12c14eac1a47b1afdabc3d))
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
## 1.0.0-alpha.7 (2022-12-21)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
### Bug Fixes
|
|
124
|
+
|
|
125
|
+
* **web:** new design for disabled standard button ([#527](https://github.com/BonnierNews/dn-design-system/issues/527)) ([7505328](https://github.com/BonnierNews/dn-design-system/commit/7505328a76dee387807d5e4f34038e2fc38140d6))
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
## [1.0.0-alpha.6](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@1.0.0-alpha.5...@bonniernews/dn-design-system-web@1.0.0-alpha.6) (2022-12-19)
|
|
130
|
+
|
|
131
|
+
**Note:** Version bump only for package @bonniernews/dn-design-system-web
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
## [1.0.0-alpha.5](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@1.0.0-alpha.4...@bonniernews/dn-design-system-web@1.0.0-alpha.5) (2022-12-19)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
### Features
|
|
141
|
+
|
|
142
|
+
* **foundations:** handle token types boxShadow and textDecoration ([#522](https://github.com/BonnierNews/dn-design-system/issues/522)) ([80339f3](https://github.com/BonnierNews/dn-design-system/commit/80339f35ca71e5f9efa0b8178ebbe8316619e2ab))
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
## [1.0.0-alpha.4](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@1.0.0-alpha.3...@bonniernews/dn-design-system-web@1.0.0-alpha.4) (2022-12-19)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
### Features
|
|
150
|
+
|
|
151
|
+
* **web:** spinner web component ([#515](https://github.com/BonnierNews/dn-design-system/issues/515)) ([f1146c2](https://github.com/BonnierNews/dn-design-system/commit/f1146c27434ed2c353bb27ee66e57d5b8145d043))
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
## 1.0.0-alpha.3 (2022-12-16)
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
### Bug Fixes
|
|
159
|
+
|
|
160
|
+
* **web:** badge static white as text color ([#511](https://github.com/BonnierNews/dn-design-system/issues/511)) ([ae48f8d](https://github.com/BonnierNews/dn-design-system/commit/ae48f8ddc21fcc3c3fcd651560a37062689e2e0a))
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
6
164
|
## 1.0.0-alpha.2 (2022-12-15)
|
|
7
165
|
|
|
8
166
|
**Note:** Version bump only for package @bonniernews/dn-design-system-web
|
|
@@ -8,10 +8,12 @@
|
|
|
8
8
|
|
|
9
9
|
<div class="ds-form-field {{ wrapperClasses | join(" ") }} {{ classes | join(" ") }} {{"hidden" if params.type == "hidden" }}">
|
|
10
10
|
{{ caller() if caller }}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
{% if params.errorMessage %}
|
|
12
|
+
<div class="ds-form-field__error-message js-field-error">
|
|
13
|
+
{{ Icon({ icon: "info-filled" }) }}
|
|
14
|
+
<span>{{ params.errorMessage | safe }}</span>
|
|
15
|
+
</div>
|
|
16
|
+
{% endif %}
|
|
15
17
|
{% if params.helpText or params.helpHtml %}
|
|
16
18
|
<p class="ds-form-field__help-text">{{ params.helpHtml | safe if params.helpHtml else params.helpText }}</p>
|
|
17
19
|
{% endif %}
|
|
@@ -12,7 +12,7 @@ $ds-badge__min-size: 8px;
|
|
|
12
12
|
|
|
13
13
|
.ds-badge__inner {
|
|
14
14
|
@include ds-typography($ds-typography-functional-meta02medium);
|
|
15
|
-
color: var($ds-color-
|
|
15
|
+
color: var($ds-color-static-white);
|
|
16
16
|
background-color: var($ds-color-component-brand);
|
|
17
17
|
border: var($ds-color-border-secondary) ds-metrics-border-width(x2) solid;
|
|
18
18
|
border-radius: 100px;
|
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
|:--- | :--- | :--- | :--- | :--- | :--- |
|
|
12
12
|
|text | String | yes | | | |
|
|
13
13
|
|disabled | bool | no | true, false | false | Note: only works on button-tag, not on a-tag |
|
|
14
|
-
|variant | String | no | brand, business, primary,
|
|
14
|
+
|variant | String | no | brand, business, criticalOutlined, primary, secondaryFilled, secondaryOutlined, staticWhiteFilled, staticWhiteOutlined | primary | Design variant |
|
|
15
15
|
|size| String | no | default, small | default | |
|
|
16
16
|
|fullWidth | bool | no | true, false | false | Button will be full width on both desktop and mobile |
|
|
17
17
|
|mobile.fullWidth | bool | no | true, false | false | Ex mobile: { fullWidth: true } |
|
|
18
18
|
|iconPosition | String | no | none, left, right | none | |
|
|
19
19
|
|iconName | String | no | add, arrow_back, arrow_forward etc | | For all available icons see: https://designsystem.dn.se/?path=/story/foundations-icon-web--all |
|
|
20
|
-
|
|
20
|
+
|loading | bool | no | true, false | false | |
|
|
21
21
|
|type | String | no | button, submit | button | |
|
|
22
22
|
|href | String | no | | | If href is set the button will be rendered as an a-tag |
|
|
23
23
|
|attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
{% from '@bonniernews/dn-design-system-web/foundations/icons/icon.njk' import Icon %}
|
|
2
|
+
{% from '@bonniernews/dn-design-system-web/components/spinner/spinner.njk' import Spinner %}
|
|
2
3
|
|
|
3
4
|
{% macro Button(params) %}
|
|
4
5
|
{% set componentClassName = "ds-btn" %}
|
|
@@ -11,14 +12,22 @@
|
|
|
11
12
|
{% endfor %}
|
|
12
13
|
{% endset %}
|
|
13
14
|
|
|
14
|
-
{%
|
|
15
|
-
|
|
15
|
+
{% set buttonVariant = params.variant | default("primary") %}
|
|
16
|
+
{% set variant = (variant.push(classNamePrefix + buttonVariant), variant) %}
|
|
17
|
+
|
|
18
|
+
{% set spinnerMap = { primary: "secondary", brand: "onBrand", business: "onBusiness", staticWhiteFilled: "staticBlack", staticWhiteOutlined: "staticWhite" } %}
|
|
19
|
+
{% set spinnerVariant = spinnerMap[buttonVariant] | default("primary") %}
|
|
20
|
+
|
|
21
|
+
{% set loadingHtml %}
|
|
22
|
+
{{ Spinner({ size: 'small', variant: spinnerVariant, forcePx: params.forcePx }) }}
|
|
23
|
+
{% endset %}
|
|
24
|
+
|
|
25
|
+
{% if params.loading %}
|
|
26
|
+
{% set variant = (variant.push("ds-loading"), variant) %}
|
|
16
27
|
{% endif %}
|
|
17
28
|
|
|
18
|
-
{% if params.
|
|
19
|
-
{% set variant = (variant.push(
|
|
20
|
-
{% else %}
|
|
21
|
-
{% set variant = (variant.push(classNamePrefix + "primary"), variant) %}
|
|
29
|
+
{% if params.forcePx %}
|
|
30
|
+
{% set variant = (variant.push("ds-force-px"), variant) %}
|
|
22
31
|
{% endif %}
|
|
23
32
|
|
|
24
33
|
{% if params.size and params.size != "default" %}
|
|
@@ -45,8 +54,18 @@
|
|
|
45
54
|
{% set classes = componentClassName + " " + variant | join(" ") %}
|
|
46
55
|
|
|
47
56
|
{% if params.href %}
|
|
48
|
-
<a href="{{ params.href | default('#', true) }}" class="{{ classes }}" {{- attributes | safe}}
|
|
57
|
+
<a href="{{ params.href | default('#', true) }}" class="{{ classes }}" {{- attributes | safe}}>
|
|
58
|
+
<div class="{{ componentClassName + '__inner'}}">
|
|
59
|
+
<span>{{ text }}</span>
|
|
60
|
+
{{- iconSvg | safe if iconSvg -}} {{ loadingHtml | safe }}
|
|
61
|
+
</div>
|
|
62
|
+
</a>
|
|
49
63
|
{% else %}
|
|
50
|
-
<button type="{{ params.type | default('button') }}" class="{{ classes }}" {{ "disabled" if params.disabled }} {{- attributes | safe}}
|
|
64
|
+
<button type="{{ params.type | default('button') }}" class="{{ classes }}" {{ "disabled" if params.disabled }} {{- attributes | safe}}>
|
|
65
|
+
<div class="{{ componentClassName + '__inner'}}">
|
|
66
|
+
<span>{{ text }}</span>
|
|
67
|
+
{{- iconSvg | safe if iconSvg -}} {{ loadingHtml | safe }}
|
|
68
|
+
</div>
|
|
69
|
+
</button>
|
|
51
70
|
{% endif %}
|
|
52
71
|
{% endmacro %}
|
|
@@ -5,21 +5,13 @@
|
|
|
5
5
|
@use "../../foundations/helpers/metrics.scss" as *;
|
|
6
6
|
@use "../../foundations/helpers/utilities.scss" as *;
|
|
7
7
|
@use "../../foundations/helpers/colors.scss" as *;
|
|
8
|
+
@use "../../foundations/helpers/loading.scss" as *;
|
|
9
|
+
@use "../spinner/spinner.scss" as *;
|
|
8
10
|
|
|
9
11
|
$ds-btn-outlined__border-width: ds-metrics-border-width(x1);
|
|
10
12
|
$ds-btn__min-clickable-area: 48px;
|
|
11
13
|
$ds-btn__icon-size: 24px;
|
|
12
14
|
|
|
13
|
-
@mixin ds-btn-disabled() {
|
|
14
|
-
cursor: not-allowed;
|
|
15
|
-
background-color: var($ds-color-component-primary-overlay);
|
|
16
|
-
border-color: transparent;
|
|
17
|
-
color: var($ds-color-text-disabled);
|
|
18
|
-
&::before {
|
|
19
|
-
background-color: unset;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
15
|
.ds-btn {
|
|
24
16
|
cursor: pointer;
|
|
25
17
|
background-color: transparent;
|
|
@@ -30,6 +22,7 @@ $ds-btn__icon-size: 24px;
|
|
|
30
22
|
align-items: center;
|
|
31
23
|
justify-content: center;
|
|
32
24
|
padding: 0;
|
|
25
|
+
position: relative;
|
|
33
26
|
|
|
34
27
|
&:focus-visible {
|
|
35
28
|
outline: none;
|
|
@@ -52,11 +45,6 @@ $ds-btn__icon-size: 24px;
|
|
|
52
45
|
/* stylelint-disable-next-line */
|
|
53
46
|
padding: ds-spacing-component(x3, rem) - ds-px-to-rem($ds-btn-outlined__border-width) ds-spacing-component(x6, rem) - ds-px-to-rem($ds-btn-outlined__border-width);
|
|
54
47
|
position: relative;
|
|
55
|
-
@at-root .ds-force-px#{&} {
|
|
56
|
-
padding: ds-spacing-component(x3) - $ds-btn-outlined__border-width
|
|
57
|
-
ds-spacing-component(x6) - $ds-btn-outlined__border-width;
|
|
58
|
-
@include ds-typography($ds-typography-detailstandard-button, true);
|
|
59
|
-
}
|
|
60
48
|
&::before {
|
|
61
49
|
content: "";
|
|
62
50
|
border-radius: inherit;
|
|
@@ -73,15 +61,14 @@ $ds-btn__icon-size: 24px;
|
|
|
73
61
|
}
|
|
74
62
|
}
|
|
75
63
|
|
|
76
|
-
&:hover:not(:disabled) .ds-btn__inner::before {
|
|
64
|
+
&:hover:not(:disabled):not(.ds-loading) .ds-btn__inner::before {
|
|
77
65
|
background-color: var($ds-color-component-primary-overlay);
|
|
78
66
|
}
|
|
79
|
-
&:active:not(:disabled) .ds-btn__inner::before {
|
|
67
|
+
&:active:not(:disabled):not(.ds-loading) .ds-btn__inner::before {
|
|
80
68
|
background-color: var($ds-color-component-primary-overlay-02);
|
|
81
69
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
70
|
+
|
|
71
|
+
@include ds-loading();
|
|
85
72
|
}
|
|
86
73
|
|
|
87
74
|
.ds-btn--full-width {
|
|
@@ -92,8 +79,10 @@ $ds-btn__icon-size: 24px;
|
|
|
92
79
|
}
|
|
93
80
|
|
|
94
81
|
.ds-btn--small .ds-btn__inner {
|
|
95
|
-
padding: ds-
|
|
96
|
-
|
|
82
|
+
padding: ds-px-to-rem(
|
|
83
|
+
ds-spacing-component(x2) - $ds-btn-outlined__border-width
|
|
84
|
+
)
|
|
85
|
+
ds-px-to-rem(ds-spacing-component(x5) - $ds-btn-outlined__border-width);
|
|
97
86
|
}
|
|
98
87
|
|
|
99
88
|
@include ds-mq-only-breakpoint(mobile) {
|
|
@@ -114,59 +103,40 @@ $ds-btn__icon-size: 24px;
|
|
|
114
103
|
display: flex;
|
|
115
104
|
height: ds-px-to-rem($ds-btn__icon-size);
|
|
116
105
|
width: ds-px-to-rem($ds-btn__icon-size);
|
|
117
|
-
margin: ds-spacing-component(0 0 0 x2);
|
|
106
|
+
margin: ds-spacing-component(0 0 0 x2, rem);
|
|
118
107
|
svg {
|
|
119
108
|
fill: currentColor;
|
|
120
109
|
}
|
|
121
110
|
}
|
|
122
111
|
}
|
|
123
112
|
|
|
124
|
-
.ds-force-px {
|
|
125
|
-
&.ds-btn--icon-left .ds-btn__inner .ds-icon,
|
|
126
|
-
&.ds-btn--icon-right .ds-btn__inner .ds-icon {
|
|
127
|
-
height: $ds-btn__icon-size;
|
|
128
|
-
width: $ds-btn__icon-size;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
113
|
.ds-btn--icon-right {
|
|
133
114
|
.ds-btn__inner {
|
|
134
|
-
padding-right: ds-
|
|
115
|
+
padding-right: ds-px-to-rem(
|
|
116
|
+
ds-spacing-component(x5) - $ds-btn-outlined__border-width
|
|
117
|
+
);
|
|
135
118
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
padding-right: ds-spacing-component(x5)-$ds-btn-outlined__border-width;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
&.ds-btn--small .ds-btn__inner {
|
|
144
|
-
padding-right: ds-spacing-component(x4)-$ds-btn-outlined__border-width;
|
|
145
|
-
}
|
|
119
|
+
&.ds-btn--small .ds-btn__inner {
|
|
120
|
+
padding-right: ds-px-to-rem(
|
|
121
|
+
ds-spacing-component(x4) - $ds-btn-outlined__border-width
|
|
122
|
+
);
|
|
146
123
|
}
|
|
147
124
|
}
|
|
148
125
|
|
|
149
126
|
.ds-btn--icon-left {
|
|
150
127
|
.ds-btn__inner {
|
|
151
128
|
flex-direction: row-reverse;
|
|
152
|
-
padding-left: ds-
|
|
129
|
+
padding-left: ds-px-to-rem(
|
|
130
|
+
ds-spacing-component(x5) - $ds-btn-outlined__border-width
|
|
131
|
+
);
|
|
153
132
|
.ds-icon {
|
|
154
|
-
margin: ds-spacing-component(0 x2 0 0);
|
|
133
|
+
margin: ds-spacing-component(0 x2 0 0, rem);
|
|
155
134
|
}
|
|
156
135
|
}
|
|
157
136
|
&.ds-btn--small .ds-btn__inner {
|
|
158
|
-
padding-left: ds-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
&.ds-btn--secondaryOutlined,
|
|
162
|
-
&.ds-btn--destructive {
|
|
163
|
-
.ds-btn__inner {
|
|
164
|
-
padding-left: ds-spacing-component(x5)-$ds-btn-outlined__border-width;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
&.ds-btn--small .ds-btn__inner {
|
|
168
|
-
padding-left: ds-spacing-component(x4)-$ds-btn-outlined__border-width;
|
|
169
|
-
}
|
|
137
|
+
padding-left: ds-px-to-rem(
|
|
138
|
+
ds-spacing-component(x4) - $ds-btn-outlined__border-width
|
|
139
|
+
);
|
|
170
140
|
}
|
|
171
141
|
}
|
|
172
142
|
|
|
@@ -201,10 +171,10 @@ $ds-btn__icon-size: 24px;
|
|
|
201
171
|
&:focus-visible .ds-btn__inner {
|
|
202
172
|
outline-color: var($ds-color-border-focus-02);
|
|
203
173
|
}
|
|
204
|
-
&:hover:not(:disabled) .ds-btn__inner::before {
|
|
174
|
+
&:hover:not(:disabled):not(.ds-loading) .ds-btn__inner::before {
|
|
205
175
|
background-color: var($ds-color-component-secondary-overlay);
|
|
206
176
|
}
|
|
207
|
-
&:active:not(:disabled) .ds-btn__inner::before {
|
|
177
|
+
&:active:not(:disabled):not(.ds-loading) .ds-btn__inner::before {
|
|
208
178
|
background-color: var($ds-color-component-secondary-overlay-02);
|
|
209
179
|
}
|
|
210
180
|
}
|
|
@@ -237,7 +207,113 @@ $ds-btn__icon-size: 24px;
|
|
|
237
207
|
border-color: var($ds-color-border-critical);
|
|
238
208
|
color: var($ds-color-text-critical);
|
|
239
209
|
}
|
|
210
|
+
&:not(:disabled) .ds-icon {
|
|
211
|
+
color: var($ds-color-icon-critical);
|
|
212
|
+
}
|
|
240
213
|
&:focus-visible .ds-btn__inner {
|
|
241
214
|
outline-color: var($ds-color-border-focus-03);
|
|
242
215
|
}
|
|
243
216
|
}
|
|
217
|
+
|
|
218
|
+
.ds-btn--staticWhiteFilled {
|
|
219
|
+
.ds-btn__inner {
|
|
220
|
+
border-color: transparent;
|
|
221
|
+
background-color: var($ds-color-static-white);
|
|
222
|
+
color: var($ds-color-static-black);
|
|
223
|
+
}
|
|
224
|
+
&:focus-visible .ds-btn__inner {
|
|
225
|
+
outline-color: var($ds-color-border-focus-02);
|
|
226
|
+
}
|
|
227
|
+
&:hover:not(:disabled):not(.ds-loading) .ds-btn__inner::before {
|
|
228
|
+
background-color: #0808081a; // static version of lightmode component-secondary-overlay
|
|
229
|
+
}
|
|
230
|
+
&:active:not(:disabled):not(.ds-loading) .ds-btn__inner::before {
|
|
231
|
+
background-color: #08080833; // static version of lightmode component-secondary-overlay-2
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.ds-btn--staticWhiteOutlined {
|
|
236
|
+
.ds-btn__inner {
|
|
237
|
+
background-color: transparent;
|
|
238
|
+
border-color: var($ds-color-static-white);
|
|
239
|
+
color: var($ds-color-static-white);
|
|
240
|
+
}
|
|
241
|
+
&:not(:disabled) .ds-icon {
|
|
242
|
+
color: var($ds-color-static-white);
|
|
243
|
+
}
|
|
244
|
+
&:focus-visible .ds-btn__inner {
|
|
245
|
+
outline-color: var($ds-color-static-white);
|
|
246
|
+
}
|
|
247
|
+
&:hover:not(:disabled):not(.ds-loading) .ds-btn__inner::before {
|
|
248
|
+
background-color: rgba(255, 255, 255, 0.101960784);
|
|
249
|
+
// static version of darkmode component-secondary-overlay
|
|
250
|
+
}
|
|
251
|
+
&:active:not(:disabled):not(.ds-loading) .ds-btn__inner::before {
|
|
252
|
+
background-color: rgba(255, 255, 255, 0.2);
|
|
253
|
+
// static version of darkmode component-secondary-overlay-2
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.ds-btn--secondaryFilled,
|
|
258
|
+
.ds-btn--secondaryOutlined,
|
|
259
|
+
.ds-btn--criticalOutlined,
|
|
260
|
+
.ds-btn--staticWhiteOutlined {
|
|
261
|
+
&:not(.ds-loading):disabled .ds-btn__inner {
|
|
262
|
+
cursor: not-allowed;
|
|
263
|
+
background-color: var($ds-color-component-primary-overlay);
|
|
264
|
+
border-color: transparent;
|
|
265
|
+
color: var($ds-color-text-disabled);
|
|
266
|
+
&::before {
|
|
267
|
+
background-color: unset;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.ds-btn--brand,
|
|
273
|
+
.ds-btn--business,
|
|
274
|
+
.ds-btn--primary,
|
|
275
|
+
.ds-btn--staticWhiteFilled {
|
|
276
|
+
&:not(.ds-loading):disabled {
|
|
277
|
+
opacity: 0.6; // @todo replace with opacity token if/when available
|
|
278
|
+
.ds-btn__inner {
|
|
279
|
+
cursor: not-allowed;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.ds-btn.ds-force-px {
|
|
285
|
+
.ds-btn__inner {
|
|
286
|
+
padding: ds-spacing-component(x3) - $ds-btn-outlined__border-width
|
|
287
|
+
ds-spacing-component(x6) - $ds-btn-outlined__border-width;
|
|
288
|
+
@include ds-typography($ds-typography-detailstandard-button, true);
|
|
289
|
+
}
|
|
290
|
+
&.ds-btn--icon-left .ds-btn__inner,
|
|
291
|
+
&.ds-btn--icon-right .ds-btn__inner {
|
|
292
|
+
.ds-icon {
|
|
293
|
+
margin: ds-spacing-component(0 0 0 x2);
|
|
294
|
+
height: $ds-btn__icon-size;
|
|
295
|
+
width: $ds-btn__icon-size;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
&.ds-btn--icon-right .ds-btn__inner {
|
|
299
|
+
padding-right: ds-spacing-component(x5)-$ds-btn-outlined__border-width;
|
|
300
|
+
}
|
|
301
|
+
&.ds-btn--icon-left .ds-btn__inner {
|
|
302
|
+
padding-left: ds-spacing-component(x5)-$ds-btn-outlined__border-width;
|
|
303
|
+
.ds-icon {
|
|
304
|
+
margin: ds-spacing-component(0 x2 0 0);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
&.ds-btn--small {
|
|
308
|
+
.ds-btn__inner {
|
|
309
|
+
padding: ds-spacing-component(x2)-$ds-btn-outlined__border-width
|
|
310
|
+
ds-spacing-component(x5)-$ds-btn-outlined__border-width;
|
|
311
|
+
}
|
|
312
|
+
&.ds-btn--icon-right .ds-btn__inner {
|
|
313
|
+
padding-right: ds-spacing-component(x4)-$ds-btn-outlined__border-width;
|
|
314
|
+
}
|
|
315
|
+
&.ds-btn--icon-left .ds-btn__inner {
|
|
316
|
+
padding-left: ds-spacing-component(x4)-$ds-btn-outlined__border-width;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
- GitHub: [BonnierNews/dn-design-system/../web/src/components/button-toggle](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/button-toggle)
|
|
2
|
+
- Storybook: [Button > Web](https://designsystem.dn.se/?path=/story/components-app-web-button-togglebutton-web)
|
|
3
|
+
|
|
4
|
+
----
|
|
5
|
+
|
|
6
|
+
# ButtonToggle
|
|
7
|
+
|
|
8
|
+
## Parameters
|
|
9
|
+
|
|
10
|
+
|parameter | type | required | options | default | description |
|
|
11
|
+
|:--- | :--- | :--- | :--- | :--- | :--- |
|
|
12
|
+
|selected | bool | no | true, false | false | |
|
|
13
|
+
|text | String | yes | | | |
|
|
14
|
+
|selectedText | String | yes | | | |
|
|
15
|
+
|disabled | bool | no | true, false | false | |
|
|
16
|
+
|variant | String | no | brand, SecondaryFilled | brand | Design variant |
|
|
17
|
+
|size| String | no | default, small | default | |
|
|
18
|
+
|fullWidth | bool | no | true, false | false | Button will be full width on both desktop and mobile |
|
|
19
|
+
|mobile.fullWidth | bool | no | true, false | false | Ex mobile: { fullWidth: true } |
|
|
20
|
+
|loading | bool | no | true, false | false | |
|
|
21
|
+
|attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
|
|
22
|
+
|classNames | String | no | | | Ex. "my-special-class" |
|
|
23
|
+
|forcePx | bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
|
|
24
|
+
|
|
25
|
+
## Minimum requirement example
|
|
26
|
+
|
|
27
|
+
### Nunjucks
|
|
28
|
+
|
|
29
|
+
These are copy paste friendly examples to quickliy get started using a component.
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
{% from '@bonniernews/dn-design-system-web/components/button-toggle/button-toggle.njk' import ButtonToggle %}
|
|
33
|
+
|
|
34
|
+
{{ ButtonToggle({
|
|
35
|
+
text: 'Följ',
|
|
36
|
+
selectedText: 'Följer',
|
|
37
|
+
variant: 'brand',
|
|
38
|
+
mobile: {
|
|
39
|
+
fullWidth: true
|
|
40
|
+
}
|
|
41
|
+
})}}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### SCSS
|
|
45
|
+
```scss
|
|
46
|
+
@use "@bonniernews/dn-design-system-web/components/button-toggle/button-toggle";
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Javascript
|
|
50
|
+
|
|
51
|
+
```javascript
|
|
52
|
+
import textInput from '@bonniernews/dn-design-system-web/components/button-toggle/button-toggle.js'
|
|
53
|
+
DsButtonToggle();
|
|
54
|
+
```
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function DsButtonToggle() {
|
|
2
|
+
const toggleElements = Array.from(document.getElementsByClassName("ds-btn-toggle"));
|
|
3
|
+
toggleElements.forEach((toggleEl) => {
|
|
4
|
+
toggleEl.addEventListener("click", () => {
|
|
5
|
+
if (toggleEl.classList.contains("ds-btn-toggle--disabled")) return;
|
|
6
|
+
toggleEl.classList.toggle("ds-btn-toggle--selected");
|
|
7
|
+
});
|
|
8
|
+
});
|
|
9
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{% from '@bonniernews/dn-design-system-web/foundations/icons/icon.njk' import Icon %}
|
|
2
|
+
{% from '@bonniernews/dn-design-system-web/components/spinner/spinner.njk' import Spinner %}
|
|
3
|
+
|
|
4
|
+
{% macro ButtonToggle(params) %}
|
|
5
|
+
{% set componentClassName = "ds-btn-toggle" %}
|
|
6
|
+
{% set classNamePrefix = componentClassName + "--" %}
|
|
7
|
+
{% set variant = [] %}
|
|
8
|
+
{% set attributes %}
|
|
9
|
+
{% for attribute, value in params.attributes %}
|
|
10
|
+
{{attribute}}="{{value}}"
|
|
11
|
+
{% endfor %}
|
|
12
|
+
{% endset %}
|
|
13
|
+
|
|
14
|
+
{% if params.selected %}
|
|
15
|
+
{% set variant = (variant.push(classNamePrefix + "selected"), variant) %}
|
|
16
|
+
{% endif %}
|
|
17
|
+
|
|
18
|
+
{% set buttonVariant = params.variant | default("brand") %}
|
|
19
|
+
{% set variant = (variant.push(classNamePrefix + buttonVariant), variant) %}
|
|
20
|
+
|
|
21
|
+
{% set spinnerMap = { primary: "secondary", brand: "onBrand", business: "onBusiness" } %}
|
|
22
|
+
{% set spinnerVariant = spinnerMap[buttonVariant] | default("primary") %}
|
|
23
|
+
|
|
24
|
+
{% set loadingHtml %}
|
|
25
|
+
{{ Spinner({ size: 'small', variant: spinnerVariant, forcePx: params.forcePx }) }}
|
|
26
|
+
{% endset %}
|
|
27
|
+
|
|
28
|
+
{% if params.loading %}
|
|
29
|
+
{% set variant = (variant.push("ds-loading"), variant) %}
|
|
30
|
+
{% endif %}
|
|
31
|
+
|
|
32
|
+
{% if params.forcePx %}
|
|
33
|
+
{% set variant = (variant.push("ds-force-px"), variant) %}
|
|
34
|
+
{% endif %}
|
|
35
|
+
|
|
36
|
+
{% if params.size and params.size != "default" %}
|
|
37
|
+
{% set variant = (variant.push(classNamePrefix + params.size), variant) %}
|
|
38
|
+
{% endif %}
|
|
39
|
+
|
|
40
|
+
{% if params.fullWidth %}
|
|
41
|
+
{% set variant = (variant.push(classNamePrefix + "full-width"), variant) %}
|
|
42
|
+
{% endif %}
|
|
43
|
+
|
|
44
|
+
{% if params.mobile and params.mobile.fullWidth %}
|
|
45
|
+
{% set variant = (variant.push(classNamePrefix + "mobile-full-width"), variant) %}
|
|
46
|
+
{% endif %}
|
|
47
|
+
|
|
48
|
+
{% if params.classNames %}
|
|
49
|
+
{% set variant = (variant.push(params.classNames), variant) %}
|
|
50
|
+
{% endif%}
|
|
51
|
+
|
|
52
|
+
{% set classes = componentClassName + " " + variant | join(" ") %}
|
|
53
|
+
|
|
54
|
+
<button type="button'" class="{{ classes }}" {{ "disabled" if params.disabled }} {{- attributes | safe}}>
|
|
55
|
+
<div class="{{ componentClassName + '__inner'}}">
|
|
56
|
+
<div class="{{ componentClassName + '__off'}}"><span>{{ params.text }}</span></div>
|
|
57
|
+
<div class="{{ componentClassName + '__on'}}">
|
|
58
|
+
{{ Icon({ icon: "check" }) }} <span>{{ params.selectedText }}</span>
|
|
59
|
+
</div>
|
|
60
|
+
{{ loadingHtml | safe }}
|
|
61
|
+
</div>
|
|
62
|
+
</button>
|
|
63
|
+
{% endmacro %}
|