@bonniernews/dn-design-system-web 14.3.10 → 14.4.0-beta.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/CHANGELOG.md +19 -0
- package/components/blocked-content/blocked-content.js +1 -1
- package/components/blocked-content/blocked-content.njk +2 -2
- package/components/button/README-UXD.md +2 -2
- package/components/button/README.md +4 -2
- package/components/{button-toggle/button-toggle.js → button/button.js} +3 -3
- package/components/button/button.njk +62 -15
- package/components/button/button.scss +179 -121
- package/components/button-toggle/README.md +4 -4
- package/components/button-toggle/button-toggle.njk +17 -36
- package/components/button-toggle/button-toggle.scss +1 -215
- package/components/byline/README.md +2 -2
- package/components/byline/byline.njk +2 -2
- package/components/factbox/factbox.njk +4 -4
- package/components/group-header/group-header.njk +5 -3
- package/components/group-header/group-header.scss +4 -4
- package/components/icon-button/README.md +5 -3
- package/components/icon-button/icon-button.njk +18 -51
- package/components/icon-button/icon-button.scss +19 -126
- package/components/icon-button-toggle/README.md +8 -8
- package/components/icon-button-toggle/icon-button-toggle.njk +14 -1
- package/components/icon-button-toggle/icon-button-toggle.scss +1 -17
- package/components/list-item/list-item.js +2 -2
- package/components/list-item/list-item.njk +2 -2
- package/components/list-item/list-item.scss +1 -1
- package/components/modal/modal.njk +3 -2
- package/components/modal/modal.scss +4 -4
- package/components/tag-header/tag-header.njk +1 -1
- package/components/teaser-list-swipe/teaser-list-swipe.njk +4 -2
- package/components/teaser-list-vertical/teaser-list-vertical.njk +1 -1
- package/components/text-input/text-input.scss +1 -1
- package/package.json +1 -1
- package/components/floating-button/README.md +0 -41
- package/components/floating-button/floating-button.njk +0 -41
- package/components/floating-button/floating-button.scss +0 -145
- package/components/icon-button-toggle/icon-button-toggle.js +0 -21
|
@@ -1,39 +1,20 @@
|
|
|
1
|
-
{% from '@bonniernews/dn-design-system-web/components/
|
|
2
|
-
{% from '@bonniernews/dn-design-system-web/components/spinner/spinner.njk' import Spinner %}
|
|
3
|
-
{% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
|
|
1
|
+
{% from '@bonniernews/dn-design-system-web/components/button/button.njk' import Button %}
|
|
4
2
|
|
|
5
3
|
{% macro ButtonToggle(params) %}
|
|
6
|
-
{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
classNamePrefix + buttonVariant,
|
|
23
|
-
classNamePrefix + "selected" if params.selected,
|
|
24
|
-
classNamePrefix + params.size if params.size and params.size !== "default",
|
|
25
|
-
classNamePrefix + "full-width" if params.fullWidth,
|
|
26
|
-
classNamePrefix + "mobile-full-width" if params.mobile and params.mobile.fullWidth,
|
|
27
|
-
"ds-loading" if params.loading,
|
|
28
|
-
"ds-force-px" if params.forcePx,
|
|
29
|
-
params.classNames if params.classNames
|
|
30
|
-
] | join(" ") %}
|
|
31
|
-
|
|
32
|
-
<button type="button" role="switch" {{ ariaLabel | safe }} aria-checked="{{ "true" if params.selected else "false" }}" class="{{ classes }}" {{ "disabled" if params.disabled }} {{- attributes | safe }}>
|
|
33
|
-
<span class="{{ componentClassName + '__off' }}" aria-hidden="true"><span>{{ params.text }}</span></span>
|
|
34
|
-
<span class="{{ componentClassName + '__on' }}" aria-hidden="true">
|
|
35
|
-
{{ IconUse({ icon: "check" }) }} <span>{{ params.selectedText }}</span>
|
|
36
|
-
</span>
|
|
37
|
-
{{ loadingHtml | safe }}
|
|
38
|
-
</button>
|
|
4
|
+
{{ Button({
|
|
5
|
+
isToggle: true,
|
|
6
|
+
rounded: true,
|
|
7
|
+
selected: params.selected,
|
|
8
|
+
text: params.text,
|
|
9
|
+
selectedText: params.selectedText,
|
|
10
|
+
variant: params.variant,
|
|
11
|
+
disabled: params.disabled,
|
|
12
|
+
size: params.size,
|
|
13
|
+
fullWidth: params.fullWidth,
|
|
14
|
+
mobile: params.mobile,
|
|
15
|
+
loading: params.loading,
|
|
16
|
+
forcePx: params.forcePx,
|
|
17
|
+
classNames: params.classNames,
|
|
18
|
+
attributes: params.attributes
|
|
19
|
+
}) }}
|
|
39
20
|
{% endmacro %}
|
|
@@ -1,215 +1 @@
|
|
|
1
|
-
@use "
|
|
2
|
-
@use "../../foundations/helpers/forward.helpers.scss" as *;
|
|
3
|
-
@use "../icon-sprite/icon-sprite.scss";
|
|
4
|
-
@use "../spinner/spinner.scss" as *;
|
|
5
|
-
|
|
6
|
-
$ds-btn-toggle-outlined__border-width: ds-metrics-border-width(x1);
|
|
7
|
-
$ds-btn-toggle__icon-size: 24px;
|
|
8
|
-
$ds-btn-toggle__icon-size-xsmall: 20px;
|
|
9
|
-
|
|
10
|
-
.ds-btn-toggle {
|
|
11
|
-
--ds-btn-toggle__background-color: transparent;
|
|
12
|
-
--ds-btn-toggle__background-color-hover: #{$ds-color-component-primary-overlay};
|
|
13
|
-
--ds-btn-toggle__background-color-active: #{$ds-color-component-primary-overlay-02};
|
|
14
|
-
--ds-btn-toggle__border-color: #{$ds-color-border-primary-03};
|
|
15
|
-
--ds-btn-toggle__outline-color: #{$ds-color-border-focus-02};
|
|
16
|
-
--ds-btn-toggle__color: #{$ds-color-text-primary};
|
|
17
|
-
|
|
18
|
-
&--brand:not(.ds-btn-toggle--selected) {
|
|
19
|
-
--ds-btn-toggle__background-color: #{$ds-color-component-brand};
|
|
20
|
-
--ds-btn-toggle__border-color: transparent;
|
|
21
|
-
--ds-btn-toggle__outline-color: #{$ds-color-border-focus};
|
|
22
|
-
--ds-btn-toggle__color: #{$ds-color-text-on-brand};
|
|
23
|
-
&:not(.ds-loading):disabled {
|
|
24
|
-
opacity: $ds-opacity-component-disabled;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
&--secondaryFilled:not(.ds-btn-toggle--selected) {
|
|
29
|
-
--ds-btn-toggle__border-color: transparent;
|
|
30
|
-
--ds-btn-toggle__outline-color: #{$ds-color-border-focus-02};
|
|
31
|
-
--ds-btn-toggle__background-color: #{$ds-color-component-primary-overlay};
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
&--secondaryFilled,
|
|
35
|
-
&--selected {
|
|
36
|
-
&:not(.ds-loading):disabled {
|
|
37
|
-
--ds-btn-toggle__border-color: transparent;
|
|
38
|
-
--ds-btn-toggle__color: #{$ds-color-text-disabled};
|
|
39
|
-
&::before {
|
|
40
|
-
--ds-btn-toggle__background-color: unset;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
&:not(.ds-loading):disabled {
|
|
46
|
-
cursor: not-allowed;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@include ds-typography($ds-typography-detailstandard-button);
|
|
50
|
-
cursor: pointer;
|
|
51
|
-
color: var(--ds-btn-toggle__color);
|
|
52
|
-
background-color: var(--ds-btn-toggle__background-color);
|
|
53
|
-
min-width: 0;
|
|
54
|
-
min-height: 0;
|
|
55
|
-
display: inline-flex;
|
|
56
|
-
align-items: center;
|
|
57
|
-
justify-content: center;
|
|
58
|
-
flex-shrink: 0;
|
|
59
|
-
border: $ds-btn-toggle-outlined__border-width solid var(--ds-btn-toggle__border-color);
|
|
60
|
-
border-radius: 100px;
|
|
61
|
-
position: relative;
|
|
62
|
-
padding: ds-spacing($ds-s-075, rem) - ds-px-to-rem($ds-btn-toggle-outlined__border-width) ds-spacing($ds-s-150, rem) - ds-px-to-rem(
|
|
63
|
-
$ds-btn-toggle-outlined__border-width
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
&::before {
|
|
67
|
-
content: "";
|
|
68
|
-
border-radius: inherit;
|
|
69
|
-
pointer-events: none;
|
|
70
|
-
position: absolute;
|
|
71
|
-
top: -$ds-btn-toggle-outlined__border-width;
|
|
72
|
-
left: -$ds-btn-toggle-outlined__border-width;
|
|
73
|
-
bottom: -$ds-btn-toggle-outlined__border-width;
|
|
74
|
-
right: -$ds-btn-toggle-outlined__border-width;
|
|
75
|
-
}
|
|
76
|
-
span,
|
|
77
|
-
i {
|
|
78
|
-
position: relative;
|
|
79
|
-
}
|
|
80
|
-
.ds-btn-toggle__on {
|
|
81
|
-
display: none;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
span {
|
|
85
|
-
pointer-events: none;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
@include min-click-surface();
|
|
89
|
-
|
|
90
|
-
&:focus-visible {
|
|
91
|
-
outline: ds-metrics-border-width(x2) solid var(--ds-btn-toggle__outline-color);
|
|
92
|
-
outline-offset: 2px;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
@at-root a#{&} {
|
|
96
|
-
box-sizing: border-box;
|
|
97
|
-
text-align: center;
|
|
98
|
-
text-decoration: none;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
@include ds-hover() {
|
|
102
|
-
&:hover:not(:disabled):not(.ds-loading)::before {
|
|
103
|
-
background-color: var(--ds-btn-toggle__background-color-hover);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
&:active:not(:disabled):not(.ds-loading)::before {
|
|
107
|
-
background-color: var(--ds-btn-toggle__background-color-active);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
@include ds-loading();
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
.ds-btn-toggle--full-width {
|
|
114
|
-
width: 100%;
|
|
115
|
-
box-sizing: border-box;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
.ds-btn-toggle--small {
|
|
119
|
-
padding: ds-px-to-rem(ds-spacing($ds-s-050) - $ds-btn-toggle-outlined__border-width)
|
|
120
|
-
ds-px-to-rem(ds-spacing($ds-s-125) - $ds-btn-toggle-outlined__border-width);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
.ds-btn-toggle--xsmall {
|
|
124
|
-
@include ds-typography($ds-typography-detailstandard-button-small);
|
|
125
|
-
padding: ds-px-to-rem(ds-spacing($ds-s-025) - $ds-btn-toggle-outlined__border-width)
|
|
126
|
-
ds-px-to-rem(ds-spacing($ds-s-075) - $ds-btn-toggle-outlined__border-width);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
@include ds-mq-only-breakpoint(mobile) {
|
|
130
|
-
.ds-btn-toggle--mobile-full-width {
|
|
131
|
-
width: 100%;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
.ds-btn-toggle--selected {
|
|
136
|
-
display: inline-flex;
|
|
137
|
-
align-items: center;
|
|
138
|
-
justify-content: center;
|
|
139
|
-
padding-left: ds-px-to-rem(ds-spacing($ds-s-125) - $ds-btn-toggle-outlined__border-width);
|
|
140
|
-
|
|
141
|
-
.ds-btn-toggle__on {
|
|
142
|
-
display: flex;
|
|
143
|
-
}
|
|
144
|
-
.ds-btn-toggle__off {
|
|
145
|
-
display: none;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
.ds-icon {
|
|
149
|
-
display: flex;
|
|
150
|
-
height: ds-px-to-rem($ds-btn-toggle__icon-size);
|
|
151
|
-
width: ds-px-to-rem($ds-btn-toggle__icon-size);
|
|
152
|
-
margin: ds-spacing(0 $ds-s-050 0 0, rem);
|
|
153
|
-
svg {
|
|
154
|
-
fill: currentColor;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
&.ds-btn-toggle--small {
|
|
159
|
-
padding-left: ds-px-to-rem(ds-spacing($ds-s-100) - $ds-btn-toggle-outlined__border-width);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
&.ds-btn-toggle--xsmall {
|
|
163
|
-
padding-left: ds-px-to-rem(ds-spacing($ds-s-050) - $ds-btn-toggle-outlined__border-width);
|
|
164
|
-
.ds-icon {
|
|
165
|
-
height: ds-px-to-rem($ds-btn-toggle__icon-size-xsmall);
|
|
166
|
-
width: ds-px-to-rem($ds-btn-toggle__icon-size-xsmall);
|
|
167
|
-
margin: ds-spacing(0 $ds-s-025 0 0, rem);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// we have to override spinner styling since spinner variant is based on "off" button variant
|
|
172
|
-
&.ds-loading {
|
|
173
|
-
.ds-spinner__inner {
|
|
174
|
-
border-top-color: $ds-color-icon-primary;
|
|
175
|
-
&::before {
|
|
176
|
-
border-color: $ds-color-icon-primary;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
.ds-btn-toggle.ds-force-px {
|
|
183
|
-
/* stylelint-disable-next-line */
|
|
184
|
-
padding: ds-spacing($ds-s-075) - $ds-btn-toggle-outlined__border-width ds-spacing($ds-s-150) -
|
|
185
|
-
$ds-btn-toggle-outlined__border-width;
|
|
186
|
-
@include ds-typography($ds-typography-detailstandard-button, true);
|
|
187
|
-
|
|
188
|
-
&.ds-btn-toggle--selected {
|
|
189
|
-
padding-left: ds-spacing($ds-s-125)-$ds-btn-toggle-outlined__border-width;
|
|
190
|
-
.ds-icon {
|
|
191
|
-
margin: ds-spacing(0 $ds-s-050 0 0);
|
|
192
|
-
height: $ds-btn-toggle__icon-size;
|
|
193
|
-
width: $ds-btn-toggle__icon-size;
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
&.ds-btn-toggle--small {
|
|
197
|
-
padding: ds-spacing($ds-s-050)-$ds-btn-toggle-outlined__border-width ds-spacing($ds-s-125)-$ds-btn-toggle-outlined__border-width;
|
|
198
|
-
|
|
199
|
-
&.ds-btn-toggle--selected {
|
|
200
|
-
padding-left: ds-spacing($ds-s-100)-$ds-btn-toggle-outlined__border-width;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
&.ds-btn-toggle--xsmall {
|
|
204
|
-
@include ds-typography($ds-typography-detailstandard-button-small, true);
|
|
205
|
-
padding: ds-spacing($ds-s-025)-$ds-btn-toggle-outlined__border-width ds-spacing($ds-s-075)-$ds-btn-toggle-outlined__border-width;
|
|
206
|
-
.ds-icon {
|
|
207
|
-
margin: ds-spacing(0 $ds-s-025 0 0);
|
|
208
|
-
height: $ds-btn-toggle__icon-size-xsmall;
|
|
209
|
-
width: $ds-btn-toggle__icon-size-xsmall;
|
|
210
|
-
}
|
|
211
|
-
&.ds-btn-toggle--selected {
|
|
212
|
-
padding-left: ds-spacing($ds-s-050)-$ds-btn-toggle-outlined__border-width;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
}
|
|
1
|
+
@use "../button/button.scss" as *;
|
|
@@ -62,7 +62,7 @@ These are copy paste friendly examples to quickliy get started using a component
|
|
|
62
62
|
### Javascript
|
|
63
63
|
|
|
64
64
|
```javascript
|
|
65
|
-
import dsButtonToggle from '@bonniernews/dn-design-system-web/components/button
|
|
66
|
-
const toggleElements = Array.from(document.getElementsByClassName("ds-btn
|
|
65
|
+
import dsButtonToggle from '@bonniernews/dn-design-system-web/components/button/button.js'
|
|
66
|
+
const toggleElements = Array.from(document.getElementsByClassName("ds-btn--toggle"));
|
|
67
67
|
dsButtonToggle(toggleElements);
|
|
68
68
|
```
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
text: "Följ",
|
|
29
29
|
selectedText: "Följer",
|
|
30
30
|
selected: params.followed,
|
|
31
|
-
variant: "
|
|
32
|
-
size: "
|
|
31
|
+
variant: "secondary",
|
|
32
|
+
size: "small",
|
|
33
33
|
attributes: params.elementAttributes,
|
|
34
34
|
classNames: elementClassNames | join(" "),
|
|
35
35
|
forcePx: params.forcePx
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
<div class="{{ componentClassName + '__show-more'}}">
|
|
30
30
|
{{ Button({
|
|
31
31
|
text: 'Visa mer',
|
|
32
|
-
variant: '
|
|
33
|
-
size: '
|
|
32
|
+
variant: 'secondary',
|
|
33
|
+
size: 'medium',
|
|
34
34
|
iconPosition: 'right',
|
|
35
35
|
iconName: 'expand_more',
|
|
36
36
|
classNames: 'ds-factbox__expand-more',
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
})}}
|
|
40
40
|
{{ Button({
|
|
41
41
|
text: 'Visa mindre',
|
|
42
|
-
variant: '
|
|
43
|
-
size: '
|
|
42
|
+
variant: 'secondary',
|
|
43
|
+
size: 'medium',
|
|
44
44
|
iconPosition: 'right',
|
|
45
45
|
iconName: 'expand_less',
|
|
46
46
|
classNames: 'ds-factbox__expand-less',
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
{% if params.variant == 'toggle' %}
|
|
48
48
|
{{ ButtonToggle({
|
|
49
49
|
variant: 'brand',
|
|
50
|
-
size: '
|
|
50
|
+
size: 'small',
|
|
51
51
|
text: params.toggleText,
|
|
52
52
|
selectedText: params.toggleSelectedText,
|
|
53
53
|
selected: params.toggleSelected,
|
|
@@ -58,14 +58,16 @@
|
|
|
58
58
|
{% elif (params.variant == 'arrows') %}
|
|
59
59
|
<div class="{{ componentClassName + '__arrows' }} hidden-mobile hidden-tablet">
|
|
60
60
|
{{ IconButton({
|
|
61
|
-
variant: "
|
|
61
|
+
variant: "primary",
|
|
62
|
+
emphasis: "outline",
|
|
62
63
|
size: "small",
|
|
63
64
|
iconName: "arrow_back",
|
|
64
65
|
classNames: "ds-group-header__arrow ds-group-header__arrow--left",
|
|
65
66
|
attributes: {"aria-label": "Föregående"}
|
|
66
67
|
}) }}
|
|
67
68
|
{{ IconButton({
|
|
68
|
-
variant: "
|
|
69
|
+
variant: "primary",
|
|
70
|
+
emphasis: "outline",
|
|
69
71
|
size: "small",
|
|
70
72
|
iconName: "arrow_forward",
|
|
71
73
|
classNames: "ds-group-header__arrow ds-group-header__arrow--right",
|
|
@@ -49,7 +49,7 @@ $ds-group-header__icon-size: 24px;
|
|
|
49
49
|
|
|
50
50
|
.ds-group-header__right-link,
|
|
51
51
|
.ds-group-header__icon,
|
|
52
|
-
.ds-btn
|
|
52
|
+
.ds-btn--toggle {
|
|
53
53
|
flex-shrink: 0;
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -58,15 +58,15 @@ $ds-group-header__icon-size: 24px;
|
|
|
58
58
|
flex-shrink: 0;
|
|
59
59
|
align-items: center;
|
|
60
60
|
|
|
61
|
-
.ds-
|
|
61
|
+
.ds-btn {
|
|
62
62
|
margin: ds-spacing(0 $ds-s-050);
|
|
63
|
-
+ .ds-
|
|
63
|
+
+ .ds-btn {
|
|
64
64
|
margin: ds-spacing(0 0 0 $ds-s-075);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
.ds-btn
|
|
69
|
+
.ds-btn--toggle {
|
|
70
70
|
align-self: center;
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -12,8 +12,9 @@
|
|
|
12
12
|
|:--- | :--- | :--- | :--- | :--- | :--- |
|
|
13
13
|
|iconName | String | yes | add, arrow_back, arrow_forward etc | | For all available icons see: https://designsystem.dn.se/?path=/story/foundations-icons--all-icons |
|
|
14
14
|
|disabled | bool | no | true, false | false | Note: only works on button-tag, not on a-tag |
|
|
15
|
-
|variant | String | no |
|
|
16
|
-
|
|
|
15
|
+
|variant | String | no | primary, secondary, brand, staticWhite | primary | Design variant |
|
|
16
|
+
|emphasis | String | no | default, elevated, outline, transparent | default | |
|
|
17
|
+
|size| String | no | small, medium, large, xlarge | medium | |
|
|
17
18
|
|loading | bool | no | true, false | false | |
|
|
18
19
|
|a11y.visuallyHidden | Object | no | | | Ex. a11y: { visuallyHidden: "Dela på TikTok" } |
|
|
19
20
|
|href | String | no | | | If href is set the button will be rendered as an a-tag |
|
|
@@ -31,7 +32,8 @@ These are copy paste friendly examples to quickliy get started using a component
|
|
|
31
32
|
{% from '@bonniernews/dn-design-system-web/components/icon-button/icon-button.njk' import IconButton %}
|
|
32
33
|
|
|
33
34
|
{{ IconButton({
|
|
34
|
-
variant: '
|
|
35
|
+
variant: 'primary',
|
|
36
|
+
emphasis: 'outline',
|
|
35
37
|
size: 'default',
|
|
36
38
|
iconName: 'arrow_forward',
|
|
37
39
|
attributes: { 'aria-label': 'Nästa' }
|
|
@@ -1,53 +1,20 @@
|
|
|
1
|
-
{% from '@bonniernews/dn-design-system-web/components/
|
|
2
|
-
{% from '@bonniernews/dn-design-system-web/foundations/a11y/visually-hidden.njk' import VisuallyHidden %}
|
|
3
|
-
{% from '@bonniernews/dn-design-system-web/components/spinner/spinner.njk' import Spinner %}
|
|
4
|
-
{% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
|
|
1
|
+
{% from '@bonniernews/dn-design-system-web/components/button/button.njk' import Button %}
|
|
5
2
|
|
|
6
|
-
{% macro IconButton(params
|
|
7
|
-
{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
{%- set loadingHtml %}
|
|
24
|
-
{{ Spinner({ size: "small", additionalClasses: "primary", forcePx: params.forcePx, attributes: { "aria-hidden": "true" } }) }}
|
|
25
|
-
{% endset %}
|
|
26
|
-
|
|
27
|
-
{%- if params.a11y and params.a11y.visuallyHidden %}
|
|
28
|
-
{% set visuallyHidden = VisuallyHidden({ text: params.a11y.visuallyHidden }) %}
|
|
29
|
-
{% endif %}
|
|
30
|
-
|
|
31
|
-
{%- if isToggle %}
|
|
32
|
-
<button type="button" role="switch" aria-checked="{{ "true" if params.selected else "false" }}" class="{{ classes }}" {{ "disabled" if params.disabled }} {{- attributes | safe }}>
|
|
33
|
-
{{- visuallyHidden | safe if visuallyHidden -}}
|
|
34
|
-
<span class="{{ componentClassName + '__off' }}" aria-hidden="true">{{ IconUse({ icon: params.iconName }) }}</span>
|
|
35
|
-
<span class="{{ componentClassName + '__on' }}" aria-hidden="true">{{ IconUse({ icon: params.selectedIconName }) }}</span>
|
|
36
|
-
{{ loadingHtml | safe }}
|
|
37
|
-
</button>
|
|
38
|
-
{% else %}
|
|
39
|
-
{% if params.href %}
|
|
40
|
-
<a href="{{ params.href | default('#', true) }}" class="{{ classes }}" {{- attributes | safe }}>
|
|
41
|
-
{{- visuallyHidden | safe if visuallyHidden -}}
|
|
42
|
-
{{ IconUse({ icon: params.iconName, attributes: { "aria-hidden": "true" } }) }}
|
|
43
|
-
{{ loadingHtml | safe }}
|
|
44
|
-
</a>
|
|
45
|
-
{% else %}
|
|
46
|
-
<button type="button" class="{{ classes }}" {{ "disabled" if params.disabled }} {{- attributes | safe }}>
|
|
47
|
-
{{- visuallyHidden | safe if visuallyHidden -}}
|
|
48
|
-
{{ IconUse({ icon: params.iconName, attributes: { "aria-hidden": "true" } }) }}
|
|
49
|
-
{{ loadingHtml | safe }}
|
|
50
|
-
</button>
|
|
51
|
-
{% endif %}
|
|
52
|
-
{% endif %}
|
|
3
|
+
{% macro IconButton(params) %}
|
|
4
|
+
{{ Button({
|
|
5
|
+
isIconBtn: true,
|
|
6
|
+
isToggle: params.isToggle,
|
|
7
|
+
variant: params.variant,
|
|
8
|
+
emphasis: params.emphasis,
|
|
9
|
+
disabled: params.disabled,
|
|
10
|
+
size: params.size,
|
|
11
|
+
iconName: params.iconName,
|
|
12
|
+
selectedIconName: params.selectedIconName,
|
|
13
|
+
loading: params.loading,
|
|
14
|
+
selected: params.selected,
|
|
15
|
+
forcePx: params.forcePx,
|
|
16
|
+
classNames: params.classNames,
|
|
17
|
+
attributes: params.attributes,
|
|
18
|
+
a11y: params.a11y
|
|
19
|
+
}) }}
|
|
53
20
|
{% endmacro %}
|
|
@@ -1,141 +1,34 @@
|
|
|
1
1
|
@use "../../foundations/helpers/forward.helpers.scss" as *;
|
|
2
|
-
@use "../
|
|
3
|
-
@use "../spinner/spinner.scss" as *;
|
|
2
|
+
@use "../button/button.scss" as *;
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
.ds-btn.ds-btn--icon-only {
|
|
5
|
+
border-radius: 50%;
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
--ds-icon-btn__background-color-hover: #{$ds-color-component-primary-overlay};
|
|
13
|
-
--ds-icon-btn__background-color-active: #{$ds-color-component-primary-overlay-02};
|
|
14
|
-
--ds-icon-btn__border-color: transparent;
|
|
15
|
-
--ds-icon-btn__outline-color: #{$ds-color-border-focus-02};
|
|
16
|
-
--ds-icon-btn__color: #{$ds-color-icon-primary};
|
|
17
|
-
|
|
18
|
-
&--outlined {
|
|
19
|
-
--ds-icon-btn__background-color: #{$ds-color-component-secondary};
|
|
20
|
-
--ds-icon-btn__border-color: #{$ds-color-border-primary-02};
|
|
21
|
-
--ds-icon-btn__color: #{$ds-color-icon-primary};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
&--elevated {
|
|
25
|
-
box-shadow: ds-shadow-get-box-shadow($ds-shadow-elevation-m);
|
|
26
|
-
--ds-icon-btn__background-color: #{$ds-color-component-secondary};
|
|
27
|
-
--ds-icon-btn__border-color: #{$ds-color-border-primary-02};
|
|
28
|
-
--ds-icon-btn__color: #{$ds-color-icon-primary};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
&--on-media {
|
|
32
|
-
--ds-icon-btn__background-color: #{$ds-color-static-transparent-black};
|
|
33
|
-
--ds-icon-btn__color: #{$ds-color-static-white};
|
|
34
|
-
@include ds-hover() {
|
|
35
|
-
&:hover:not(.ds-loading)::before {
|
|
36
|
-
--ds-icon-btn__background-color-hover: #{$ds-color-static-transparent-white-10};
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
&:active:not(.ds-loading)::before {
|
|
40
|
-
--ds-icon-btn__background-color-active: $ds-color-static-transparent-white-10;
|
|
41
|
-
}
|
|
42
|
-
&:disabled:not(.ds-loading) {
|
|
43
|
-
color: $ds-color-static-white;
|
|
44
|
-
&::before {
|
|
45
|
-
background-color: transparent;
|
|
46
|
-
}
|
|
7
|
+
&.ds-btn--small {
|
|
8
|
+
padding: ds-px-to-rem(ds-spacing($ds-s-025) - $ds-btn-outlined__border-width);
|
|
9
|
+
@at-root .ds-force-px#{&} {
|
|
10
|
+
padding: ds-spacing($ds-s-025) - $ds-btn-outlined__border-width;
|
|
47
11
|
}
|
|
48
|
-
&:focus-visible {
|
|
49
|
-
--ds-icon-btn__outline-color: #{$ds-color-static-white};
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
&--outlined:disabled,
|
|
54
|
-
&--elevated:disabled,
|
|
55
|
-
&--on-media:disabled {
|
|
56
|
-
--ds-icon-btn__border-color: #{$ds-color-border-primary};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
&.ds-force-px {
|
|
60
|
-
--ds-icon-btn__icon-size: 24px;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
&.ds-icon-btn--small {
|
|
64
|
-
--ds-icon-btn__padding: #{2px - $ds-btn-outlined__border-width};
|
|
65
12
|
}
|
|
66
13
|
|
|
67
|
-
&.ds-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
cursor: pointer;
|
|
72
|
-
background-color: var(--ds-icon-btn__background-color);
|
|
73
|
-
color: var(--ds-icon-btn__color);
|
|
74
|
-
box-sizing: border-box;
|
|
75
|
-
border-radius: $ds-icon-btn__border-radius;
|
|
76
|
-
border: $ds-btn-outlined__border-width solid var(--ds-icon-btn__border-color);
|
|
77
|
-
margin: 0;
|
|
78
|
-
display: inline-flex;
|
|
79
|
-
align-items: center;
|
|
80
|
-
justify-content: center;
|
|
81
|
-
position: relative;
|
|
82
|
-
padding: var(--ds-icon-btn__padding);
|
|
83
|
-
|
|
84
|
-
span {
|
|
85
|
-
pointer-events: none;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
&::before {
|
|
89
|
-
content: "";
|
|
90
|
-
border-radius: inherit;
|
|
91
|
-
pointer-events: none;
|
|
92
|
-
position: absolute;
|
|
93
|
-
top: -$ds-btn-outlined__border-width;
|
|
94
|
-
left: -$ds-btn-outlined__border-width;
|
|
95
|
-
bottom: -$ds-btn-outlined__border-width;
|
|
96
|
-
right: -$ds-btn-outlined__border-width;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
@include min-click-surface();
|
|
100
|
-
|
|
101
|
-
.ds-icon {
|
|
102
|
-
position: relative;
|
|
103
|
-
display: flex;
|
|
104
|
-
height: var(--ds-icon-btn__icon-size);
|
|
105
|
-
width: var(--ds-icon-btn__icon-size);
|
|
106
|
-
margin: 0;
|
|
107
|
-
svg {
|
|
108
|
-
fill: currentColor;
|
|
14
|
+
&.ds-btn--medium {
|
|
15
|
+
padding: ds-px-to-rem(ds-spacing($ds-s-050) - $ds-btn-outlined__border-width);
|
|
16
|
+
@at-root .ds-force-px#{&} {
|
|
17
|
+
padding: ds-spacing($ds-s-050) - $ds-btn-outlined__border-width;
|
|
109
18
|
}
|
|
110
19
|
}
|
|
111
20
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
21
|
+
&.ds-btn--large {
|
|
22
|
+
padding: ds-px-to-rem(ds-spacing($ds-s-075) - $ds-btn-outlined__border-width);
|
|
23
|
+
@at-root .ds-force-px#{&} {
|
|
24
|
+
padding: ds-spacing($ds-s-075) - $ds-btn-outlined__border-width;
|
|
115
25
|
}
|
|
116
26
|
}
|
|
117
|
-
&:active:not(.ds-loading)::before {
|
|
118
|
-
background-color: var(--ds-icon-btn__background-color-active);
|
|
119
|
-
}
|
|
120
27
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
&:disabled:not(.ds-loading) {
|
|
126
|
-
cursor: not-allowed;
|
|
127
|
-
color: $ds-color-icon-disabled;
|
|
128
|
-
outline: none;
|
|
129
|
-
&::before {
|
|
130
|
-
background-color: transparent;
|
|
28
|
+
&.ds-btn--xlarge {
|
|
29
|
+
padding: ds-px-to-rem(ds-spacing($ds-s-075) - $ds-btn-outlined__border-width);
|
|
30
|
+
@at-root .ds-force-px#{&} {
|
|
31
|
+
padding: ds-spacing($ds-s-075) - $ds-btn-outlined__border-width;
|
|
131
32
|
}
|
|
132
33
|
}
|
|
133
|
-
|
|
134
|
-
@at-root a#{&} {
|
|
135
|
-
box-sizing: border-box;
|
|
136
|
-
text-align: center;
|
|
137
|
-
text-decoration: none;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
@include ds-loading();
|
|
141
34
|
}
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
|:--- | :--- | :--- | :--- | :--- | :--- |
|
|
13
13
|
|selected | bool | no | true, false | false | |
|
|
14
14
|
|iconName | String | yes | add, arrow_back, arrow_forward etc | | For all available icons see: https://designsystem.dn.se/?path=/story/foundations-icons--all-icons |
|
|
15
|
-
|selectedIconName | String | yes | add, arrow_back, arrow_forward etc | | For all available icons see: https://designsystem.dn.se/?path=/story/foundations-icons--all-icons |
|
|
15
|
+
|selectedIconName | String | yes | add, arrow_back, arrow_forward etc | | For all available icons see: https://designsystem.dn.se/?path=/story/foundations-icons--all-icons |
|
|
16
16
|
|disabled | bool | no | true, false | false | Note: only works on button-tag, not on a-tag |
|
|
17
|
-
|variant | String | no |
|
|
18
|
-
|
|
|
17
|
+
|variant | String | no | primary, secondary, brand, staticWhite | primary | Design variant |
|
|
18
|
+
|emphasis | String | no | default, elevated, outline, transparent | default | |
|
|
19
|
+
|size| String | no | small, medium, large | medium | |
|
|
19
20
|
|loading | bool | no | true, false | false | |
|
|
20
|
-
|a11y.visuallyHidden | Object | no | | | Ex. a11y: { visuallyHidden: "Dela på TikTok" } |
|
|
21
21
|
|attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
|
|
22
22
|
|classNames | String | no | | | Ex. "my-special-class" |
|
|
23
23
|
|forcePx | bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
|
|
@@ -32,7 +32,7 @@ These are copy paste friendly examples to quickliy get started using a component
|
|
|
32
32
|
{% from '@bonniernews/dn-design-system-web/components/icon-button-toggle/icon-button-toggle.njk' import IconButtonToggle %}
|
|
33
33
|
|
|
34
34
|
{{ IconButtonToggle({
|
|
35
|
-
variant: '
|
|
35
|
+
variant: 'primary',
|
|
36
36
|
size: 'default',
|
|
37
37
|
iconName: 'bookmarked',
|
|
38
38
|
selectedIconName: 'bookmark-fill'
|
|
@@ -47,7 +47,7 @@ These are copy paste friendly examples to quickliy get started using a component
|
|
|
47
47
|
### Javascript
|
|
48
48
|
|
|
49
49
|
```javascript
|
|
50
|
-
import
|
|
51
|
-
const toggleElements = Array.from(document.getElementsByClassName("ds-
|
|
52
|
-
|
|
50
|
+
import dsButtonToggle from '@bonniernews/dn-design-system-web/components/button/button.js'
|
|
51
|
+
const toggleElements = Array.from(document.getElementsByClassName("ds-btn--toggle"));
|
|
52
|
+
dsButtonToggle(toggleElements);
|
|
53
53
|
```
|