@bonniernews/dn-design-system-web 14.0.4 → 15.0.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 +11 -0
- package/components/blocked-content/blocked-content.js +1 -1
- package/components/blocked-content/blocked-content.njk +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 -14
- package/components/button/button.scss +169 -110
- 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 +17 -51
- package/components/icon-button/icon-button.scss +19 -126
- package/components/icon-button-toggle/README.md +8 -7
- package/components/icon-button-toggle/icon-button-toggle.njk +15 -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
|
@@ -144,10 +144,10 @@
|
|
|
144
144
|
text: params.toggleText,
|
|
145
145
|
selected: params.selected,
|
|
146
146
|
selectedText: params.toggleSelectedText,
|
|
147
|
-
variant: params.variant | default("
|
|
147
|
+
variant: params.variant | default("secondary"),
|
|
148
148
|
disabled: params.disabled,
|
|
149
149
|
forcePx: params.forcePx,
|
|
150
|
-
size: "
|
|
150
|
+
size: "small",
|
|
151
151
|
attributes: params.elementAttributes
|
|
152
152
|
})}}
|
|
153
153
|
{% endset %}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
variant: "transparent",
|
|
21
21
|
size: "small",
|
|
22
22
|
iconName: "close",
|
|
23
|
-
classNames: "ds-modal__close"
|
|
23
|
+
classNames: "ds-modal__close ds-modal__close--icon"
|
|
24
24
|
})}}
|
|
25
25
|
|
|
26
26
|
{% if params.title %}
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
] | join(" ") %}
|
|
39
39
|
{{ Button({
|
|
40
40
|
text: params.secondaryButton.text,
|
|
41
|
-
variant: "
|
|
41
|
+
variant: "primary",
|
|
42
|
+
emphasis: "outline",
|
|
42
43
|
href: params.secondaryButton.href,
|
|
43
44
|
classNames: secondaryButtonClasses,
|
|
44
45
|
attributes: params.secondaryButton.attributes,
|
|
@@ -78,7 +78,7 @@ body.no-scroll {
|
|
|
78
78
|
border-radius: ds-border-radius(x1);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
.ds-
|
|
81
|
+
.ds-btn.ds-modal__close--icon {
|
|
82
82
|
position: absolute;
|
|
83
83
|
top: ds-spacing($ds-s-100);
|
|
84
84
|
right: ds-spacing($ds-s-100);
|
|
@@ -105,12 +105,12 @@ body.no-scroll {
|
|
|
105
105
|
display: flex;
|
|
106
106
|
flex-wrap: wrap;
|
|
107
107
|
|
|
108
|
-
.ds-btn--
|
|
108
|
+
.ds-btn--default:not(:only-child) {
|
|
109
109
|
order: 1;
|
|
110
110
|
margin-bottom: ds-spacing($ds-s-100);
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
.ds-btn--
|
|
113
|
+
.ds-btn--outline:not(:only-child) {
|
|
114
114
|
order: 2;
|
|
115
115
|
}
|
|
116
116
|
}
|
|
@@ -119,7 +119,7 @@ body.no-scroll {
|
|
|
119
119
|
display: flex;
|
|
120
120
|
justify-content: center;
|
|
121
121
|
|
|
122
|
-
.ds-btn--
|
|
122
|
+
.ds-btn--outline:not(:only-child) {
|
|
123
123
|
margin-right: ds-spacing($ds-s-100);
|
|
124
124
|
}
|
|
125
125
|
}
|
|
@@ -42,7 +42,8 @@
|
|
|
42
42
|
{% if arrowPosition === 'floating' %}
|
|
43
43
|
{{ IconButton({
|
|
44
44
|
iconName: 'arrow_back',
|
|
45
|
-
variant: '
|
|
45
|
+
variant: 'primary',
|
|
46
|
+
emphasis: 'elevated',
|
|
46
47
|
size: 'small',
|
|
47
48
|
attributes: { 'aria-label': 'Föregående' },
|
|
48
49
|
classNames: componentClassName + '__swipe-arrow ' + componentClassName + '__swipe-arrow--back hidden-mobile hidden-tablet',
|
|
@@ -50,7 +51,8 @@
|
|
|
50
51
|
}) }}
|
|
51
52
|
{{ IconButton({
|
|
52
53
|
iconName: 'arrow_forward',
|
|
53
|
-
variant: '
|
|
54
|
+
variant: 'primary',
|
|
55
|
+
emphasis: 'elevated',
|
|
54
56
|
size: 'small',
|
|
55
57
|
attributes: { 'aria-label': 'Nästa' },
|
|
56
58
|
classNames: componentClassName + '__swipe-arrow ' + componentClassName + '__swipe-arrow--forward hidden-mobile hidden-tablet',
|
|
@@ -95,7 +95,7 @@ $ds-text-input-toggle-btn__area: ($ds-text-input-toggle-btn__width + ds-spacing(
|
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
.ds-
|
|
98
|
+
.ds-btn.ds-text-input__password-toggle {
|
|
99
99
|
position: absolute;
|
|
100
100
|
top: ds-px-to-rem($ds-text-input-toggle-btn__top);
|
|
101
101
|
right: ds-spacing($ds-s-025);
|
package/package.json
CHANGED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
- GitHub: [BonnierNews/dn-design-system/../web/src/components/floating-button](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/floating-button)
|
|
2
|
-
- Storybook: [Button > Web](https://designsystem.dn.se/?path=/story/components-app-web-floatingbutton-web)
|
|
3
|
-
|
|
4
|
-
----
|
|
5
|
-
|
|
6
|
-
# FloatingButton
|
|
7
|
-
|
|
8
|
-
## Parameters
|
|
9
|
-
|
|
10
|
-
|parameter | type | required | options | default | description |
|
|
11
|
-
|:--- | :--- | :--- | :--- | :--- | :--- |
|
|
12
|
-
|text | String | yes | | | |
|
|
13
|
-
|disabled | bool | no | true, false | false | Note: only works on button-tag, not on a-tag |
|
|
14
|
-
|size| String | no | default, small | default | |
|
|
15
|
-
|iconName | String | no | add, arrow_back, arrow_forward etc | | For all available icons see: https://designsystem.dn.se/?path=/story/foundations-icon-web--all |
|
|
16
|
-
|iconPosition | String | no | none, left, right | none | |
|
|
17
|
-
|loading | bool | no | true, false | false | |
|
|
18
|
-
|href | String | no | | | If href is set the button will be rendered as an a-tag |
|
|
19
|
-
|attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
|
|
20
|
-
|classNames | String | no | | | Ex. "my-special-class" |
|
|
21
|
-
|forcePx | bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
|
|
22
|
-
|
|
23
|
-
## Minimum requirement example
|
|
24
|
-
|
|
25
|
-
### Nunjucks
|
|
26
|
-
|
|
27
|
-
These are copy paste friendly examples to quickliy get started using a component.
|
|
28
|
-
|
|
29
|
-
```html
|
|
30
|
-
{% from '@bonniernews/dn-design-system-web/components/floating-button/floating-button.njk' import FloatingButton %}
|
|
31
|
-
|
|
32
|
-
{{ FloatingButton({
|
|
33
|
-
text: 'With icon',
|
|
34
|
-
iconName: 'arrow_forward'
|
|
35
|
-
})}}
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
### SCSS
|
|
39
|
-
```scss
|
|
40
|
-
@use "@bonniernews/dn-design-system-web/components/floating-button/floating-button";
|
|
41
|
-
```
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
{% from '@bonniernews/dn-design-system-web/components/icon-sprite/icon-sprite.njk' import IconUse %}
|
|
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 %}
|
|
4
|
-
|
|
5
|
-
{% macro FloatingButton(params) %}
|
|
6
|
-
{%- set componentClassName = "ds-floating-btn" %}
|
|
7
|
-
{%- set classNamePrefix = componentClassName + "--" %}
|
|
8
|
-
{%- set text = params.text %}
|
|
9
|
-
{%- set attributes = getAttributes(params.attributes) %}
|
|
10
|
-
{%- set ariaLabel = 'aria-label="' + text + '"' if not params.attributes["aria-label"] else "" %}
|
|
11
|
-
|
|
12
|
-
{%- set loadingHtml %}
|
|
13
|
-
{{ Spinner({ size: 'small', forcePx: params.forcePx }) }}
|
|
14
|
-
{% endset %}
|
|
15
|
-
|
|
16
|
-
{%- if params.iconName and params.iconPosition and params.iconPosition != "none" %}
|
|
17
|
-
{% set iconSvg = IconUse({ icon: params.iconName, attributes: { "aria-hidden": "true" } }) %}
|
|
18
|
-
{% endif %}
|
|
19
|
-
|
|
20
|
-
{%- set classes = [
|
|
21
|
-
componentClassName,
|
|
22
|
-
"ds-force-px" if params.forcePx,
|
|
23
|
-
"ds-loading" if params.loading,
|
|
24
|
-
classNamePrefix + params.size if params.size and params.size !== "default",
|
|
25
|
-
classNamePrefix + "icon" if iconSvg,
|
|
26
|
-
classNamePrefix + "icon-" + params.iconPosition if iconSvg,
|
|
27
|
-
params.classNames if params.classNames
|
|
28
|
-
] | join(" ") %}
|
|
29
|
-
|
|
30
|
-
{%- if params.href %}
|
|
31
|
-
<a href="{{ params.href | default('#', true) }}" {{ ariaLabel | safe }} class="{{ classes }}" {{- attributes | safe}}>
|
|
32
|
-
<span aria-hidden="true">{{ text }}</span>
|
|
33
|
-
{{- iconSvg | safe if iconSvg -}} {{ loadingHtml | safe }}
|
|
34
|
-
</a>
|
|
35
|
-
{% else %}
|
|
36
|
-
<button {{ ariaLabel | safe }} class="{{ classes }}" {{ "disabled" if params.disabled }} {{- attributes | safe}}>
|
|
37
|
-
<span aria-hidden="true">{{ text }}</span>
|
|
38
|
-
{{- iconSvg | safe if iconSvg -}} {{ loadingHtml | safe }}
|
|
39
|
-
</button>
|
|
40
|
-
{% endif %}
|
|
41
|
-
{% endmacro %}
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
@use "sass:math";
|
|
2
|
-
@use "../../foundations/helpers/forward.helpers.scss" as *;
|
|
3
|
-
@use "../icon-sprite/icon-sprite.scss";
|
|
4
|
-
@use "../spinner/spinner.scss" as *;
|
|
5
|
-
|
|
6
|
-
.ds-floating-btn {
|
|
7
|
-
--ds-floating-btn__padding: #{ds-spacing($ds-s-075 $ds-s-125, rem)};
|
|
8
|
-
--ds-floating-btn__icon-size: #{ds-px-to-rem(24px)};
|
|
9
|
-
|
|
10
|
-
&.ds-force-px {
|
|
11
|
-
--ds-floating-btn__padding: #{ds-spacing($ds-s-075 $ds-s-125)};
|
|
12
|
-
--ds-floating-btn__icon-size: 24px;
|
|
13
|
-
@include ds-typography($ds-typography-detailstandard-button, true);
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
&.ds-floating-btn--icon-left {
|
|
17
|
-
--ds-floating-btn__padding: #{ds-spacing($ds-s-075 $ds-s-125 $ds-s-075 $ds-s-100, rem)};
|
|
18
|
-
--ds-floating-btn__icon-margin: #{ds-spacing(0 $ds-s-050 0 0)};
|
|
19
|
-
|
|
20
|
-
&.ds-force-px {
|
|
21
|
-
--ds-floating-btn__padding: #{ds-spacing($ds-s-075 $ds-s-125 $ds-s-075 $ds-s-100)};
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
&.ds-floating-btn--icon-right {
|
|
26
|
-
--ds-floating-btn__padding: #{ds-spacing($ds-s-075 $ds-s-100 $ds-s-075 $ds-s-125, rem)};
|
|
27
|
-
--ds-floating-btn__icon-margin: #{ds-spacing(0 0 0 $ds-s-050)};
|
|
28
|
-
|
|
29
|
-
&.ds-force-px {
|
|
30
|
-
--ds-floating-btn__padding: #{ds-spacing($ds-s-075 $ds-s-100 $ds-s-075 $ds-s-125)};
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
&.ds-floating-btn--small {
|
|
35
|
-
--ds-floating-btn__padding: #{ds-spacing($ds-s-050 $ds-s-125, rem)};
|
|
36
|
-
|
|
37
|
-
&.ds-force-px {
|
|
38
|
-
--ds-floating-btn__padding: #{ds-spacing($ds-s-050 $ds-s-125)};
|
|
39
|
-
|
|
40
|
-
&.ds-floating-btn--icon-left {
|
|
41
|
-
--ds-floating-btn__padding: #{ds-spacing($ds-s-050 $ds-s-125 $ds-s-050 $ds-s-100)};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
&.ds-floating-btn--icon-right {
|
|
45
|
-
--ds-floating-btn__padding: #{ds-spacing($ds-s-050 $ds-s-100 $ds-s-050 $ds-s-125)};
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
&.ds-floating-btn--icon-left {
|
|
50
|
-
--ds-floating-btn__padding: #{ds-spacing($ds-s-050 $ds-s-125 $ds-s-050 $ds-s-100, rem)};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
&.ds-floating-btn--icon-right {
|
|
54
|
-
--ds-floating-btn__padding: #{ds-spacing($ds-s-050 $ds-s-100 $ds-s-050 $ds-s-125, rem)};
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
cursor: pointer;
|
|
59
|
-
@include ds-typography($ds-typography-detailstandard-button);
|
|
60
|
-
color: $ds-color-text-secondary;
|
|
61
|
-
background-color: $ds-color-component-primary;
|
|
62
|
-
border-radius: 100px;
|
|
63
|
-
padding: var(--ds-floating-btn__padding);
|
|
64
|
-
position: relative;
|
|
65
|
-
box-shadow: ds-shadow-get-box-shadow($ds-shadow-elevation-m);
|
|
66
|
-
border: none;
|
|
67
|
-
display: inline-flex;
|
|
68
|
-
align-items: center;
|
|
69
|
-
justify-content: center;
|
|
70
|
-
|
|
71
|
-
span {
|
|
72
|
-
pointer-events: none;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
&:focus-visible {
|
|
76
|
-
outline: ds-metrics-border-width(x2) solid;
|
|
77
|
-
outline-offset: 2px;
|
|
78
|
-
outline-color: $ds-color-border-focus-02;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
@at-root a#{&} {
|
|
82
|
-
box-sizing: border-box;
|
|
83
|
-
text-align: center;
|
|
84
|
-
text-decoration: none;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
&::before {
|
|
88
|
-
content: "";
|
|
89
|
-
border-radius: inherit;
|
|
90
|
-
pointer-events: none;
|
|
91
|
-
position: absolute;
|
|
92
|
-
top: 0;
|
|
93
|
-
bottom: 0;
|
|
94
|
-
left: 0;
|
|
95
|
-
right: 0;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
@include min-click-surface();
|
|
99
|
-
|
|
100
|
-
@include ds-hover() {
|
|
101
|
-
&:hover:not(:disabled):not(.ds-loading)::before {
|
|
102
|
-
background-color: $ds-color-component-secondary-overlay;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
&:active:not(:disabled):not(.ds-loading)::before {
|
|
107
|
-
background-color: $ds-color-component-secondary-overlay-02;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
&:not(.ds-loading):disabled {
|
|
111
|
-
opacity: $ds-opacity-component-disabled;
|
|
112
|
-
cursor: not-allowed;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// we have to override spinner styling since spinner variant is based on "off" button variant
|
|
116
|
-
&.ds-loading {
|
|
117
|
-
border-top-color: $ds-color-icon-secondary;
|
|
118
|
-
&::before {
|
|
119
|
-
border-color: $ds-color-icon-secondary;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
@include ds-loading();
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
.ds-floating-btn--icon {
|
|
127
|
-
display: inline-flex;
|
|
128
|
-
align-items: center;
|
|
129
|
-
justify-content: center;
|
|
130
|
-
|
|
131
|
-
.ds-icon {
|
|
132
|
-
display: flex;
|
|
133
|
-
margin: var(--ds-floating-btn__icon-margin);
|
|
134
|
-
height: var(--ds-floating-btn__icon-size);
|
|
135
|
-
width: var(--ds-floating-btn__icon-size);
|
|
136
|
-
|
|
137
|
-
svg {
|
|
138
|
-
fill: currentColor;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
.ds-floating-btn--icon-left {
|
|
144
|
-
flex-direction: row-reverse;
|
|
145
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
dsIconButtonToggle,
|
|
3
|
-
dsIconButtonToggleAll
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
function dsIconButtonToggle(toggleElements = []) {
|
|
7
|
-
if (!toggleElements.length) return;
|
|
8
|
-
toggleElements.forEach((toggleEl) => {
|
|
9
|
-
toggleEl.addEventListener("click", () => {
|
|
10
|
-
if (toggleEl.classList.contains("ds-icon-btn--disabled")) return;
|
|
11
|
-
toggleEl.classList.toggle("ds-icon-btn--selected");
|
|
12
|
-
const ariaChecked = toggleEl.getAttribute("aria-checked") === "true" ? "false" : "true";
|
|
13
|
-
toggleEl.setAttribute("aria-checked", ariaChecked);
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function dsIconButtonToggleAll() {
|
|
19
|
-
const toggleElements = Array.from(document.getElementsByClassName("ds-icon-btn--toggle"));
|
|
20
|
-
dsIconButtonToggle(toggleElements);
|
|
21
|
-
}
|