@bonniernews/dn-design-system-web 28.0.1-beta.0 → 28.0.1
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 +17 -0
- package/components/blocked-content/blocked-content.js +1 -1
- package/components/blocked-content/blocked-content.njk +2 -2
- package/components/buddy-menu/buddy-menu.njk +5 -5
- package/components/buddy-menu/buddy-menu.scss +1 -0
- package/components/button/README.md +8 -6
- package/components/button/button-types.ts +25 -34
- package/components/button/button.njk +15 -8
- package/components/button/button.scss +85 -58
- package/components/button-toggle/README.md +5 -8
- package/components/button-toggle/button-toggle.njk +0 -3
- package/components/divider/README.md +1 -1
- package/components/empty-state/empty-state.njk +3 -2
- package/components/factbox/factbox.njk +4 -4
- package/components/group-header/group-header.njk +10 -10
- package/components/group-header/group-header.scss +2 -1
- package/components/icon-button/README-NJK.md +47 -0
- package/components/icon-button/README-UXD.md +44 -0
- package/components/icon-button/README.md +31 -0
- package/components/icon-button/icon-button.njk +22 -0
- package/components/icon-button/icon-button.scss +32 -0
- package/components/icon-button-toggle/README-NJK.md +53 -0
- package/components/icon-button-toggle/README-UXD.md +0 -0
- package/components/icon-button-toggle/README.md +38 -0
- package/components/icon-button-toggle/icon-button-toggle.njk +18 -0
- package/components/icon-button-toggle/icon-button-toggle.scss +1 -0
- package/components/list-item/list-item-types.ts +3 -3
- package/components/list-item/list-item.njk +4 -4
- package/components/modal/modal.njk +8 -10
- package/components/modal/modal.scss +4 -3
- package/components/pagination/pagination.njk +1 -0
- package/components/profile-header/profile-header.njk +2 -2
- package/components/tag-header/tag-header.njk +2 -2
- package/components/teaser-list-swipe/teaser-list-swipe.njk +9 -9
- package/components/teaser-list-swipe/teaser-list-swipe.scss +3 -3
- package/components/teaser-list-vertical/teaser-list-vertical.njk +1 -1
- package/components/text-input/text-input.njk +3 -5
- package/components/text-input/text-input.scss +3 -2
- package/components/tooltip/tooltip.njk +4 -4
- package/components/tooltip/tooltip.scss +1 -0
- package/foundations/icons/icon.njk +15 -0
- package/foundations/icons/sprite.njk +1 -1
- package/foundations/icons/sprite.svg +1 -1
- package/foundations/icons/svg/auto-imported/autoplay.svg +3 -0
- package/foundations/icons/svg/auto-imported/notifications_off.svg +3 -0
- package/foundations/icons/svg/auto-imported/settings.svg +3 -0
- package/package.json +1 -1
- package/preact/components/buddy-menu/buddy-menu.js +69 -24
- package/preact/components/buddy-menu/buddy-menu.js.map +4 -4
- package/preact/components/button/button-base.d.ts +1 -1
- package/preact/components/button/button-base.js +12 -4
- package/preact/components/button/button-base.js.map +2 -2
- package/preact/components/button/button-types.d.ts +19 -24
- package/preact/components/button/button.d.ts +1 -1
- package/preact/components/button/button.js +17 -7
- package/preact/components/button/button.js.map +2 -2
- package/preact/components/button-toggle/button-toggle.d.ts +1 -1
- package/preact/components/button-toggle/button-toggle.js +14 -11
- package/preact/components/button-toggle/button-toggle.js.map +2 -2
- package/preact/components/checkbox/checkbox.js.map +2 -2
- package/preact/components/icon-button/icon-button.d.ts +10 -0
- package/preact/components/icon-button/icon-button.js +198 -0
- package/preact/components/icon-button/icon-button.js.map +7 -0
- package/preact/components/icon-button-toggle/icon-button-toggle.d.ts +18 -0
- package/preact/components/icon-button-toggle/icon-button-toggle.js +200 -0
- package/preact/components/icon-button-toggle/icon-button-toggle.js.map +7 -0
- package/preact/components/icon-sprite/icon-sprite.js +3 -0
- package/preact/components/icon-sprite/icon-sprite.js.map +2 -2
- package/preact/components/icon-with-wrapper/icon-with-wrapper.js.map +2 -2
- package/preact/components/list-item/list-item-types.d.ts +3 -3
- package/preact/components/list-item/list-item.js +16 -13
- package/preact/components/list-item/list-item.js.map +2 -2
- package/preact/components/pictogram/pictogram.js.map +2 -2
- package/preact/components/radio-button/radio-button.js.map +2 -2
- package/preact/components/text-input/text-input.js +29 -28
- package/preact/components/text-input/text-input.js.map +3 -3
- package/types-lib/ds-icon.d.ts +3 -0
- package/variables/icon-list.json +3 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
|
|
2
2
|
{% from '@bonniernews/dn-design-system-web/components/icon-sprite/icon-sprite.njk' import IconUse %}
|
|
3
3
|
{% from '@bonniernews/dn-design-system-web/components/button-toggle/button-toggle.njk' import ButtonToggle %}
|
|
4
|
-
{% from '@bonniernews/dn-design-system-web/components/button/button.njk' import
|
|
4
|
+
{% from '@bonniernews/dn-design-system-web/components/icon-button/icon-button.njk' import IconButton %}
|
|
5
5
|
|
|
6
6
|
{% macro GroupHeader(params) %}
|
|
7
7
|
{% set componentClassName = "ds-group-header" %}
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
{# there is no static-white toggle btn so it is disabled for bauta for now #}
|
|
50
50
|
{% if params.type == 'toggle' and not params.variant %}
|
|
51
51
|
{{ ButtonToggle({
|
|
52
|
-
variant: "
|
|
53
|
-
size: '
|
|
52
|
+
variant: "brand",
|
|
53
|
+
size: 'small',
|
|
54
54
|
text: params.toggleText,
|
|
55
55
|
selectedText: params.toggleSelectedText,
|
|
56
56
|
selected: params.toggleSelected,
|
|
@@ -59,20 +59,20 @@
|
|
|
59
59
|
attributes: params.toggleAttributes
|
|
60
60
|
}) }}
|
|
61
61
|
{% elif (params.type == 'arrows') %}
|
|
62
|
-
{% set buttonVariant = "staticWhite" if params.variant else "
|
|
62
|
+
{% set buttonVariant = "staticWhite" if params.variant else "primary" %}
|
|
63
63
|
<div class="{{ componentClassName + '__arrows' }} hidden-mobile hidden-tablet">
|
|
64
|
-
{{
|
|
64
|
+
{{ IconButton({
|
|
65
65
|
variant: buttonVariant,
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
emphasis: "outline",
|
|
67
|
+
size: "small",
|
|
68
68
|
iconName: "arrow_back",
|
|
69
69
|
classNames: "ds-group-header__arrow ds-group-header__arrow--left",
|
|
70
70
|
attributes: {"aria-label": "Föregående"}
|
|
71
71
|
}) }}
|
|
72
|
-
{{
|
|
72
|
+
{{ IconButton({
|
|
73
73
|
variant: buttonVariant,
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
emphasis: "outline",
|
|
75
|
+
size: "small",
|
|
76
76
|
iconName: "arrow_forward",
|
|
77
77
|
classNames: "ds-group-header__arrow ds-group-header__arrow--right",
|
|
78
78
|
attributes: {"aria-label": "Nästa"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
- GitHub: [BonnierNews/dn-design-system/../web/src/components/icon-button](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/icon-button)
|
|
2
|
+
- Storybook: [Buttons > IconButton](https://designsystem.dn.se/?path=/docs/basic-buttons-iconbutton--docs)
|
|
3
|
+
- Storybook (Latest): [Buttons > IconButton](https://designsystem-latest.dn.se/?path=/docs/basic-buttons-iconbutton--docs)
|
|
4
|
+
|
|
5
|
+
----
|
|
6
|
+
|
|
7
|
+
# Icon button
|
|
8
|
+
|
|
9
|
+
## Parameters
|
|
10
|
+
|
|
11
|
+
|parameter | type | required | options | default | description |
|
|
12
|
+
|:--- | :--- | :--- | :--- | :--- | :--- |
|
|
13
|
+
|iconName | String | yes | add, arrow_back, arrow_forward etc | | For all available icons see: https://designsystem.dn.se/?path=/story/foundations-icons--all-icons |
|
|
14
|
+
|disabled | bool | no | true, false | false | Note: only works on button-tag, not on a-tag |
|
|
15
|
+
|variant | String | no | primary, secondary, brand, staticWhite | primary | Design variant |
|
|
16
|
+
|emphasis | String | no | default, elevated, outline, transparent | default | |
|
|
17
|
+
|rounded | bool | no | true, false | true | Button will be rounded to the max |
|
|
18
|
+
|size| String | no | small, medium, large, xlarge | medium | |
|
|
19
|
+
|loading | bool | no | true, false | false | |
|
|
20
|
+
|a11y.visuallyHidden | Object | no | | | Ex. a11y: { visuallyHidden: "Dela på TikTok" } |
|
|
21
|
+
|href | String | no | | | If href is set the button will be rendered as an a-tag |
|
|
22
|
+
|attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
|
|
23
|
+
|classNames | String | no | | | Ex. "my-special-class" |
|
|
24
|
+
|forcePx | bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
|
|
25
|
+
|
|
26
|
+
## Minimum requirement example
|
|
27
|
+
|
|
28
|
+
### Nunjucks
|
|
29
|
+
|
|
30
|
+
These are copy paste friendly examples to quickliy get started using a component.
|
|
31
|
+
|
|
32
|
+
```html
|
|
33
|
+
{% from '@bonniernews/dn-design-system-web/components/icon-button/icon-button.njk' import IconButton %}
|
|
34
|
+
|
|
35
|
+
{{ IconButton({
|
|
36
|
+
variant: 'primary',
|
|
37
|
+
emphasis: 'outline',
|
|
38
|
+
size: 'default',
|
|
39
|
+
iconName: 'arrow_forward',
|
|
40
|
+
attributes: { 'aria-label': 'Nästa' }
|
|
41
|
+
})}}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### SCSS
|
|
45
|
+
```scss
|
|
46
|
+
@use "@bonniernews/dn-design-system-web/components/icon-button/icon-button";
|
|
47
|
+
```
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Icon Button
|
|
2
|
+
|
|
3
|
+
An icon-only button lets people take a common and recognizable action where space is limited.
|
|
4
|
+
|
|
5
|
+
## Anatomy
|
|
6
|
+
|
|
7
|
+
<img src="/images/uxd/icon-button.png">
|
|
8
|
+
|
|
9
|
+
- **Icon:** The visual representation of an object, action, or concept, usually depicted in a simplified and recognizable form. See [Icon component](https://designsystem.dn.se/?path=/docs/foundations-icons--docs).
|
|
10
|
+
- **Background:** The background area that encompasses the toggle button, providing visual context and affordance.
|
|
11
|
+
- **Border:** The outline surrounding the button, providing visual separation from surrounding elements.
|
|
12
|
+
- **Shape:** The standard shape is circular but the component also supports a rectangular format.
|
|
13
|
+
|
|
14
|
+
## Variants
|
|
15
|
+
|
|
16
|
+
| Variant | How to use |
|
|
17
|
+
| -------------- | -------------------------------------------------------------------------------------------------- |
|
|
18
|
+
| Brand | Not used at the moment. |
|
|
19
|
+
| Primary | Primary icon buttons are used for key actions or primary functions within a context, providing visual emphasis. |
|
|
20
|
+
| Secondary | Secondary icon buttons denote lesser actions or supplementary functions, serving as supporting elements within the interface. |
|
|
21
|
+
| Static White | Static white icon button is used if the button should have a white background regardless of light/dark theme. |
|
|
22
|
+
|
|
23
|
+
## Emphasis Styles
|
|
24
|
+
|
|
25
|
+
| Style | Description |
|
|
26
|
+
| ----------- | --------------------------------------------------------------------------------------------- |
|
|
27
|
+
| Elevated | Elevated icon buttons have a raised appearance, indicating prominence or importance within the interface. |
|
|
28
|
+
| Default | Default icon buttons maintain a standard appearance, blending seamlessly with the surrounding content. |
|
|
29
|
+
| Outline | Outline icon buttons have a minimalistic outline appearance, providing visual contrast against the background. |
|
|
30
|
+
| Transparent | Transparent icon buttons have no visible background, seamlessly integrating with any background color or pattern. |
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
An icon-only button lets people take a common and recognizable action where space is limited.
|
|
35
|
+
|
|
36
|
+
### Dos
|
|
37
|
+
|
|
38
|
+
- **Only use conventional icon buttons:** Since the icon is the only cue it's important that the user recognize the call to action. Typical icon buttons are save, share, print, or next/previous in a slideshow.
|
|
39
|
+
- **Consider Button Emphasis:** Choose the appropriate emphasis style (elevated, default, outline, or transparent) based on the context and background.
|
|
40
|
+
|
|
41
|
+
### Don'ts
|
|
42
|
+
|
|
43
|
+
- **Avoid Overloading Icon Buttons:** Refrain from overloading icon buttons with excessive icons or functionalities, as this can reduce clarity and usability.
|
|
44
|
+
- **Unconventional use:** Use icon button variants appropriately, avoiding the use of unambiguous icons.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
IconButton
|
|
2
|
+
==========
|
|
3
|
+
|
|
4
|
+
* GitHub: [BonnierNews/dn-design-system/../web/src/components/icon-button](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/icon-button)
|
|
5
|
+
* Storybook: [Buttons > IconButton](https://designsystem.dn.se/?path=/docs/basic-buttons-iconbutton--docs)
|
|
6
|
+
|
|
7
|
+
The component will not include styling by itself. Make sure to include the right styles for the component. See example below: `@use "@bonniernews/dn-design-system-web/components/icon-button/icon-button.scss";`
|
|
8
|
+
|
|
9
|
+
| Name | Description | Default |
|
|
10
|
+
|:--- | :--- | :--- |
|
|
11
|
+
| a11y | object | \- |
|
|
12
|
+
| variant | "brand", "secondary", "primary" | "primary" |
|
|
13
|
+
| disabled | Note: only works on button-tag, not on a-tag<br />boolean | false |
|
|
14
|
+
| classNames | string | \- |
|
|
15
|
+
| attributes | Ex. { target: "\_blank", "data-test": "lorem ipsum" }<br />{ \[key: string\]: string; } | \- |
|
|
16
|
+
| forcePx | Fixed pixel value is used for typography to prevent scaling based on html font-size<br />boolean | false |
|
|
17
|
+
| size | "large", "small", "medium", "xlarge" | "medium" |
|
|
18
|
+
| loading | boolean | false |
|
|
19
|
+
| iconName | add, arrow\_back, arrow\_forward etc | | For all available icons see: [https://designsystem.dn.se/?path=/story/foundations-icons--all-icons](https://designsystem.dn.se/?path=/story/foundations-icons--all-icons)<br />"add", "arrow\_back", "arrow\_forward", "arrow\_outward", "arrow\_upward", "bookmark-filled", "bookmarked", "campaign" | \- |
|
|
20
|
+
| href | If href is set the button will be rendered as an a-tag<br />string | \- |
|
|
21
|
+
| emphasis | "default", "elevated", "outline", "transparent" | "default" |
|
|
22
|
+
| rounded | Button will be rounded<br />boolean | true |
|
|
23
|
+
|
|
24
|
+
```jsx
|
|
25
|
+
<IconButton
|
|
26
|
+
emphasis="outline"
|
|
27
|
+
iconName="home"
|
|
28
|
+
size="large"
|
|
29
|
+
variant="secondary"
|
|
30
|
+
/>
|
|
31
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{% from '@bonniernews/dn-design-system-web/components/button/button.njk' import Button %}
|
|
2
|
+
|
|
3
|
+
{% macro IconButton(params) %}
|
|
4
|
+
{{ Button({
|
|
5
|
+
isIconBtn: true,
|
|
6
|
+
isToggle: params.isToggle,
|
|
7
|
+
variant: params.variant,
|
|
8
|
+
href: params.href,
|
|
9
|
+
emphasis: params.emphasis,
|
|
10
|
+
rounded: false if params.rounded === false else true,
|
|
11
|
+
disabled: params.disabled,
|
|
12
|
+
size: params.size,
|
|
13
|
+
iconName: params.iconName,
|
|
14
|
+
selectedIconName: params.selectedIconName,
|
|
15
|
+
loading: params.loading,
|
|
16
|
+
selected: params.selected,
|
|
17
|
+
forcePx: params.forcePx,
|
|
18
|
+
classNames: params.classNames,
|
|
19
|
+
attributes: params.attributes,
|
|
20
|
+
a11y: params.a11y
|
|
21
|
+
}) }}
|
|
22
|
+
{% endmacro %}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
@use "../../foundations/helpers/forward.helpers.scss" as *;
|
|
2
|
+
@use "../button/button.scss" as *;
|
|
3
|
+
|
|
4
|
+
.ds-btn.ds-btn--icon-only {
|
|
5
|
+
&.ds-btn--small {
|
|
6
|
+
padding: ds-px-to-rem(ds-spacing($ds-s-025) - $ds-btn-outlined__border-width);
|
|
7
|
+
@at-root .ds-force-px#{&} {
|
|
8
|
+
padding: ds-spacing($ds-s-025) - $ds-btn-outlined__border-width;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&.ds-btn--medium {
|
|
13
|
+
padding: ds-px-to-rem(ds-spacing($ds-s-050) - $ds-btn-outlined__border-width);
|
|
14
|
+
@at-root .ds-force-px#{&} {
|
|
15
|
+
padding: ds-spacing($ds-s-050) - $ds-btn-outlined__border-width;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&.ds-btn--large {
|
|
20
|
+
padding: ds-px-to-rem(ds-spacing($ds-s-075) - $ds-btn-outlined__border-width);
|
|
21
|
+
@at-root .ds-force-px#{&} {
|
|
22
|
+
padding: ds-spacing($ds-s-075) - $ds-btn-outlined__border-width;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&.ds-btn--xlarge {
|
|
27
|
+
padding: ds-px-to-rem(ds-spacing($ds-s-075) - $ds-btn-outlined__border-width);
|
|
28
|
+
@at-root .ds-force-px#{&} {
|
|
29
|
+
padding: ds-spacing($ds-s-075) - $ds-btn-outlined__border-width;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
- GitHub: [BonnierNews/dn-design-system/../web/src/components/icon-button-toggle](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/icon-button-toggle)
|
|
2
|
+
- Storybook: [Buttons > IconButtonToggle](https://designsystem.dn.se/?path=/docs/basic-buttons-iconbuttontoggle--docs)
|
|
3
|
+
- Storybook (Latest): [Buttons > IconButtonToggle](https://designsystem-latest.dn.se/?path=/docs/basic-buttons-iconbuttontoggle--docs)
|
|
4
|
+
|
|
5
|
+
----
|
|
6
|
+
|
|
7
|
+
# Icon button toggle
|
|
8
|
+
|
|
9
|
+
## Parameters
|
|
10
|
+
|
|
11
|
+
|parameter | type | required | options | default | description |
|
|
12
|
+
|:--- | :--- | :--- | :--- | :--- | :--- |
|
|
13
|
+
|selected | bool | no | true, false | false | |
|
|
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 |
|
|
16
|
+
|disabled | bool | no | true, false | false | Note: only works on button-tag, not on a-tag |
|
|
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 | |
|
|
20
|
+
|loading | bool | no | true, false | false | |
|
|
21
|
+
|attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
|
|
22
|
+
|classNames | String | no | | | Ex. "my-special-class" |
|
|
23
|
+
|forcePx | bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
|
|
24
|
+
|
|
25
|
+
## Minimum requirement example
|
|
26
|
+
|
|
27
|
+
### Nunjucks
|
|
28
|
+
|
|
29
|
+
These are copy paste friendly examples to quickliy get started using a component.
|
|
30
|
+
|
|
31
|
+
```html
|
|
32
|
+
{% from '@bonniernews/dn-design-system-web/components/icon-button-toggle/icon-button-toggle.njk' import IconButtonToggle %}
|
|
33
|
+
|
|
34
|
+
{{ IconButtonToggle({
|
|
35
|
+
variant: 'primary',
|
|
36
|
+
size: 'default',
|
|
37
|
+
iconName: 'bookmarked',
|
|
38
|
+
selectedIconName: 'bookmark-fill'
|
|
39
|
+
})}}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### SCSS
|
|
43
|
+
```scss
|
|
44
|
+
@use "@bonniernews/dn-design-system-web/components/icon-button-toggle/icon-button-toggle";
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Javascript
|
|
48
|
+
|
|
49
|
+
```javascript
|
|
50
|
+
import dsButtonToggle from '@bonniernews/dn-design-system-web/components/button/button-interactions.js'
|
|
51
|
+
const toggleElements = Array.from(document.getElementsByClassName("ds-btn--toggle"));
|
|
52
|
+
dsButtonToggle(toggleElements);
|
|
53
|
+
```
|
|
File without changes
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
IconButtonToggle
|
|
2
|
+
================
|
|
3
|
+
|
|
4
|
+
* GitHub: [BonnierNews/dn-design-system/../web/src/components/icon-button-toggle](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/icon-button-toggle)
|
|
5
|
+
* Storybook: [Buttons > IconButtonToggle](https://designsystem.dn.se/?path=/docs/basic-buttons-iconbuttontoggle--docs)
|
|
6
|
+
|
|
7
|
+
### [](#javascript)Javascript
|
|
8
|
+
|
|
9
|
+
```javascript
|
|
10
|
+
import dsButtonToggle from '@bonniernews/dn-design-system-web/components/button/button-interactions.js'
|
|
11
|
+
const toggleElements = Array.from(document.getElementsByClassName("ds-btn--toggle"));
|
|
12
|
+
dsButtonToggle(toggleElements);
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The component will not include styling by itself. Make sure to include the right styles for the component. See example below: `@use "@bonniernews/dn-design-system-web/components/icon-button-toggle/icon-button-toggle.scss";`
|
|
16
|
+
|
|
17
|
+
| Name | Description | Default |
|
|
18
|
+
|:--- | :--- | :--- |
|
|
19
|
+
| selected | boolean | false |
|
|
20
|
+
| variant | "brand", "secondary", "primary" | "primary" |
|
|
21
|
+
| disabled | Note: only works on button-tag, not on a-tag<br />boolean | false |
|
|
22
|
+
| classNames | string | \- |
|
|
23
|
+
| attributes | Ex. { target: "\_blank", "data-test": "lorem ipsum" }<br />{ \[key: string\]: string; } | \- |
|
|
24
|
+
| forcePx | Fixed pixel value is used for typography to prevent scaling based on html font-size<br />boolean | false |
|
|
25
|
+
| size | "large", "small", "medium", "xlarge" | "medium" |
|
|
26
|
+
| loading | boolean | false |
|
|
27
|
+
| iconName | add, arrow\_back, arrow\_forward etc | | For all available icons see: [https://designsystem.dn.se/?path=/story/foundations-icons--all-icons](https://designsystem.dn.se/?path=/story/foundations-icons--all-icons)<br />"add", "arrow\_back", "arrow\_forward", "arrow\_outward", "arrow\_upward", "bookmark-filled", "bookmarked", "campaign" | \- |
|
|
28
|
+
| emphasis | "default", "elevated", "outline", "transparent" | "default" |
|
|
29
|
+
| selectedIconName | "add", "arrow\_back", "arrow\_forward", "arrow\_outward", "arrow\_upward", "bookmark-filled", "bookmarked", "campaign" | \- |
|
|
30
|
+
|
|
31
|
+
```jsx
|
|
32
|
+
<IconButtonToggle
|
|
33
|
+
iconName="bookmarked"
|
|
34
|
+
selectedIconName="bookmark-filled"
|
|
35
|
+
size="medium"
|
|
36
|
+
variant="primary"
|
|
37
|
+
/>
|
|
38
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{% from '@bonniernews/dn-design-system-web/components/icon-button/icon-button.njk' import IconButton %}
|
|
2
|
+
|
|
3
|
+
{% macro IconButtonToggle(params) %}
|
|
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
|
+
}) }}
|
|
18
|
+
{% endmacro %}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@use "../icon-button/icon-button.scss" as *;
|
|
@@ -3,7 +3,7 @@ import { ComponentChildren } from "preact";
|
|
|
3
3
|
import { ButtonProps } from '../radio-button/radio-button'
|
|
4
4
|
import type { DsIcon } from '@bonniernews/dn-design-system-web/types-lib/ds-icon.d.ts'
|
|
5
5
|
import { SwitchInnerProps } from '../switch/switch'
|
|
6
|
-
import {
|
|
6
|
+
import { ButtonToggleProps } from '../button/button-types'
|
|
7
7
|
|
|
8
8
|
export interface ListItemSharedProps {
|
|
9
9
|
title?: string
|
|
@@ -67,7 +67,7 @@ export interface SwitchListItemProps
|
|
|
67
67
|
|
|
68
68
|
export interface ToggleListItemProps
|
|
69
69
|
extends ListItemSharedProps,
|
|
70
|
-
|
|
70
|
+
ButtonToggleProps,
|
|
71
71
|
Pick<ListItemBaseProps, 'title' | 'subtitle' | 'disabled' | 'selected'> {
|
|
72
72
|
name: string
|
|
73
73
|
titleHref?: string
|
|
@@ -104,7 +104,7 @@ export interface InnerListItemProps
|
|
|
104
104
|
| 'toggleSelectedText'
|
|
105
105
|
| 'disabled'
|
|
106
106
|
>,
|
|
107
|
-
Pick<
|
|
107
|
+
Pick<ButtonToggleProps, 'variant'> {
|
|
108
108
|
componentClassName: string
|
|
109
109
|
}
|
|
110
110
|
|
|
@@ -147,10 +147,10 @@
|
|
|
147
147
|
text: params.toggleText,
|
|
148
148
|
selected: params.selected,
|
|
149
149
|
selectedText: params.toggleSelectedText,
|
|
150
|
-
variant: params.variant | default("
|
|
150
|
+
variant: params.variant | default("secondary"),
|
|
151
151
|
disabled: params.disabled,
|
|
152
152
|
forcePx: params.forcePx,
|
|
153
|
-
size: "
|
|
153
|
+
size: "small",
|
|
154
154
|
attributes: params.elementAttributes,
|
|
155
155
|
classNames: params.elementClassNames
|
|
156
156
|
})}}
|
|
@@ -164,10 +164,10 @@
|
|
|
164
164
|
text: params.toggleText,
|
|
165
165
|
selected: params.selected,
|
|
166
166
|
selectedText: params.toggleSelectedText,
|
|
167
|
-
variant: params.variant | default("
|
|
167
|
+
variant: params.variant | default("secondary"),
|
|
168
168
|
disabled: params.disabled,
|
|
169
169
|
forcePx: params.forcePx,
|
|
170
|
-
size: "
|
|
170
|
+
size: "small",
|
|
171
171
|
attributes: params.elementAttributes,
|
|
172
172
|
classNames: params.elementClassNames
|
|
173
173
|
})}}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{% from '@bonniernews/dn-design-system-web/components/icon-sprite/icon-sprite.njk' import IconUse %}
|
|
2
2
|
{% from '@bonniernews/dn-design-system-web/components/button/button.njk' import Button %}
|
|
3
|
+
{% from '@bonniernews/dn-design-system-web/components/icon-button/icon-button.njk' import IconButton %}
|
|
3
4
|
{% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
|
|
4
5
|
|
|
5
6
|
{% macro Modal(params) %}
|
|
@@ -15,11 +16,10 @@
|
|
|
15
16
|
<div class="{{ classes }}">
|
|
16
17
|
<dialog class="{{ componentClassName + '__inner' }}" {{- attributes | safe }}>
|
|
17
18
|
<div class="{{ componentClassName + '__content' }}">
|
|
18
|
-
{{
|
|
19
|
+
{{ IconButton({
|
|
19
20
|
variant: "transparent",
|
|
20
|
-
size: "
|
|
21
|
+
size: "small",
|
|
21
22
|
iconName: "close",
|
|
22
|
-
isIconButton: true,
|
|
23
23
|
classNames: "ds-modal__close ds-modal__close--icon"
|
|
24
24
|
})}}
|
|
25
25
|
|
|
@@ -32,13 +32,14 @@
|
|
|
32
32
|
{% if params.primaryButton or params.secondaryButton %}
|
|
33
33
|
<div class="ds-modal__buttons">
|
|
34
34
|
{% if params.secondaryButton %}
|
|
35
|
-
{%- set secondaryButtonClasses = [
|
|
35
|
+
{%- set secondaryButtonClasses = [
|
|
36
36
|
"ds-modal__close" if params.secondaryButton.isCloseButton,
|
|
37
37
|
params.secondaryButton.classNames if params.secondaryButton.classNames
|
|
38
38
|
] | join(" ") %}
|
|
39
39
|
{{ Button({
|
|
40
40
|
text: params.secondaryButton.text,
|
|
41
|
-
variant: "
|
|
41
|
+
variant: "primary",
|
|
42
|
+
emphasis: "outline",
|
|
42
43
|
href: params.secondaryButton.href,
|
|
43
44
|
classNames: secondaryButtonClasses,
|
|
44
45
|
attributes: params.secondaryButton.attributes,
|
|
@@ -50,14 +51,11 @@
|
|
|
50
51
|
{% endif %}
|
|
51
52
|
|
|
52
53
|
{% if params.primaryButton %}
|
|
53
|
-
{%- set primaryButtonClasses = ["ds-modal__primary-button",
|
|
54
|
-
params.primaryButton.classNames if params.primaryButton.classNames
|
|
55
|
-
] | join(" ") %}
|
|
56
54
|
{{ Button({
|
|
57
55
|
text: params.primaryButton.text,
|
|
58
|
-
variant: "
|
|
56
|
+
variant: "primary",
|
|
59
57
|
href: params.primaryButton.href,
|
|
60
|
-
classNames:
|
|
58
|
+
classNames: params.primaryButton.classNames,
|
|
61
59
|
attributes: params.primaryButton.attributes,
|
|
62
60
|
forcePx: params.forcePx,
|
|
63
61
|
mobile: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
@use "../../foundations/helpers/forward.helpers.scss" as *;
|
|
2
2
|
@use "../../components/icon-sprite/icon-sprite.scss";
|
|
3
3
|
@use "../../components/button/button.scss";
|
|
4
|
+
@use "../../components/icon-button/icon-button.scss";
|
|
4
5
|
|
|
5
6
|
body:has(dialog[open]),
|
|
6
7
|
body.no-scroll {
|
|
@@ -106,12 +107,12 @@ body.no-scroll {
|
|
|
106
107
|
display: flex;
|
|
107
108
|
flex-wrap: wrap;
|
|
108
109
|
|
|
109
|
-
.ds-
|
|
110
|
+
.ds-btn--default:not(:only-child) {
|
|
110
111
|
order: 1;
|
|
111
112
|
margin-bottom: ds-spacing($ds-s-100);
|
|
112
113
|
}
|
|
113
114
|
|
|
114
|
-
.ds-
|
|
115
|
+
.ds-btn--outline:not(:only-child) {
|
|
115
116
|
order: 2;
|
|
116
117
|
}
|
|
117
118
|
}
|
|
@@ -120,7 +121,7 @@ body.no-scroll {
|
|
|
120
121
|
display: flex;
|
|
121
122
|
justify-content: center;
|
|
122
123
|
|
|
123
|
-
.ds-
|
|
124
|
+
.ds-btn--outline:not(:only-child) {
|
|
124
125
|
margin-right: ds-spacing($ds-s-100);
|
|
125
126
|
}
|
|
126
127
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
|
|
2
2
|
{% from '@bonniernews/dn-design-system-web/components/text-button/text-button.njk' import TextButton %}
|
|
3
|
+
{% from '@bonniernews/dn-design-system-web/components/icon-button/icon-button.njk' import IconButton %}
|
|
3
4
|
|
|
4
5
|
{% macro Pagination(params) %}
|
|
5
6
|
{%- set componentClassName = "ds-pagination" %}
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
<h1 class="{{ componentClassName }}__title">{{ params.title}}</h1>
|
|
19
19
|
{% if params.toggle %}
|
|
20
20
|
{{ ButtonToggle({
|
|
21
|
-
variant: '
|
|
22
|
-
size: '
|
|
21
|
+
variant: 'brand',
|
|
22
|
+
size: 'medium',
|
|
23
23
|
text: params.toggleText,
|
|
24
24
|
selectedText: params.toggleSelectedText,
|
|
25
25
|
selected: params.toggleSelected,
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
<h1 class="{{ componentClassName }}__title">{{ params.title}}</h1>
|
|
27
27
|
{% if params.toggle %}
|
|
28
28
|
{{ ButtonToggle({
|
|
29
|
-
variant: '
|
|
30
|
-
size: '
|
|
29
|
+
variant: 'brand',
|
|
30
|
+
size: 'medium',
|
|
31
31
|
text: params.toggleText,
|
|
32
32
|
selectedText: params.toggleSelectedText,
|
|
33
33
|
selected: params.toggleSelected,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
|
|
2
2
|
{% from '@bonniernews/dn-design-system-web/components/teaser-card/teaser-card.njk' import TeaserCard %}
|
|
3
|
+
{% from '@bonniernews/dn-design-system-web/components/icon-button/icon-button.njk' import IconButton %}
|
|
3
4
|
{% from '@bonniernews/dn-design-system-web/components/group-header/group-header.njk' import GroupHeader %}
|
|
4
5
|
{% from '@bonniernews/dn-design-system-web/components/teaser-swipe-card/teaser-swipe-card.njk' import TeaserSwipeCard %}
|
|
5
|
-
{% from '@bonniernews/dn-design-system-web/components/button/button.njk' import Button %}
|
|
6
6
|
|
|
7
7
|
{% macro TeaserListSwipe(params) %}
|
|
8
8
|
{% set componentClassName = "ds-teaser" %}
|
|
@@ -45,20 +45,20 @@
|
|
|
45
45
|
</div>
|
|
46
46
|
|
|
47
47
|
{% if arrowPosition === 'floating' %}
|
|
48
|
-
{{
|
|
48
|
+
{{ IconButton({
|
|
49
49
|
iconName: 'arrow_back',
|
|
50
|
-
variant: '
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
variant: 'primary',
|
|
51
|
+
emphasis: 'outline',
|
|
52
|
+
size: 'small',
|
|
53
53
|
attributes: { 'aria-label': 'Föregående' },
|
|
54
54
|
classNames: componentClassName + '__swipe-arrow ' + componentClassName + '__swipe-arrow--back hidden-mobile hidden-tablet',
|
|
55
55
|
forcePx: true
|
|
56
56
|
}) }}
|
|
57
|
-
{{
|
|
57
|
+
{{ IconButton({
|
|
58
58
|
iconName: 'arrow_forward',
|
|
59
|
-
variant: '
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
variant: 'primary',
|
|
60
|
+
emphasis: 'outline',
|
|
61
|
+
size: 'small',
|
|
62
62
|
attributes: { 'aria-label': 'Nästa' },
|
|
63
63
|
classNames: componentClassName + '__swipe-arrow ' + componentClassName + '__swipe-arrow--forward hidden-mobile hidden-tablet',
|
|
64
64
|
forcePx: true
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
@use "../../foundations/helpers/forward.helpers.scss" as *;
|
|
2
2
|
@use "../../assets/teaser/teaser.scss" as *;
|
|
3
|
-
@use "../../components/button/button
|
|
3
|
+
@use "../../components/icon-button/icon-button";
|
|
4
4
|
@use "../../components/group-header/group-header";
|
|
5
5
|
@use "../../components/teaser-swipe-card/teaser-swipe-card";
|
|
6
6
|
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
z-index: 5;
|
|
48
48
|
|
|
49
49
|
&--back {
|
|
50
|
-
left:
|
|
50
|
+
left: 10px;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
&--forward {
|
|
54
|
-
right:
|
|
54
|
+
right: 10px;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
57
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
{% from '@bonniernews/dn-design-system-web/components/icon-button/icon-button.njk' import IconButton %} {# TODO switch to on-off button #}
|
|
1
2
|
{% from '@bonniernews/dn-design-system-web/assets/form-field/form-field.njk' import FormField %}
|
|
2
|
-
{% from '@bonniernews/dn-design-system-web/components/button-toggle/button-toggle.njk' import ButtonToggle %}
|
|
3
3
|
|
|
4
4
|
{% macro TextInput(params) %}
|
|
5
5
|
{% set componentClassName = "ds-text-input" %}
|
|
@@ -23,12 +23,10 @@
|
|
|
23
23
|
<label class="{{ componentClassName + '__label'}}" for="{{ params.name }}">{{ params.label }}</label>
|
|
24
24
|
{% endif %}
|
|
25
25
|
{% if password %}
|
|
26
|
-
{{
|
|
26
|
+
{{ IconButton({
|
|
27
27
|
variant: "transparent",
|
|
28
|
-
size: "
|
|
28
|
+
size: "small",
|
|
29
29
|
iconName: "visibility",
|
|
30
|
-
selectedIconName: "visibility_off",
|
|
31
|
-
isIconButton: true,
|
|
32
30
|
classNames: componentClassName + "__password-toggle",
|
|
33
31
|
attributes: {
|
|
34
32
|
id: params.name + "-password-toggle"
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
@use "../../foundations/helpers/forward.helpers.scss" as *;
|
|
2
2
|
@use "../../assets/form-field/form-field.scss";
|
|
3
|
-
@use "
|
|
3
|
+
@use "../icon-button-toggle/icon-button-toggle.scss";
|
|
4
|
+
@use "../icon-button/icon-button.scss"; // TODO remove when njk is removed
|
|
4
5
|
|
|
5
6
|
$ds-text-input-toggle-btn__width: 28px;
|
|
6
|
-
$ds-text-input-toggle-btn__top:
|
|
7
|
+
$ds-text-input-toggle-btn__top: 22px;
|
|
7
8
|
$ds-text-input-toggle-btn__area: ($ds-text-input-toggle-btn__width + ds-spacing($ds-s-050));
|
|
8
9
|
|
|
9
10
|
.ds-form-field__error {
|