@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.
Files changed (36) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/components/blocked-content/blocked-content.js +1 -1
  3. package/components/blocked-content/blocked-content.njk +2 -2
  4. package/components/button/README-UXD.md +2 -2
  5. package/components/button/README.md +4 -2
  6. package/components/{button-toggle/button-toggle.js → button/button.js} +3 -3
  7. package/components/button/button.njk +62 -15
  8. package/components/button/button.scss +179 -121
  9. package/components/button-toggle/README.md +4 -4
  10. package/components/button-toggle/button-toggle.njk +17 -36
  11. package/components/button-toggle/button-toggle.scss +1 -215
  12. package/components/byline/README.md +2 -2
  13. package/components/byline/byline.njk +2 -2
  14. package/components/factbox/factbox.njk +4 -4
  15. package/components/group-header/group-header.njk +5 -3
  16. package/components/group-header/group-header.scss +4 -4
  17. package/components/icon-button/README.md +5 -3
  18. package/components/icon-button/icon-button.njk +18 -51
  19. package/components/icon-button/icon-button.scss +19 -126
  20. package/components/icon-button-toggle/README.md +8 -8
  21. package/components/icon-button-toggle/icon-button-toggle.njk +14 -1
  22. package/components/icon-button-toggle/icon-button-toggle.scss +1 -17
  23. package/components/list-item/list-item.js +2 -2
  24. package/components/list-item/list-item.njk +2 -2
  25. package/components/list-item/list-item.scss +1 -1
  26. package/components/modal/modal.njk +3 -2
  27. package/components/modal/modal.scss +4 -4
  28. package/components/tag-header/tag-header.njk +1 -1
  29. package/components/teaser-list-swipe/teaser-list-swipe.njk +4 -2
  30. package/components/teaser-list-vertical/teaser-list-vertical.njk +1 -1
  31. package/components/text-input/text-input.scss +1 -1
  32. package/package.json +1 -1
  33. package/components/floating-button/README.md +0 -41
  34. package/components/floating-button/floating-button.njk +0 -41
  35. package/components/floating-button/floating-button.scss +0 -145
  36. package/components/icon-button-toggle/icon-button-toggle.js +0 -21
@@ -1,5 +1,18 @@
1
1
  {% from '@bonniernews/dn-design-system-web/components/icon-button/icon-button.njk' import IconButton %}
2
2
 
3
3
  {% macro IconButtonToggle(params) %}
4
- {{ IconButton(params, true) }}
4
+ {{ IconButton({
5
+ isToggle: true,
6
+ variant: params.variant,
7
+ emphasis: params.emphasis,
8
+ disabled: params.disabled,
9
+ size: params.size,
10
+ iconName: params.iconName,
11
+ selectedIconName: params.selectedIconName,
12
+ loading: params.loading,
13
+ selected: params.selected,
14
+ forcePx: params.forcePx,
15
+ classNames: params.classNames,
16
+ attributes: params.attributes
17
+ }) }}
5
18
  {% endmacro %}
@@ -1,17 +1 @@
1
- @use "../../foundations/helpers/forward.helpers.scss" as *;
2
- @use "../icon-button/icon-button.scss";
3
-
4
- .ds-icon-btn--toggle {
5
- .ds-icon-btn__on {
6
- display: none;
7
- }
8
-
9
- &.ds-icon-btn--selected {
10
- .ds-icon-btn__on {
11
- display: flex;
12
- }
13
- .ds-icon-btn__off {
14
- display: none;
15
- }
16
- }
17
- }
1
+ @use "../icon-button/icon-button.scss" as *;
@@ -1,4 +1,4 @@
1
- import {dsButtonToggle} from '@bonniernews/dn-design-system-web/components/button-toggle/button-toggle';
1
+ import {dsButtonToggle} from '@bonniernews/dn-design-system-web/components/button/button';
2
2
 
3
3
  export {
4
4
  dsListItem,
@@ -23,7 +23,7 @@ function dsListItemAccordion(accordionEl) {
23
23
  }
24
24
 
25
25
  function dsListItemToggle(toggleEl) {
26
- const toggleElements = Array.from(toggleEl.getElementsByClassName("ds-btn-toggle"));
26
+ const toggleElements = Array.from(toggleEl.getElementsByClassName("ds-btn--toggle"));
27
27
  dsButtonToggle(toggleElements);
28
28
  }
29
29
 
@@ -147,10 +147,10 @@
147
147
  text: params.toggleText,
148
148
  selected: params.selected,
149
149
  selectedText: params.toggleSelectedText,
150
- variant: params.variant | default("secondaryFilled"),
150
+ variant: params.variant | default("secondary"),
151
151
  disabled: params.disabled,
152
152
  forcePx: params.forcePx,
153
- size: "xsmall",
153
+ size: "small",
154
154
  attributes: params.elementAttributes
155
155
  })}}
156
156
  {% endset %}
@@ -278,7 +278,7 @@ $ds-list-item__icon-size: 24px;
278
278
  .ds-list-item__titles {
279
279
  padding: ds-spacing($ds-s-100) 0;
280
280
  }
281
- .ds-btn-toggle {
281
+ .ds-btn--toggle {
282
282
  margin: ds-spacing(0 $ds-s-outer 0 $ds-s-100);
283
283
  }
284
284
  a {
@@ -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: "secondaryOutlined",
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-icon-btn.ds-modal__close {
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--primary:not(:only-child) {
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--secondaryOutlined:not(:only-child) {
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--secondaryOutlined:not(:only-child) {
122
+ .ds-btn--outline:not(:only-child) {
123
123
  margin-right: ds-spacing($ds-s-100);
124
124
  }
125
125
  }
@@ -32,7 +32,7 @@
32
32
  {% if params.toggle %}
33
33
  {{ ButtonToggle({
34
34
  variant: 'brand',
35
- size: 'small',
35
+ size: 'medium',
36
36
  text: params.toggleText,
37
37
  selectedText: params.toggleSelectedText,
38
38
  selected: params.toggleSelected,
@@ -42,7 +42,8 @@
42
42
  {% if arrowPosition === 'floating' %}
43
43
  {{ IconButton({
44
44
  iconName: 'arrow_back',
45
- variant: 'elevated',
45
+ variant: 'primary',
46
+ emphasis: 'outline',
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: 'elevated',
54
+ variant: 'primary',
55
+ emphasis: 'outline',
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',
@@ -35,7 +35,7 @@
35
35
  {{ Button({
36
36
  text: params.listLink.text,
37
37
  href: params.listLink.url,
38
- variant: 'secondaryFilled',
38
+ variant: 'secondary',
39
39
  fullWidth: true,
40
40
  classNames: params.listLink.classNames,
41
41
  attributes: params.listLink.attributes,
@@ -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-icon-btn.ds-text-input__password-toggle {
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonniernews/dn-design-system-web",
3
- "version": "14.3.10",
3
+ "version": "14.4.0-beta.0",
4
4
  "description": "DN design system for web.",
5
5
  "main": "index.js",
6
6
  "homepage": "https://github.com/BonnierNews/dn-design-system/tree/main/web/src#readme",
@@ -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
- }