@bonniernews/dn-design-system-web 4.1.0-alpha.1 → 4.1.0-alpha.3
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 +18 -0
- package/components/button-toggle/README.md +1 -1
- package/components/floating-button/README.md +41 -0
- package/components/floating-button/floating-button.njk +54 -0
- package/components/floating-button/floating-button.scss +133 -0
- package/components/group-header/README.md +44 -0
- package/components/group-header/group-header.njk +42 -0
- package/components/group-header/group-header.scss +49 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
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.3 (2023-08-31)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **web:** floating button ([#967](https://github.com/BonnierNews/dn-design-system/issues/967)) ([34aff80](https://github.com/BonnierNews/dn-design-system/commit/34aff802da810baab13c6e872fd66de13a0dd2a6))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## 4.1.0-alpha.2 (2023-08-25)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* **web:** implement the groupheader component ([#961](https://github.com/BonnierNews/dn-design-system/issues/961)) ([7767031](https://github.com/BonnierNews/dn-design-system/commit/77670310626cbbe1516e5fd0937c300c6938dbcb))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
6
24
|
## 4.1.0-alpha.1 (2023-08-24)
|
|
7
25
|
|
|
8
26
|
**Note:** Version bump only for package @bonniernews/dn-design-system-web
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|selectedText | String | yes | | | |
|
|
16
16
|
|disabled | bool | no | true, false | false | |
|
|
17
17
|
|variant | String | no | brand, SecondaryFilled | brand | Design variant |
|
|
18
|
-
|size| String | no | default, small | default | |
|
|
18
|
+
|size| String | no | default, small, xsmall | default | |
|
|
19
19
|
|fullWidth | bool | no | true, false | false | Button will be full width on both desktop and mobile |
|
|
20
20
|
|condensed | bool | no | true, false | false | Condensed reduces spacing to a bare minimum, use with care since this might make touch target area smaller than recommended size |
|
|
21
21
|
|mobile.fullWidth | bool | no | true, false | false | Ex mobile: { fullWidth: true } |
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
iconPosition: 'left',
|
|
34
|
+
iconName: 'arrow_forward',
|
|
35
|
+
})}}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### SCSS
|
|
39
|
+
```scss
|
|
40
|
+
@use "@bonniernews/dn-design-system-web/components/floating-button/floating-button";
|
|
41
|
+
```
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
- GitHub: [BonnierNews/dn-design-system/../web/src/components/group-header](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/group-header)
|
|
2
|
+
- Storybook: [GroupHeader](https://designsystem.dn.se/?path=/docs/basic-groupheader--docs)
|
|
3
|
+
- Storybook (Latest): [GroupHeader](https://designsystem.dn.se/?path=/docs/basic-groupheader--docs)
|
|
4
|
+
|
|
5
|
+
----
|
|
6
|
+
|
|
7
|
+
# GroupHeader
|
|
8
|
+
|
|
9
|
+
## Parameters
|
|
10
|
+
|
|
11
|
+
|parameter | type | required | options | default | description |
|
|
12
|
+
|:--- | :--- | :--- | :--- | :--- | :--- |
|
|
13
|
+
|title | string | yes | | | The title text |
|
|
14
|
+
|variant | string | no | icon, link, toggle | icon | The variant to render |
|
|
15
|
+
|href | string | no | | | If given, the title is rendered as a link. Only available for variants `icon` and `link` |
|
|
16
|
+
|linkText | string | no | | | The link text to render (only for variant `link`) |
|
|
17
|
+
|toggle | object | no | | | Arguments to the ToggleButton (only for variant `toggle`) |
|
|
18
|
+
|classNames | String | no | | | Ex. "my-special-class" |
|
|
19
|
+
|attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
|
|
20
|
+
|
|
21
|
+
Depending on variant, only one of `toggle`, `linkText` is allowed. In `icon` and `link` mode, the `href` is required to show the ornament.
|
|
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/group-header/group-header.njk' import GroupHeader %}
|
|
31
|
+
|
|
32
|
+
{{ call GroupHeader({
|
|
33
|
+
title: "Dagens Nyheter",
|
|
34
|
+
href: "https://www.dn.se/"
|
|
35
|
+
}) }}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### SCSS
|
|
39
|
+
```scss
|
|
40
|
+
@use "@bonniernews/dn-design-system-web/components/group-header/group-header";
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### JS
|
|
44
|
+
If you provide the `toggle` parameter, you might need to initiate that component, [as per the documentation](https://designsystem.dn.se/?path=/readmetab/basic-buttons-buttontoggle--docs).
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
|
|
2
|
+
{% from '@bonniernews/dn-design-system-web/components/icon-sprite/icon-sprite.njk' import IconUse %}
|
|
3
|
+
{% from '@bonniernews/dn-design-system-web/components/button-toggle/button-toggle.njk' import ButtonToggle %}
|
|
4
|
+
|
|
5
|
+
{% macro GroupHeader(params) %}
|
|
6
|
+
{% set componentClassName = "ds-group-header" %}
|
|
7
|
+
{% set classNamePrefix = componentClassName + "--" %}
|
|
8
|
+
{% set variant = [] %}
|
|
9
|
+
{% set attributes = getAttributes(params.attributes) %}
|
|
10
|
+
|
|
11
|
+
{% if params.classNames %}
|
|
12
|
+
{% set variant = (variant.push(params.classNames), variant) %}
|
|
13
|
+
{% endif%}
|
|
14
|
+
|
|
15
|
+
{% set classes = componentClassName + " " + variant | join(" ") %}
|
|
16
|
+
|
|
17
|
+
{% set groupHeaderInner %}
|
|
18
|
+
<h2 class="{{ componentClassName + '__title'}}">{{ params.title}}</h2>
|
|
19
|
+
|
|
20
|
+
{% if params.variant == 'toggle' and params.toggle %}
|
|
21
|
+
{# Could we add defaults here? #}
|
|
22
|
+
{{ ButtonToggle(params.toggle) }}
|
|
23
|
+
{% elif params.variant == 'link' and params.linkText and params.href %}
|
|
24
|
+
<span class="{{ componentClassName + '__right-link' }}">
|
|
25
|
+
{{ params.linkText }}
|
|
26
|
+
</span>
|
|
27
|
+
{% elif (params.variant == 'icon' or not params.variant) and params.href %}
|
|
28
|
+
{{ IconUse({ icon: "arrow_forward" }) }}
|
|
29
|
+
{% endif %}
|
|
30
|
+
{% endset %}
|
|
31
|
+
|
|
32
|
+
{% if (params.variant == 'link' or params.variant == 'icon' or not params.variant) and params.href %}
|
|
33
|
+
<a class="{{ classes }} {{ componentClassName + '--link'}}" href="{{ params.titleHref }}" {{ attributes | safe }}>
|
|
34
|
+
{{ groupHeaderInner | safe }}
|
|
35
|
+
</a>
|
|
36
|
+
{% else %}
|
|
37
|
+
<div class="{{ classes }}" {{ attributes | safe }}>
|
|
38
|
+
{{ groupHeaderInner | safe }}
|
|
39
|
+
</div>
|
|
40
|
+
{% endif %}
|
|
41
|
+
|
|
42
|
+
{% endmacro %}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
@use "../../foundations/helpers/forward.helpers.scss" as *;
|
|
2
|
+
@use "../button-toggle/button-toggle.scss";
|
|
3
|
+
|
|
4
|
+
.ds-group-header {
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
justify-content: space-between;
|
|
8
|
+
background: $ds-color-background-primary;
|
|
9
|
+
color: $ds-color-text-primary;
|
|
10
|
+
padding: ds-spacing-component(0 $ds-sc-x4);
|
|
11
|
+
@include ds-typography($ds-typography-functional-body02regular);
|
|
12
|
+
|
|
13
|
+
.ds-group-header__right-link,
|
|
14
|
+
.ds-btn-toggle,
|
|
15
|
+
.ds-icon {
|
|
16
|
+
flex-shrink: 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.ds-group-header__right-link {
|
|
20
|
+
@include ds-link($ds-link-paragraph);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.ds-icon {
|
|
24
|
+
height: 24px;
|
|
25
|
+
width: 24px;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
&.ds-group-header--link {
|
|
29
|
+
@include ds-link($ds-link-list);
|
|
30
|
+
|
|
31
|
+
@include ds-hover(true) {
|
|
32
|
+
text-decoration: none;
|
|
33
|
+
|
|
34
|
+
.ds-group-header__title {
|
|
35
|
+
@include ds-underline(1px, 2px);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.ds-group-header__right-link {
|
|
39
|
+
text-decoration: none;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.ds-group-header__title {
|
|
45
|
+
padding: ds-spacing-component($ds-sc-x3 0);
|
|
46
|
+
@include ds-typography($ds-typography-functional-body02bold);
|
|
47
|
+
margin: 0;
|
|
48
|
+
}
|
|
49
|
+
}
|
package/package.json
CHANGED