@bonniernews/dn-design-system-web 9.1.0 → 10.0.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 (35) hide show
  1. package/CHANGELOG.md +4 -4
  2. package/components/blocked-content/blocked-content.js +1 -1
  3. package/components/blocked-content/blocked-content.njk +0 -1
  4. package/components/buddy-menu/buddy-menu.scss +2 -2
  5. package/components/button/README.md +0 -1
  6. package/components/button/button.njk +6 -11
  7. package/components/button/button.scss +141 -216
  8. package/components/button-toggle/README.md +0 -1
  9. package/components/button-toggle/button-toggle.njk +5 -8
  10. package/components/button-toggle/button-toggle.scss +115 -144
  11. package/components/byline/byline.njk +1 -2
  12. package/components/factbox/factbox.njk +2 -4
  13. package/components/factbox/factbox.scss +2 -2
  14. package/components/floating-button/floating-button.njk +5 -9
  15. package/components/floating-button/floating-button.scss +46 -53
  16. package/components/group-header/group-header.scss +18 -6
  17. package/components/icon-button/icon-button.njk +6 -8
  18. package/components/icon-button/icon-button.scss +93 -111
  19. package/components/icon-button-toggle/icon-button-toggle.scss +3 -5
  20. package/components/list-item/list-item.njk +0 -1
  21. package/components/pictogram/pictogram.njk +1 -1
  22. package/components/teaser-list-swipe/teaser-list-swipe.scss +2 -2
  23. package/components/text-button/README.md +0 -1
  24. package/components/text-button/text-button.njk +7 -12
  25. package/components/text-button/text-button.scss +45 -61
  26. package/components/text-button-toggle/README.md +0 -1
  27. package/components/text-button-toggle/text-button-toggle.njk +7 -10
  28. package/components/text-button-toggle/text-button-toggle.scss +50 -60
  29. package/foundations/colors.scss +0 -1
  30. package/foundations/helpers/metrics.scss +1 -0
  31. package/package.json +1 -1
  32. package/components/modal/README.md +0 -52
  33. package/components/modal/modal.js +0 -59
  34. package/components/modal/modal.njk +0 -66
  35. package/components/modal/modal.scss +0 -115
@@ -2,7 +2,6 @@
2
2
  @use "../icon-sprite/icon-sprite.scss";
3
3
  @use "../spinner/spinner.scss" as *;
4
4
 
5
- $ds-text-btn-toggle__min-clickable-area: 0;
6
5
  $ds-text-btn-toggle__underline-offset: 2px;
7
6
  $ds-text-btn-toggle__icon-size: 24px;
8
7
 
@@ -21,13 +20,12 @@ $ds-text-btn-toggle__icon-size: 24px;
21
20
 
22
21
  .ds-text-btn-toggle {
23
22
  cursor: pointer;
24
- background-color: transparent;
25
23
  border: 0;
26
- min-width: $ds-text-btn-toggle__min-clickable-area;
27
- min-height: $ds-text-btn-toggle__min-clickable-area;
28
24
  display: inline-flex;
29
25
  align-items: center;
30
26
  justify-content: center;
27
+ background-color: transparent;
28
+ border-radius: ds-border-radius(x1);
31
29
  padding: 0;
32
30
  position: relative;
33
31
 
@@ -36,11 +34,8 @@ $ds-text-btn-toggle__icon-size: 24px;
36
34
  }
37
35
 
38
36
  &:focus-visible {
39
- outline: none;
40
- .ds-text-btn-toggle__inner {
41
- outline: ds-border-width(x2) solid $ds-color-border-focus-02;
42
- outline-offset: 2px;
43
- }
37
+ outline: ds-border-width(x2) solid $ds-color-border-focus-02;
38
+ outline-offset: 2px;
44
39
  }
45
40
 
46
41
  @at-root a#{&} {
@@ -49,69 +44,68 @@ $ds-text-btn-toggle__icon-size: 24px;
49
44
  text-decoration: none;
50
45
  }
51
46
 
52
- .ds-text-btn-toggle__inner {
53
- display: inline-flex;
54
- align-items: center;
55
- justify-content: center;
56
- background-color: transparent;
57
- border-radius: ds-border-radius(x1);
58
- padding: ds-spacing($ds-s-075 $ds-s-075 $ds-s-075 $ds-s-050);
59
- position: relative;
60
- &::before {
61
- content: "";
62
- border-radius: inherit;
63
- pointer-events: none;
64
- position: absolute;
65
- top: 0;
66
- left: 0;
67
- bottom: 0;
68
- right: 0;
69
- }
47
+ &::before {
48
+ content: "";
49
+ border-radius: inherit;
50
+ pointer-events: none;
51
+ position: absolute;
52
+ top: 0;
53
+ left: 0;
54
+ bottom: 0;
55
+ right: 0;
56
+ }
70
57
 
71
- .ds-icon {
72
- display: flex;
73
- height: ds-px-to-rem($ds-text-btn-toggle__icon-size);
74
- width: ds-px-to-rem($ds-text-btn-toggle__icon-size);
75
- margin: ds-spacing(0 $ds-s-050 0 0);
76
- color: $ds-color-icon-primary;
77
- svg {
78
- fill: currentColor;
79
- }
80
- }
58
+ &::after {
59
+ content: "";
60
+ position: absolute;
61
+ min-width: $ds-btn__min-clickable-area;
62
+ min-height: $ds-btn__min-clickable-area;
63
+ width: 100%;
64
+ }
81
65
 
82
- .ds-text-btn-toggle__text {
83
- @include ds-typography($ds-typography-functional-body02regular);
84
- @at-root .ds-force-px#{&} {
85
- @include ds-typography($ds-typography-functional-body02regular, true);
86
- }
87
- text-decoration: none;
88
- color: $ds-color-text-primary;
66
+ .ds-icon {
67
+ display: flex;
68
+ height: ds-px-to-rem($ds-text-btn-toggle__icon-size);
69
+ width: ds-px-to-rem($ds-text-btn-toggle__icon-size);
70
+ margin: ds-spacing(0 $ds-s-050 0 0);
71
+ color: $ds-color-icon-primary;
72
+ svg {
73
+ fill: currentColor;
89
74
  }
75
+ }
90
76
 
91
- .ds-text-btn-toggle__off {
92
- display: flex;
93
- }
94
- .ds-text-btn-toggle__on {
95
- display: none;
77
+ .ds-text-btn-toggle__text {
78
+ @include ds-typography($ds-typography-functional-body02regular);
79
+ @at-root .ds-force-px#{&} {
80
+ @include ds-typography($ds-typography-functional-body02regular, true);
96
81
  }
82
+ color: $ds-color-text-primary;
83
+ }
84
+
85
+ .ds-text-btn-toggle__off {
86
+ display: flex;
87
+ }
88
+ .ds-text-btn-toggle__on {
89
+ display: none;
97
90
  }
98
91
 
99
92
  @include ds-hover() {
100
- &:hover:not(.ds-loading) .ds-text-btn-toggle__inner::before {
101
- background-color: $ds-color-component-primary-overlay;
93
+ &:hover:not(.ds-loading):not(:disabled) .ds-text-btn-toggle__text {
94
+ text-decoration: underline;
95
+ text-underline-offset: $ds-text-btn-toggle__underline-offset;
102
96
  }
103
97
  }
104
- &:active:not(.ds-loading) .ds-text-btn-toggle__inner::before {
105
- background-color: $ds-color-component-primary-overlay-02;
98
+ &:active:not(:disabled):not(.ds-loading) {
99
+ opacity: $ds-opacity-component-disabled;
106
100
  }
107
- &:disabled:not(.ds-loading) .ds-text-btn-toggle__inner {
101
+ &:disabled:not(.ds-loading) {
108
102
  @include ds-text-btn-toggle-disabled;
109
103
  }
110
104
 
111
105
  @include ds-loading();
112
106
  }
113
107
 
114
- .ds-text-btn-toggle--selected .ds-text-btn-toggle__inner {
108
+ .ds-text-btn-toggle--selected {
115
109
  .ds-text-btn-toggle__on {
116
110
  display: flex;
117
111
  }
@@ -121,12 +115,8 @@ $ds-text-btn-toggle__icon-size: 24px;
121
115
  }
122
116
 
123
117
  .ds-force-px {
124
- &.ds-text-btn-toggle .ds-text-btn-toggle__inner .ds-icon {
118
+ &.ds-text-btn-toggle .ds-icon {
125
119
  height: $ds-text-btn-toggle__icon-size;
126
120
  width: $ds-text-btn-toggle__icon-size;
127
121
  }
128
122
  }
129
-
130
- .ds-text-btn-toggle--condensed .ds-text-btn-toggle__inner {
131
- padding: ds-spacing($ds-s-025);
132
- }
@@ -5,7 +5,6 @@
5
5
  @use "./helpers/colors.scss" as *;
6
6
 
7
7
  html,
8
- ::backdrop, //backdrop can't handle variables in html element. It needs to be defined here
9
8
  .ds-light {
10
9
  @each $name, $value in meta.module-variables("colorsDnLightTokens") {
11
10
  --ds-color-#{string.slice($name, 8)}: #{$value};
@@ -3,6 +3,7 @@
3
3
  @use "sass:map";
4
4
  @use "../variables/metrics.scss" as *;
5
5
 
6
+ $ds-btn__min-clickable-area: 48px;
6
7
  $dsBorderRadius: map.get($metrics, "border-radius");
7
8
  $dsBorderWidth: map.get($metrics, "border-width");
8
9
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonniernews/dn-design-system-web",
3
- "version": "9.1.0",
3
+ "version": "10.0.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,52 +0,0 @@
1
- - GitHub: [BonnierNews/dn-design-system/../web/src/components/modal](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/modal)
2
- - Storybook: [Modal](https://designsystem.dn.se/?path=/docs/basic-modal--docs)
3
- - Storybook (Latest): [Modal](https://designsystem-latest.dn.se/?path=/docs/basic-modal--docs)
4
-
5
- ----
6
-
7
- # Modal
8
-
9
-
10
- ## Parameters
11
-
12
- |parameter | type | required | options | default | description |
13
- |:--- | :--- | :--- | :--- | :--- | :--- |
14
- | title | String | yes | | | Title in modal |
15
- | bodyText | String | yes | text | | Text in modal |
16
- | primaryButton | Object | no | text | | Object with text, href (optional), classNames (optional) and attributes (optional) |
17
- | secondaryButton | Object | no | text | | Object with text, href (optional), classNames (optional) and attributes (optional). Set isCloseButton to true if you wanna close modal with this button |
18
- | classNames | String | no | | | Ex. "my-special-class" |
19
- | attributes | Object | no | | | Ex. { data-prop: value } |
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
- These are copy paste friendly examples to quickliy get started using a component.
25
-
26
- ### Nunjucks
27
-
28
- ```javascript
29
- {% from '@bonniernews/dn-design-system-web/components/modal/modal.njk' import Modal %}
30
-
31
- {{ Modal({
32
- title: "Rubrik",
33
- bodyText: "Text i modalen",
34
- primaryButton: "Text i knapp",
35
- secondaryButton: "Text i knapp",
36
- })}}
37
- ```
38
-
39
- ### Scss
40
-
41
- ```scss
42
- @use "@bonniernews/dn-design-system-web/components/modal/modal";
43
- ```
44
-
45
- ### Javascript
46
-
47
- ```javascript
48
- import { initModal, openModal } from '@bonniernews/dn-design-system-web/components/modal/modal.js'
49
- const modalEl = document.querySelector(".ds-modal");
50
- initModal(modalEl);
51
- openModal(modalEl);
52
- ```
@@ -1,59 +0,0 @@
1
- export {
2
- initModal,
3
- openModal,
4
- initModalStorybook
5
- }
6
-
7
- function initModal(modalEl) {
8
- const isDialogSupported = typeof HTMLDialogElement === "function";
9
- let modalWrapper = modalEl.querySelector(".ds-modal__inner");
10
- if (!isDialogSupported) {
11
- modalWrapper = modalEl;
12
- const modalElInner = document.querySelector(".ds-modal__inner");
13
- const modalAttributes = Array.from(modalElInner.attributes);
14
- const fallbackDiv = document.createElement("div");
15
- modalEl.classList.add("ds-modal--hidden", "ds-modal--fallback");
16
- modalAttributes.forEach((attr) => {
17
- fallbackDiv.setAttribute(attr.name, attr.value);
18
- });
19
- fallbackDiv.setAttribute("role", "dialog");
20
- fallbackDiv.setAttribute("aria-modal", "true");
21
- fallbackDiv.innerHTML = modalElInner.innerHTML;
22
- modalEl.replaceChild(fallbackDiv, modalElInner);
23
- }
24
-
25
- modalEl.addEventListener("click", (e) => {
26
- if (e.target === modalWrapper) closeModal(modalEl, isDialogSupported);
27
- });
28
-
29
- const closeButtons = Array.from(modalEl.getElementsByClassName("ds-modal__close"));
30
- closeButtons.forEach((button) => {
31
- button.addEventListener("click", () => {
32
- closeModal(modalEl, isDialogSupported);
33
- });
34
- });
35
- }
36
-
37
- function openModal(modalEl) {
38
- if (typeof HTMLDialogElement === "function") {
39
- const modalElInner = modalEl.querySelector(".ds-modal__inner");
40
- modalElInner.showModal();
41
- } else {
42
- modalEl.classList.remove("ds-modal--hidden");
43
- }
44
- }
45
-
46
- function closeModal(modalEl, isDialogSupported) {
47
- if (isDialogSupported) {
48
- const modalElInner = modalEl.querySelector(".ds-modal__inner");
49
- modalElInner.close();
50
- } else {
51
- modalEl.classList.add("ds-modal--hidden");
52
- }
53
- }
54
-
55
- function initModalStorybook() {
56
- const modalEl = document.querySelector(".ds-modal");
57
- initModal(modalEl);
58
- openModal(modalEl);
59
- }
@@ -1,66 +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/button/button.njk' import Button %}
3
- {% from '@bonniernews/dn-design-system-web/components/icon-button/icon-button.njk' import IconButton %}
4
- {% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
5
-
6
- {% macro Modal(params) %}
7
- {% set componentClassName = "ds-modal" %}
8
-
9
- {%- set classes = [
10
- componentClassName,
11
- "ds-force-px" if params.forcePx,
12
- params.classNames if params.classNames
13
- ] | join(" ") %}
14
- {% set attributes = getAttributes(params.attributes) %}
15
-
16
- <div class="{{ classes }}">
17
- <dialog class="{{ componentClassName + '__inner' }}" {{- attributes | safe }}>
18
- <div class="{{ componentClassName + '__content' }}">
19
- {{ IconButton({
20
- variant: "transparent",
21
- size: "small",
22
- iconName: "close",
23
- classNames: "ds-modal__close"
24
- })}}
25
- <h2>{{ params.title }}</h2>
26
- <p>{{ params.bodyText }}</p>
27
-
28
- {% if params.primaryButton or params.secondaryButton %}
29
- <div class="ds-modal__buttons">
30
- {% if params.secondaryButton %}
31
- {%- set secondaryButtonClasses = [
32
- "ds-modal__close" if params.secondaryButton.isCloseButton,
33
- params.secondaryButton.classNames if params.secondaryButton.classNames
34
- ] | join(" ") %}
35
- {{ Button({
36
- text: params.secondaryButton.text,
37
- variant: "secondaryOutlined",
38
- href: params.secondaryButton.href,
39
- classNames: secondaryButtonClasses,
40
- attributes: params.secondaryButton.attributes,
41
- forcePx: params.forcePx,
42
- mobile: {
43
- fullWidth: true
44
- }
45
- })}}
46
- {% endif %}
47
-
48
- {% if params.primaryButton %}
49
- {{ Button({
50
- text: params.primaryButton.text,
51
- variant: "primary",
52
- href: params.primaryButton.href,
53
- classNames: params.primaryButton.classNames,
54
- attributes: params.primaryButton.attributes,
55
- forcePx: params.forcePx,
56
- mobile: {
57
- fullWidth: true
58
- }
59
- })}}
60
- {% endif %}
61
- </div>
62
- {% endif %}
63
- </div>
64
- </dialog>
65
- </div>
66
- {% endmacro %}
@@ -1,115 +0,0 @@
1
- @use "../../foundations/helpers/forward.helpers.scss" as *;
2
- @use "../../components/icon-sprite/icon-sprite.scss";
3
- @use "../../components/button/button.scss";
4
- @use "../../components/icon-button/icon-button.scss";
5
-
6
- .ds-modal {
7
- &--fallback.ds-modal--hidden {
8
- display: none;
9
- }
10
-
11
- &--fallback {
12
- display: flex;
13
- position: fixed;
14
- top: 0;
15
- bottom: 0;
16
- right: 0;
17
- left: 0;
18
- z-index: 999;
19
- background-color: $ds-color-surface-overlay;
20
-
21
- @include ds-mq-only-breakpoint(mobile) {
22
- align-items: flex-end;
23
- }
24
-
25
- @include ds-mq-smallest-breakpoint(tablet) {
26
- align-items: center;
27
- justify-content: center;
28
- }
29
-
30
- .ds-modal__inner {
31
- position: relative;
32
- }
33
-
34
- .ds-modal__content {
35
- @include ds-mq-only-breakpoint(mobile) {
36
- border-radius: 16px 16px 0 0;
37
- }
38
-
39
- @include ds-mq-smallest-breakpoint(tablet) {
40
- border-radius: ds-border-radius(x1);
41
- }
42
- }
43
- }
44
-
45
- .ds-modal__inner {
46
- max-width: 700px;
47
- border: none;
48
- padding: 0;
49
-
50
- @include ds-mq-only-breakpoint(mobile) {
51
- margin-bottom: 0;
52
- border-radius: 16px 16px 0 0;
53
- }
54
-
55
- @include ds-mq-smallest-breakpoint(tablet) {
56
- border-radius: ds-border-radius(x1);
57
- }
58
-
59
- &::backdrop {
60
- background-color: $ds-color-surface-overlay;
61
- }
62
- }
63
-
64
- .ds-modal__content {
65
- padding: ds-spacing($ds-s-400 $ds-s-300 $ds-s-300);
66
- background-color: $ds-color-surface-background;
67
-
68
- .ds-icon-btn.ds-modal__close {
69
- position: absolute;
70
- top: ds-spacing($ds-s-100);
71
- right: ds-spacing($ds-s-100);
72
- }
73
-
74
- > h2 {
75
- @include ds-typography($ds-typography-functional-heading03bold);
76
- margin: ds-spacing(0 0 $ds-s-200);
77
- color: $ds-color-text-primary;
78
- text-align: center;
79
- }
80
-
81
- > p {
82
- @include ds-typography($ds-typography-functional-body02regular);
83
- margin: 0;
84
- text-align: center;
85
- color: $ds-color-text-primary;
86
- }
87
-
88
- > .ds-modal__buttons {
89
- margin: ds-spacing($ds-s-200 0 0);
90
-
91
- @include ds-mq-only-breakpoint(mobile) {
92
- display: flex;
93
- flex-wrap: wrap;
94
-
95
- .ds-btn--primary:not(:only-child) {
96
- order: 1;
97
- margin-bottom: ds-spacing($ds-s-100);
98
- }
99
-
100
- .ds-btn--secondaryOutlined:not(:only-child) {
101
- order: 2;
102
- }
103
- }
104
-
105
- @include ds-mq-smallest-breakpoint(tablet) {
106
- display: flex;
107
- justify-content: center;
108
-
109
- .ds-btn--secondaryOutlined:not(:only-child) {
110
- margin-right: ds-spacing($ds-s-100);
111
- }
112
- }
113
- }
114
- }
115
- }