@bonniernews/dn-design-system-web 4.1.0-alpha.2 → 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
CHANGED
|
@@ -3,6 +3,15 @@
|
|
|
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
|
+
|
|
6
15
|
## 4.1.0-alpha.2 (2023-08-25)
|
|
7
16
|
|
|
8
17
|
|
|
@@ -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
|
+
}
|
package/package.json
CHANGED