@bonniernews/dn-design-system-web 4.1.0-alpha.2 → 4.1.0-alpha.4

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 CHANGED
@@ -3,6 +3,30 @@
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
+ ## 4.1.0-alpha.4 (2023-09-04)
7
+
8
+
9
+ ### Features
10
+
11
+ * **web:** small version of text button ([#969](https://github.com/BonnierNews/dn-design-system/issues/969)) ([7774e0a](https://github.com/BonnierNews/dn-design-system/commit/7774e0aeaf9cc836a5775665259fcc7003dc0f7a))
12
+ * **web:** update typography for native puff ([#972](https://github.com/BonnierNews/dn-design-system/issues/972)) ([2ac880f](https://github.com/BonnierNews/dn-design-system/commit/2ac880f3394a8fba4bec6d97a5033181807e6a9a))
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * **web:** remove unused props from floating-button readme example ([#971](https://github.com/BonnierNews/dn-design-system/issues/971)) ([9f53f46](https://github.com/BonnierNews/dn-design-system/commit/9f53f460e041d385d6869e1acaa4126f8952a69d))
18
+
19
+
20
+
21
+ ## 4.1.0-alpha.3 (2023-08-31)
22
+
23
+
24
+ ### Features
25
+
26
+ * **web:** floating button ([#967](https://github.com/BonnierNews/dn-design-system/issues/967)) ([34aff80](https://github.com/BonnierNews/dn-design-system/commit/34aff802da810baab13c6e872fd66de13a0dd2a6))
27
+
28
+
29
+
6
30
  ## 4.1.0-alpha.2 (2023-08-25)
7
31
 
8
32
 
@@ -0,0 +1,40 @@
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
+ |loading | bool | no | true, false | false | |
17
+ |href | String | no | | | If href is set the button will be rendered as an a-tag |
18
+ |attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
19
+ |classNames | String | no | | | Ex. "my-special-class" |
20
+ |forcePx | bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
21
+
22
+ ## Minimum requirement example
23
+
24
+ ### Nunjucks
25
+
26
+ These are copy paste friendly examples to quickliy get started using a component.
27
+
28
+ ```html
29
+ {% from '@bonniernews/dn-design-system-web/components/floating-button/floating-button.njk' import FloatingButton %}
30
+
31
+ {{ FloatingButton({
32
+ text: 'With icon',
33
+ iconName: 'arrow_forward'
34
+ })}}
35
+ ```
36
+
37
+ ### SCSS
38
+ ```scss
39
+ @use "@bonniernews/dn-design-system-web/components/floating-button/floating-button";
40
+ ```
@@ -0,0 +1,54 @@
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 additionalClasses = [] %}
10
+ {%- set attributes = getAttributes(params.attributes) %}
11
+ {%- set ariaLabel = 'aria-label="' + text + '"' if not params.attributes["aria-label"] else "" %}
12
+
13
+ {%- set loadingHtml %}
14
+ {{ Spinner({ size: 'small', forcePx: params.forcePx }) }}
15
+ {% endset %}
16
+
17
+ {%- if params.loading %}
18
+ {% set additionalClasses = (additionalClasses.push("ds-loading"), additionalClasses) %}
19
+ {% endif %}
20
+
21
+ {%- if params.forcePx %}
22
+ {% set additionalClasses = (additionalClasses.push("ds-force-px"), additionalClasses) %}
23
+ {% endif %}
24
+
25
+ {%- if params.size and params.size != "default" %}
26
+ {% set additionalClasses = (additionalClasses.push(classNamePrefix + params.size), additionalClasses) %}
27
+ {% endif %}
28
+
29
+ {%- if params.iconName %}
30
+ {% set additionalClasses = (additionalClasses.push(classNamePrefix + "icon"), additionalClasses) %}
31
+ {% set iconSvg = IconUse({ icon: params.iconName }) %}
32
+ {% endif %}
33
+
34
+ {%- if params.classNames %}
35
+ {% set additionalClasses = (additionalClasses.push(params.classNames), additionalClasses) %}
36
+ {% endif%}
37
+
38
+ {%- set classes = componentClassName + " " + additionalClasses | join(" ") %}
39
+ {%- if params.href %}
40
+ <a href="{{ params.href | default('#', true) }}" {{ ariaLabel | safe }} class="{{ classes }}" {{- attributes | safe}}>
41
+ <span class="{{ componentClassName + '__inner' }}" aria-hidden="true">
42
+ <span>{{ text }}</span>
43
+ {{- iconSvg | safe if iconSvg -}} {{ loadingHtml | safe }}
44
+ </span>
45
+ </a>
46
+ {% else %}
47
+ <button {{ ariaLabel | safe }} class="{{ classes }}" {{ "disabled" if params.disabled }} {{- attributes | safe}}>
48
+ <span class="{{ componentClassName + '__inner' }}" aria-hidden="true">
49
+ <span>{{ text }}</span>
50
+ {{- iconSvg | safe if iconSvg -}} {{ loadingHtml | safe }}
51
+ </span>
52
+ </button>
53
+ {% endif %}
54
+ {% endmacro %}
@@ -0,0 +1,133 @@
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__icon-size: 24px;
7
+
8
+ .ds-floating-btn {
9
+ cursor: pointer;
10
+ background-color: transparent;
11
+ border: none;
12
+ display: inline-flex;
13
+ align-items: center;
14
+ justify-content: center;
15
+ padding: 0;
16
+
17
+ span {
18
+ pointer-events: none;
19
+ }
20
+
21
+ &:focus-visible {
22
+ outline: none;
23
+
24
+ .ds-floating-btn__inner {
25
+ outline: ds-metrics-border-width(x2) solid;
26
+ outline-offset: 2px;
27
+ outline-color: $ds-color-border-focus-02;
28
+ }
29
+ }
30
+
31
+ @at-root a#{&} {
32
+ box-sizing: border-box;
33
+ text-align: center;
34
+ text-decoration: none;
35
+ }
36
+
37
+ .ds-floating-btn__inner {
38
+ @include ds-typography($ds-typography-detailstandard-button);
39
+ color: $ds-color-text-secondary;
40
+ background-color: $ds-color-component-primary;
41
+ border-radius: 100px;
42
+ padding: ds-spacing-component($ds-sc-x3 $ds-sc-x5, rem);
43
+ position: relative;
44
+ box-shadow: ds-shadow-get-box-shadow($ds-shadow-drop-shadow-b);
45
+
46
+ &::before {
47
+ content: "";
48
+ border-radius: inherit;
49
+ pointer-events: none;
50
+ position: absolute;
51
+ top: 0;
52
+ bottom: 0;
53
+ left: 0;
54
+ right: 0;
55
+ }
56
+ }
57
+
58
+ @include ds-hover() {
59
+ &:hover:not(:disabled):not(.ds-loading) .ds-floating-btn__inner::before {
60
+ background-color: $ds-color-component-secondary-overlay;
61
+ }
62
+ }
63
+
64
+ &:active:not(:disabled):not(.ds-loading) .ds-floating-btn__inner::before {
65
+ background-color: $ds-color-component-secondary-overlay-02;
66
+ }
67
+
68
+ &:not(.ds-loading):disabled {
69
+ opacity: $ds-opacity-component-disabled;
70
+ cursor: not-allowed;
71
+ }
72
+
73
+ // we have to override spinner styling since spinner variant is based on "off" button variant
74
+ &.ds-loading {
75
+ .ds-spinner__inner {
76
+ border-top-color: $ds-color-icon-secondary;
77
+
78
+ &::before {
79
+ border-color: $ds-color-icon-secondary;
80
+ }
81
+ }
82
+ }
83
+
84
+ @include ds-loading();
85
+ }
86
+
87
+ .ds-floating-btn--small .ds-floating-btn__inner {
88
+ padding: ds-px-to-rem(ds-spacing-component($ds-sc-x2)) ds-px-to-rem(ds-spacing-component($ds-sc-x5));
89
+ }
90
+
91
+ .ds-floating-btn--icon .ds-floating-btn__inner {
92
+ display: inline-flex;
93
+ align-items: center;
94
+ justify-content: center;
95
+ padding-right: ds-px-to-rem(
96
+ ds-spacing-component($ds-sc-x5)
97
+ );
98
+
99
+ .ds-icon {
100
+ display: flex;
101
+ height: ds-px-to-rem($ds-floating-btn__icon-size);
102
+ width: ds-px-to-rem($ds-floating-btn__icon-size);
103
+ margin: ds-spacing-component(0 0 0 $ds-sc-x2, rem);
104
+
105
+ svg {
106
+ fill: currentColor;
107
+ }
108
+ }
109
+ }
110
+
111
+ .ds-floating-btn.ds-force-px {
112
+ .ds-floating-btn__inner {
113
+ padding: ds-spacing-component($ds-sc-x3 $ds-sc-x5);
114
+ @include ds-typography($ds-typography-detailstandard-button, true);
115
+ }
116
+
117
+ &.ds-floating-btn--icon .ds-floating-btn__inner {
118
+ .ds-icon {
119
+ margin: ds-spacing-component(0 0 0 $ds-sc-x2);
120
+ height: $ds-floating-btn__icon-size;
121
+ width: $ds-floating-btn__icon-size;
122
+ }
123
+ }
124
+
125
+ &.ds-floating-btn--small {
126
+ .ds-floating-btn__inner {
127
+ padding: ds-spacing-component($ds-sc-x2 $ds-sc-x5);
128
+ }
129
+ &.ds-floating-btn--icon .ds-floating-btn__inner {
130
+ padding-right: ds-spacing-component($ds-sc-x4);
131
+ }
132
+ }
133
+ }
@@ -18,16 +18,8 @@
18
18
  }
19
19
 
20
20
  .ds-teaser__title {
21
- font-family: $ds-font--arial;
22
- font-weight: 700;
23
- @include ds-mq-only-breakpoint(mobile) {
24
- font-size: ds-px-to-rem(20px);
25
- line-height: ds-px-to-rem(24px);
26
- }
27
- @include ds-mq-smallest-breakpoint(tablet) {
28
- font-size: ds-px-to-rem(32px);
29
- line-height: ds-px-to-rem(36px);
30
- }
21
+ @include ds-typography($ds-typography-expressive-heading02bold);
22
+ font-family: $ds-font--arial !important;
31
23
  }
32
24
 
33
25
  &::after {
@@ -47,6 +39,12 @@
47
39
  }
48
40
  }
49
41
 
42
+ &.ds-teaser--native-large {
43
+ .ds-teaser__title {
44
+ @include ds-typography($ds-typography-expressive-heading04bold);
45
+ }
46
+ }
47
+
50
48
  &.ds-teaser--native-right {
51
49
  @include ds-mq-smallest-breakpoint(tablet) {
52
50
  .ds-teaser__title {
@@ -57,6 +55,10 @@
57
55
  }
58
56
 
59
57
  &.ds-teaser--native-standard {
58
+ .ds-teaser__title {
59
+ @include ds-typography($ds-typography-expressive-heading03bold);
60
+ }
61
+
60
62
  .ds-teaser__media {
61
63
  margin-left: ds-spacing-component($ds-sc-x4);
62
64
  float: right;
@@ -11,6 +11,7 @@
11
11
  |parameter | type | required | options | default | description |
12
12
  |:--- | :--- | :--- | :--- | :--- | :--- |
13
13
  |text | String | yes | | | |
14
+ |size| String | no | default, small | default | |
14
15
  |disabled | bool | no | true, false | false | Note: only works on button-tag, not on a-tag |
15
16
  |fullWidth | bool | no | true, false | false | Button will be full width on both desktop and mobile |
16
17
  |mobile.fullWidth | bool | no | true, false | false | Ex mobile: { fullWidth: true } |
@@ -14,6 +14,10 @@
14
14
  {% set additionalClasses = (additionalClasses.push("ds-force-px"), additionalClasses) %}
15
15
  {% endif %}
16
16
 
17
+ {%- if params.size and params.size != "default" %}
18
+ {% set additionalClasses = (additionalClasses.push(classNamePrefix + params.size), additionalClasses) %}
19
+ {% endif %}
20
+
17
21
  {%- if params.fullWidth %}
18
22
  {% set additionalClasses = (additionalClasses.push(classNamePrefix + "full-width"), additionalClasses) %}
19
23
  {% endif %}
@@ -32,7 +36,11 @@
32
36
  {% endif %}
33
37
 
34
38
  {%- set loadingHtml %}
35
- {{ Spinner({ size: "small", variant: "primary", forcePx: params.forcePx }) }}
39
+ {% if (params.size == 'small') %}
40
+ {{ Spinner({ size: "xsmall", variant: "primary", forcePx: params.forcePx }) }}
41
+ {% else %}
42
+ {{ Spinner({ size: "small", variant: "primary", forcePx: params.forcePx }) }}
43
+ {% endif %}
36
44
  {% endset %}
37
45
 
38
46
  {%- if params.loading %}
@@ -5,6 +5,7 @@
5
5
  $ds-text-btn__min-clickable-area: 0;
6
6
  $ds-text-btn__underline-offset: 2px;
7
7
  $ds-text-btn__icon-size: 24px;
8
+ $ds-text-btn__icon-size-small: 20px;
8
9
 
9
10
  @mixin ds-text-btn-disabled() {
10
11
  cursor: not-allowed;
@@ -142,6 +143,54 @@ $ds-text-btn__icon-size: 24px;
142
143
  padding: ds-spacing-component($ds-sc-x3 $ds-sc-x2 $ds-sc-x3 $ds-sc-x3);
143
144
  }
144
145
 
146
+ .ds-text-btn--small {
147
+ .ds-text-btn__inner {
148
+ padding: ds-spacing-component($ds-sc-x2);
149
+
150
+ .ds-text-btn__text {
151
+ @include ds-typography($ds-typography-functional-body01regular);
152
+ @at-root .ds-force-px#{&} {
153
+ @include ds-typography($ds-typography-functional-body01regular, true);
154
+ }
155
+ }
156
+ }
157
+
158
+ &.ds-text-btn--icon-left .ds-text-btn__inner,
159
+ &.ds-text-btn--icon-right .ds-text-btn__inner {
160
+ .ds-icon {
161
+ height: ds-px-to-rem($ds-text-btn__icon-size-small);
162
+ width: ds-px-to-rem($ds-text-btn__icon-size-small);
163
+ margin: ds-spacing-component(0 0 0 $ds-sc-x1);
164
+ }
165
+ }
166
+
167
+ &.ds-text-btn--icon-left .ds-text-btn__inner {
168
+ padding: ds-spacing-component($ds-sc-x2 $ds-sc-x2 $ds-sc-x2 $ds-sc-x1);
169
+ }
170
+
171
+
172
+ &.ds-text-btn--icon-right .ds-text-btn__inner {
173
+ padding: ds-spacing-component($ds-sc-x2 $ds-sc-x1 $ds-sc-x2 $ds-sc-x2);
174
+ }
175
+ &.ds-text-btn--condensed {
176
+ &.ds-text-btn--icon-left .ds-text-btn__inner {
177
+ padding: ds-spacing-component($ds-sc-x1 $ds-sc-x1 $ds-sc-x1 0);
178
+ }
179
+
180
+ &.ds-text-btn--icon-right .ds-text-btn__inner {
181
+ padding: ds-spacing-component($ds-sc-x1 0 $ds-sc-x1 $ds-sc-x1);
182
+ }
183
+ }
184
+
185
+ &.ds-force-px {
186
+ &.ds-text-btn--icon-left .ds-text-btn__inner .ds-icon,
187
+ &.ds-text-btn--icon-right .ds-text-btn__inner .ds-icon {
188
+ height: $ds-text-btn__icon-size-small;
189
+ width: $ds-text-btn__icon-size-small;
190
+ }
191
+ }
192
+ }
193
+
145
194
  .ds-text-btn--condensed .ds-text-btn__inner {
146
195
  padding: ds-spacing-component($ds-sc-x1);
147
196
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonniernews/dn-design-system-web",
3
- "version": "4.1.0-alpha.2",
3
+ "version": "4.1.0-alpha.4",
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",