@bonniernews/dn-design-system-web 14.3.9 → 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 (95) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/components/article-body-image/README-UXD.md +0 -0
  3. package/components/article-top-image/README-UXD.md +0 -0
  4. package/components/badge/README-UXD.md +0 -0
  5. package/components/blocked-content/README-UXD.md +0 -0
  6. package/components/blocked-content/blocked-content.js +1 -1
  7. package/components/blocked-content/blocked-content.njk +2 -2
  8. package/components/buddy-menu/README-UXD.md +0 -0
  9. package/components/button/README-UXD.md +40 -0
  10. package/components/button/README.md +4 -2
  11. package/components/{button-toggle/button-toggle.js → button/button.js} +3 -3
  12. package/components/button/button.njk +62 -15
  13. package/components/button/button.scss +179 -121
  14. package/components/button-toggle/README-UXD.md +0 -0
  15. package/components/button-toggle/README.md +4 -4
  16. package/components/button-toggle/button-toggle.njk +17 -36
  17. package/components/button-toggle/button-toggle.scss +1 -215
  18. package/components/byline/README-UXD.md +0 -0
  19. package/components/byline/README.md +2 -2
  20. package/components/byline/byline.njk +2 -2
  21. package/components/checkbox/README-UXD.md +0 -0
  22. package/components/direkt-circle/README-UXD.md +0 -0
  23. package/components/disclaimer/README-UXD.md +0 -0
  24. package/components/divider/README-UXD.md +0 -0
  25. package/components/factbox/README-UXD.md +0 -40
  26. package/components/factbox/factbox.njk +4 -4
  27. package/components/floating-button/README-UXD.md +0 -0
  28. package/components/footer/README-UXD.md +0 -0
  29. package/components/game-header/README-UXD.md +0 -0
  30. package/components/group-header/README-UXD.md +0 -0
  31. package/components/group-header/group-header.njk +5 -3
  32. package/components/group-header/group-header.scss +4 -4
  33. package/components/icon-button/README-UXD.md +0 -0
  34. package/components/icon-button/README.md +5 -3
  35. package/components/icon-button/icon-button.njk +18 -51
  36. package/components/icon-button/icon-button.scss +19 -126
  37. package/components/icon-button-toggle/README-UXD.md +0 -0
  38. package/components/icon-button-toggle/README.md +8 -8
  39. package/components/icon-button-toggle/icon-button-toggle.njk +14 -1
  40. package/components/icon-button-toggle/icon-button-toggle.scss +1 -17
  41. package/components/icon-sprite/README-UXD.md +0 -0
  42. package/components/icon-sprite/README.md +1 -0
  43. package/components/icon-with-wrapper/README-UXD.md +0 -0
  44. package/components/image-caption/README-UXD.md +0 -0
  45. package/components/link-box/README-UXD.md +0 -0
  46. package/components/list-item/README-UXD.md +0 -0
  47. package/components/list-item/list-item.js +2 -2
  48. package/components/list-item/list-item.njk +2 -2
  49. package/components/list-item/list-item.scss +1 -1
  50. package/components/modal/README-UXD.md +0 -0
  51. package/components/modal/modal.njk +3 -2
  52. package/components/modal/modal.scss +4 -4
  53. package/components/pictogram/README-UXD.md +0 -0
  54. package/components/quote/README-UXD.md +0 -0
  55. package/components/radio-button/README-UXD.md +0 -0
  56. package/components/spinner/README-UXD.md +0 -0
  57. package/components/switch/README-UXD.md +0 -0
  58. package/components/tag-header/README-UXD.md +0 -0
  59. package/components/tag-header/tag-header.njk +1 -1
  60. package/components/teaser-card/README-UXD.md +0 -0
  61. package/components/teaser-dot/README-UXD.md +0 -0
  62. package/components/teaser-footer/README-UXD.md +0 -0
  63. package/components/teaser-image/README-UXD.md +0 -0
  64. package/components/teaser-large/README-UXD.md +0 -0
  65. package/components/teaser-list-swipe/README-UXD.md +0 -0
  66. package/components/teaser-list-swipe/teaser-list-swipe.njk +4 -2
  67. package/components/teaser-list-vertical/README-UXD.md +0 -0
  68. package/components/teaser-list-vertical/teaser-list-vertical.njk +1 -1
  69. package/components/teaser-longlife/README-UXD.md +0 -0
  70. package/components/teaser-native/README-UXD.md +0 -0
  71. package/components/teaser-onsite/README-UXD.md +0 -0
  72. package/components/teaser-package/README-UXD.md +0 -0
  73. package/components/teaser-right-now/README-UXD.md +0 -0
  74. package/components/teaser-slideshow/README-UXD.md +0 -0
  75. package/components/teaser-split/README-UXD.md +0 -0
  76. package/components/teaser-standard/README-UXD.md +0 -0
  77. package/components/teaser-swipe-card/README-UXD.md +0 -0
  78. package/components/teaser-tipsa/README-UXD.md +0 -0
  79. package/components/text-button/README-UXD.md +0 -0
  80. package/components/text-button-toggle/README-UXD.md +0 -0
  81. package/components/text-input/README-UXD.md +0 -0
  82. package/components/text-input/text-input.scss +1 -1
  83. package/components/thematic-break/README-UXD.md +0 -0
  84. package/components/tooltip/README-UXD.md +0 -0
  85. package/components/video-caption/README-UXD.md +0 -0
  86. package/components/vip-badge/README-UXD.md +0 -0
  87. package/foundations/helpers/README-UXD.md +0 -0
  88. package/foundations/typography/README-UXD.md +0 -0
  89. package/introduction/README-UXD.md +1 -0
  90. package/introduction/README.md +19 -0
  91. package/package.json +1 -1
  92. package/components/floating-button/README.md +0 -41
  93. package/components/floating-button/floating-button.njk +0 -41
  94. package/components/floating-button/floating-button.scss +0 -145
  95. package/components/icon-button-toggle/icon-button-toggle.js +0 -21
@@ -1,141 +1,34 @@
1
1
  @use "../../foundations/helpers/forward.helpers.scss" as *;
2
- @use "../icon-sprite/icon-sprite.scss";
3
- @use "../spinner/spinner.scss" as *;
2
+ @use "../button/button.scss" as *;
4
3
 
5
- $ds-icon-btn__border-radius: 50%;
6
- $ds-btn-outlined__border-width: ds-metrics-border-width(x1);
4
+ .ds-btn.ds-btn--icon-only {
5
+ border-radius: 50%;
7
6
 
8
- .ds-icon-btn {
9
- --ds-icon-btn__padding: #{ds-spacing($ds-s-050)-$ds-btn-outlined__border-width};
10
- --ds-icon-btn__icon-size: #{ds-px-to-rem(24px)};
11
- --ds-icon-btn__background-color: transparent;
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-icon-btn--large {
68
- --ds-icon-btn__padding: #{ds-spacing($ds-s-075)-$ds-btn-outlined__border-width};
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
- @include ds-hover() {
113
- &:hover:not(.ds-loading)::before {
114
- background-color: var(--ds-icon-btn__background-color-hover);
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
- &:focus-visible {
122
- outline: ds-metrics-border-width(x2) solid var(--ds-icon-btn__outline-color);
123
- outline-offset: 2px;
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
  }
File without changes
@@ -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 |v
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 | outlined, transparent | outlined | Design variant |
18
- |size| String | no | default, small, large | default | |
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: 'outlined',
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 dsIconButtonToggle from '@bonniernews/dn-design-system-web/components/icon-button-toggle/icon-button-toggle.js'
51
- const toggleElements = Array.from(document.getElementsByClassName("ds-icon-btn--toggle"));
52
- dsIconButtonToggle(toggleElements);
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
  ```
@@ -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 *;
File without changes
@@ -3,6 +3,7 @@
3
3
  - Storybook (Latest): [Icon](https://designsystem-latest.dn.se/?path=/docs/foundations-icons--docs)
4
4
 
5
5
  ----
6
+
6
7
  # Icons
7
8
 
8
9
  There are three ways to use icons from DS:
File without changes
File without changes
File without changes
File without changes
@@ -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 {
File without changes
@@ -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
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -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,
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -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',
File without changes
@@ -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,
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -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);
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1 @@
1
+ ## UXD documentation
@@ -0,0 +1,19 @@
1
+ # DN Design system
2
+
3
+ <img src="/images/digital-dn.png" width="150">
4
+
5
+ The design system used by Dagens Nyheter.
6
+
7
+ ## Technical documentation
8
+
9
+ Foundations, components and helpers of DN design system for web
10
+
11
+ ### Useful links
12
+
13
+ Storybook: [https://designsystem.dn.se/](https://designsystem.dn.se/)
14
+
15
+ Github: [https://github.com/BonnierNews/dn-design-system/tree/main/web/src](https://github.com/BonnierNews/dn-design-system/tree/main/web/src)
16
+
17
+ Changelog: [https://github.com/BonnierNews/dn-design-system/blob/main/web/src/CHANGELOG.md](https://github.com/BonnierNews/dn-design-system/blob/main/web/src/CHANGELOG.md)
18
+
19
+ For specific instructions see each component or helper readme.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonniernews/dn-design-system-web",
3
- "version": "14.3.9",
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 %}