@bonniernews/dn-design-system-web 2.1.0-alpha.2 → 2.1.0-alpha.21

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 (45) hide show
  1. package/CHANGELOG.md +167 -0
  2. package/README.md +1 -1
  3. package/components/blocked-content/README.md +60 -0
  4. package/components/blocked-content/blocked-content.js +83 -0
  5. package/components/blocked-content/blocked-content.njk +38 -0
  6. package/components/blocked-content/blocked-content.scss +34 -0
  7. package/components/button/README.md +1 -0
  8. package/components/button/button.njk +4 -0
  9. package/components/button/button.scss +24 -19
  10. package/components/button-toggle/button-toggle.njk +2 -5
  11. package/components/button-toggle/button-toggle.scss +6 -10
  12. package/components/byline/README.md +64 -0
  13. package/components/byline/byline.njk +97 -0
  14. package/components/byline/byline.scss +160 -0
  15. package/components/checkbox/checkbox.njk +2 -5
  16. package/components/disclaimer/README.md +3 -1
  17. package/components/disclaimer/disclaimer.njk +7 -6
  18. package/components/disclaimer/disclaimer.scss +10 -0
  19. package/components/factbox/README.md +53 -0
  20. package/components/factbox/factbox.js +42 -0
  21. package/components/factbox/factbox.njk +78 -0
  22. package/components/factbox/factbox.scss +155 -0
  23. package/components/footer/footer.njk +5 -10
  24. package/components/list-item/README-checkbox.md +1 -0
  25. package/components/list-item/README-radio.md +1 -0
  26. package/components/list-item/README-switch.md +1 -0
  27. package/components/list-item/README-toggle.md +2 -1
  28. package/components/list-item/list-item.njk +10 -10
  29. package/components/list-item/list-item.scss +5 -7
  30. package/components/quote/README.md +36 -0
  31. package/components/quote/quote.njk +29 -0
  32. package/components/quote/quote.scss +36 -0
  33. package/components/switch/switch.scss +22 -15
  34. package/components/thematic-break/README.md +30 -0
  35. package/components/thematic-break/thematic-break.njk +14 -0
  36. package/components/thematic-break/thematic-break.scss +22 -0
  37. package/foundations/a11y/informative-svg.njk +23 -0
  38. package/foundations/helpers/typography.scss +4 -4
  39. package/foundations/icons/grade-icon.njk +22 -0
  40. package/foundations/variables/colorsCssVariables.scss +2 -0
  41. package/foundations/variables/colorsDnDarkTokens.scss +4 -2
  42. package/foundations/variables/colorsDnLightTokens.scss +3 -1
  43. package/njk-helpers/attributes.njk +5 -0
  44. package/package.json +1 -1
  45. package/tokens/colors-css-variables.json +2 -0
@@ -0,0 +1,97 @@
1
+ {% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
2
+ {% from '@bonniernews/dn-design-system-web/foundations/icons/icon.njk' import Icon %}
3
+ {% from '@bonniernews/dn-design-system-web/components/button-toggle/button-toggle.njk' import ButtonToggle %}
4
+
5
+ {% macro Byline(params) %}
6
+ {% set componentClassName = "ds-byline" %}
7
+ <li class="{{ componentClassName + '__outer'}}">
8
+ {% call BylineInner(params, componentClassName) %}
9
+ <div class="{{ componentClassName + '__inner'}}">
10
+ {% set componentClassName = componentClassName %}
11
+ {% call BylineContent(params, visualVariant, componentClassName ) %}
12
+ {% if params.bylineImage %}
13
+ <span class="{{ componentClassName + '__image'}}">{{- params.bylineImage | safe -}}</span>
14
+ {% endif %}
15
+ <div class="{{ componentClassName + '__titles'}}">
16
+ {% if params.authorName %}
17
+ <span class="{{ componentClassName + '__title'}}">{{ params.authorName }}</span>
18
+ {% endif %}
19
+ {%- if subtitle %}
20
+ <span class="{{ componentClassName + '__subtitle'}}">{{ subtitle }}</span>
21
+ {% endif %}
22
+ </div>
23
+ {% endcall %}
24
+ {% if visualVariant == 'icon' %}
25
+ <span class="{{ componentClassName + '__icon-right'}}">{{- Icon({ icon: 'arrow_forward' }) | safe -}}</span>
26
+ {% endif %}
27
+ {% if visualVariant == 'button' and params.followable %}
28
+ {{ ButtonToggle({
29
+ text: "Följ",
30
+ selectedText: "Följer",
31
+ variant: "secondaryFilled",
32
+ size: "xsmall",
33
+ attributes: params.elementAttributes,
34
+ classNames: elementClassNames | join(" "),
35
+ forcePx: params.forcePx,
36
+ condensed: true
37
+ })}}
38
+ {% endif %}
39
+ </div>
40
+ {% endcall %}
41
+ </li>
42
+ {% endmacro %}
43
+
44
+ {# Internal helper macro - not intended for use outside of this file #}
45
+ {% macro BylineContent(params, visualVariant, componentClassName) %}
46
+ {% set subtitle = params.role if params.variant == 'link' else params.email %}
47
+ {% if visualVariant == 'button' and params.authorPageUrl %}
48
+ <a href="{{params.authorPageUrl}}" aria-label="Läs mer från: {{ params.authorName }}" class="{{ componentClassName + '__content-wrapper'}}">
49
+ {{ caller() if caller }}
50
+ </a>
51
+ {% else %}
52
+ <div class="{{ componentClassName + '__content-wrapper'}}">
53
+ {{ caller() if caller }}
54
+ </div>
55
+ {% endif %}
56
+ {% endmacro %}
57
+
58
+ {# Internal helper macro - not intended for use outside of this file #}
59
+ {% macro BylineInner(params, componentClassName) %}
60
+ {% set classNamePrefix = componentClassName + "--" %}
61
+ {% set variant = [] %}
62
+ {% set attributes = getAttributes(params.attributes) %}
63
+ {% set visualVariant = "icon" if (params.variant == 'link' or params.followable != true) and params.authorPageUrl else "button" %}
64
+
65
+ {% if params.forcePx %}
66
+ {% set variant = (variant.push("ds-force-px"), variant) %}
67
+ {% endif %}
68
+
69
+ {% if params.classNames %}
70
+ {% set variant = (variant.push(params.classNames), variant) %}
71
+ {% endif %}
72
+
73
+ {% if not params.authorPageUrl %}
74
+ {% set variant = (variant.push(componentClassName + '--noninteractive'), variant) %}
75
+ {% endif %}
76
+
77
+ {% if params.bylineImage %}
78
+ {% set bylineImage = params.bylineImage %}
79
+ {% endif %}
80
+ {% set variant = (variant.push(classNamePrefix + params.variant), variant) %}
81
+ {% set classes = componentClassName + " " + variant | join(" ") %}
82
+
83
+ {% set elementClassNames = [ componentClassName + "__btn-toggle" ]%}
84
+ {% if params.elementClassNames %}
85
+ {% set elementClassNames = (elementClassNames.push(params.elementClassNames), elementClassNames) %}
86
+ {% endif %}
87
+
88
+ {% if visualVariant == 'icon' %}
89
+ <a href="{{ params.authorPageUrl }}" aria-label="Läs mer från: {{ params.authorName }}" class="{{ classes }}" {{- attributes | safe }}>
90
+ {{ caller() if caller }}
91
+ </a>
92
+ {% else %}
93
+ <div class="{{ classes }}" {{- attributes | safe }}>
94
+ {{ caller() if caller }}
95
+ </div>
96
+ {% endif %}
97
+ {% endmacro %}
@@ -0,0 +1,160 @@
1
+ @use "../../foundations/helpers/forward.helpers.scss" as *;
2
+ @use "../../foundations/icons/icon.scss" as *;
3
+ @use "../../components/button-toggle/button-toggle.scss" as *;
4
+
5
+ $ds-byline__icon-size: 24px;
6
+ $ds-byline__image-size: 44px;
7
+
8
+ .ds-byline__outer {
9
+ list-style: none;
10
+ line-height: 0;
11
+ }
12
+
13
+ .ds-byline {
14
+ background-color: transparent;
15
+ border: 0;
16
+ display: inline-flex;
17
+ align-items: center;
18
+ justify-content: center;
19
+ padding: 0;
20
+ width: 100%;
21
+ position: relative;
22
+
23
+ &::after {
24
+ content: "";
25
+ height: ds-metrics-border-width(x1);
26
+ width: calc(100% - (ds-spacing-component(outer) * 2));
27
+ background-color: $ds-color-border-primary;
28
+ position: absolute;
29
+ left: ds-spacing-component(x4);
30
+ bottom: 0;
31
+ }
32
+
33
+ .ds-byline__inner {
34
+ box-sizing: border-box;
35
+ border-radius: 0;
36
+ transition: background-color 50ms ease-out;
37
+ margin: 0;
38
+ display: flex;
39
+ align-items: center;
40
+ justify-content: space-between;
41
+ position: relative;
42
+ padding: ds-spacing-component(x4 outer);
43
+ width: 100%;
44
+
45
+ &::before {
46
+ content: "";
47
+ border-radius: inherit;
48
+ pointer-events: none;
49
+ position: absolute;
50
+ top: 0;
51
+ left: 0;
52
+ bottom: 0;
53
+ right: 0;
54
+ transition: background-color 500ms ease;
55
+ }
56
+
57
+ .ds-icon {
58
+ position: relative;
59
+ display: flex;
60
+ height: ds-px-to-rem($ds-byline__icon-size);
61
+ width: ds-px-to-rem($ds-byline__icon-size);
62
+ margin: 0;
63
+ @at-root .ds-force-px#{&} {
64
+ height: $ds-byline__icon-size;
65
+ width: $ds-byline__icon-size;
66
+ }
67
+ svg {
68
+ fill: currentColor;
69
+ }
70
+ }
71
+ }
72
+
73
+ .ds-byline__content-wrapper {
74
+ display: flex;
75
+ align-items: center;
76
+ justify-content: space-between;
77
+ flex-grow: 1;
78
+ text-decoration: none;
79
+
80
+ &:focus-visible {
81
+ outline: ds-metrics-border-width(x2) solid $ds-color-border-focus-02;
82
+ outline-offset: 2px;
83
+ }
84
+ }
85
+
86
+ .ds-byline__image {
87
+ height: $ds-byline__image-size;
88
+ width: $ds-byline__image-size;
89
+ border-radius: 50%;
90
+ overflow: hidden;
91
+ margin-right: ds-spacing-component(x4);
92
+ background-color: $ds-color-component-primary-overlay;
93
+ flex-shrink: 0;
94
+ }
95
+
96
+ .ds-byline__titles {
97
+ display: flex;
98
+ flex-grow: 1;
99
+ flex-direction: column;
100
+ align-items: flex-start;
101
+ word-break: break-all;
102
+
103
+ .ds-byline__title {
104
+ @include ds-typography($ds-typography-functional-heading01medium);
105
+ @at-root .ds-force-px#{&} {
106
+ @include ds-typography($ds-typography-functional-heading01medium, true);
107
+ }
108
+ color: $ds-color-text-primary;
109
+ text-align: left;
110
+ }
111
+
112
+ .ds-byline__subtitle {
113
+ @include ds-typography($ds-typography-functional-body02regular);
114
+ @at-root .ds-force-px#{&} {
115
+ @include ds-typography($ds-typography-functional-body02regular, true);
116
+ }
117
+ color: $ds-color-text-primary-02;
118
+ text-align: left;
119
+ }
120
+ }
121
+
122
+ .ds-byline__icon-right {
123
+ color: $ds-color-icon-primary;
124
+ display: inline-flex;
125
+ margin-left: ds-spacing-component(x4);
126
+ }
127
+
128
+ .ds-byline__btn-toggle {
129
+ min-height: 44px;
130
+ min-width: 48px;
131
+ margin-left: ds-spacing-component(x4);
132
+ }
133
+
134
+ @include ds-hover() {
135
+ &:hover:not(.ds-byline--noninteractive) {
136
+ cursor: pointer;
137
+
138
+ .ds-byline__inner::before {
139
+ background-color: $ds-color-component-primary-overlay;
140
+ }
141
+ }
142
+ }
143
+
144
+ &:active:not(.ds-byline--noninteractive) .ds-byline__inner::before {
145
+ background-color: $ds-color-component-primary-overlay-02;
146
+ }
147
+ &:focus-visible {
148
+ outline: none;
149
+ .ds-byline__inner {
150
+ outline: ds-metrics-border-width(x2) solid $ds-color-border-focus-02;
151
+ outline-offset: -2px;
152
+ }
153
+ }
154
+
155
+ @at-root a#{&} {
156
+ box-sizing: border-box;
157
+ text-align: center;
158
+ text-decoration: none;
159
+ }
160
+ }
@@ -1,5 +1,6 @@
1
1
  {% from '@bonniernews/dn-design-system-web/foundations/icons/icon.njk' import Icon %}
2
2
  {% from '@bonniernews/dn-design-system-web/assets/form-field/form-field.njk' import FormField %}
3
+ {% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
3
4
 
4
5
  {# Internal helper macro - not intended for use outside of this file #}
5
6
  {% macro CheckboxIcons(componentClassName) %}
@@ -14,11 +15,7 @@
14
15
  {% set classNamePrefix = componentClassName + "--" %}
15
16
  {% set wrapperClasses = [] %}
16
17
  {% set name = params.name | default("ds-checkbox") %}
17
- {% set attributes %}
18
- {% for attribute, value in params.attributes %}
19
- {{attribute}}="{{value}}"
20
- {% endfor %}
21
- {% endset %}
18
+ {% set attributes = getAttributes(params.attributes) %}
22
19
 
23
20
  {% set wrapperClasses = (wrapperClasses.push(componentClassName), wrapperClasses) %}
24
21
 
@@ -1,5 +1,6 @@
1
1
  - GitHub: [BonnierNews/dn-design-system/../web/src/components/disclaimer](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/disclaimer)
2
- - Storybook: [Disclaimer > Web](https://designsystem.dn.se/?path=/story/components-app-web-disclaimer-web)
2
+ - Storybook (PROD): [Disclaimer > Web](https://designsystem.dn.se/?path=/story/components-app-web-article-components-disclaimer-web--plain-disclaimer)
3
+ - Storybook (LATEST): [Disclaimer > Web](https://designsystem-latest.dn.se/?path=/story/components-app-web-article-components-disclaimer-web--plain-disclaimer)
3
4
 
4
5
  ----
5
6
 
@@ -11,6 +12,7 @@
11
12
  |:--- | :--- | :--- | :--- | :--- | :--- |
12
13
  |bodyHtml | String | yes | | | Intended use is text, links and inlined icons |
13
14
  |iconName | String | no | add, arrow_back, arrow_forward etc | | For all available icons see: https://designsystem.dn.se/?path=/story/foundations-icon-web--all |
15
+ |variant | String | no | default, native | default | |
14
16
  |attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
15
17
  |classNames | String | no | | | Ex. "my-special-class" |
16
18
  |forcePx | bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
@@ -1,14 +1,15 @@
1
1
  {% from '@bonniernews/dn-design-system-web/foundations/icons/icon.njk' import Icon %}
2
+ {% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
2
3
 
3
4
  {% macro Disclaimer(params) %}
4
5
  {% set componentClassName = "ds-disclaimer" %}
5
6
  {% set classNamePrefix = componentClassName + "--" %}
6
7
  {% set additionalClasses = [] %}
7
- {% set attributes %}
8
- {% for attribute, value in params.attributes %}
9
- {{attribute}}="{{value}}"
10
- {% endfor %}
11
- {% endset %}
8
+ {% set attributes = getAttributes(params.attributes) %}
9
+
10
+ {% if params.variant and params.variant !== "default" %}
11
+ {% set additionalClasses = (additionalClasses.push(classNamePrefix + params.variant), additionalClasses) %}
12
+ {% endif %}
12
13
 
13
14
  {% if params.forcePx %}
14
15
  {% set additionalClasses = (additionalClasses.push("ds-force-px"), additionalClasses) %}
@@ -16,7 +17,7 @@
16
17
 
17
18
  {% if params.iconName %}
18
19
  {% set iconSvg = Icon({ icon: params.iconName }) %}
19
- {% set additionalClasses = (additionalClasses.push(componentClassName + "--with-icon"), additionalClasses) %}
20
+ {% set additionalClasses = (additionalClasses.push(classNamePrefix + "with-icon"), additionalClasses) %}
20
21
  {% endif %}
21
22
 
22
23
  {% if params.classNames %}
@@ -55,4 +55,14 @@ $ds-btn-outlined__border-width: ds-metrics-border-width(x1);
55
55
  fill: currentColor;
56
56
  }
57
57
  }
58
+
59
+ &--native {
60
+ background-color: $ds-color-static-ad-yellow;
61
+
62
+ .ds-icon,
63
+ .ds-disclaimer__body-html,
64
+ .ds-disclaimer__body-html strong {
65
+ color: $ds-color-static-black;
66
+ }
67
+ }
58
68
  }
@@ -0,0 +1,53 @@
1
+ - GitHub: [BonnierNews/dn-design-system/../web/src/components/factbox](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/factbox)
2
+ - Storybook (PROD): [Factbox > Web](https://designsystem.dn.se/?path=/story/components-app-web-article-components-factbox-web--standard)
3
+ - Storybook (LATEST): [Factbox > Web](https://designsystem-latest.dn.se/?path=/story/components-app-web-article-components-factbox-web--standard)
4
+
5
+ ----
6
+
7
+ # Factbox
8
+
9
+ ## Parameters
10
+
11
+ |parameter | type | required | options | default | description |
12
+ |:--- | :--- | :--- | :--- | :--- | :--- |
13
+ |vignetteHtml | HTML String | no | | | |
14
+ |titleHtml | HTML String | yes | | | |
15
+ |bodyHtml | HTML String | yes | | | |
16
+ |variant | String | yes | standard, culture, sport, economy | standard | Design variant |
17
+ |grade | String | no | | | zero, one, two, three, four, five, none |
18
+ |attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
19
+ |classNames | String | no | | | Ex. "my-special-class" |
20
+ |forceExpanded | bool | no | true, false | false | Full factbox is shown regardless of height and no control buttons are shown|
21
+ |forcePx | bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size |
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/factbox/factbox.njk' import Factbox %}
31
+
32
+ {{ Factbox({
33
+ vignetteHtml: "",
34
+ titleHtml: "Drama",
35
+ bodyHtml: "<p>”Irrational man”<br />Regi och manus: Woody Allen<br />I rollerna: Joaquin Phoenix, Emma Stone, Parker Posey m fl.<br />Längd: 1 tim 35 min (från 11 år.)</p>",
36
+ variant: "culture",
37
+ grade: "two",
38
+ forcePx: true
39
+ })}}
40
+ ```
41
+
42
+ ### SCSS
43
+ ```scss
44
+ @use "@bonniernews/dn-design-system-web/components/factbox/factbox" as *;
45
+ ```
46
+
47
+ ### Javascript
48
+
49
+ ```javascript
50
+ import dsFactbox from '@bonniernews/dn-design-system-web/components/factbox/factbox.js'
51
+ const factboxElements = Array.from(document.getElementsByClassName("ds-factbox"));
52
+ dsFactbox(factboxElements);
53
+ ```
@@ -0,0 +1,42 @@
1
+ export {
2
+ dsFactbox,
3
+ dsFactboxAll
4
+ };
5
+
6
+ const selector = "ds-factbox";
7
+ const expandedClass = `${selector}--expanded`;
8
+ const maxHeight = 468; // this has to match max-height in factbox.scss
9
+
10
+ function dsFactbox(factboxElements) {
11
+ if (!factboxElements.length) return;
12
+ factboxElements.forEach((factboxEl) => {
13
+ if (factboxEl.classList.contains(expandedClass)) return;
14
+
15
+ const contentEl = factboxEl.getElementsByClassName(`${selector}__content`)[0];
16
+ if (contentEl.getBoundingClientRect().height <= maxHeight) {
17
+ factboxEl.classList.add(expandedClass);
18
+ return;
19
+ }
20
+
21
+ const showMoreEl = factboxEl.getElementsByClassName(`${selector}__show-more`)[0];
22
+ showMoreEl.classList.add(`${selector}__show-more--collapsable`);
23
+
24
+ const expandMoreBtn = factboxEl.getElementsByClassName(`${selector}__expand-more`)[0];
25
+ const expandLessBtn = factboxEl.getElementsByClassName(`${selector}__expand-less`)[0];
26
+
27
+ expandMoreBtn.addEventListener("click", () => {
28
+ factboxEl.classList.add(expandedClass);
29
+ showMoreEl.setAttribute("data-factbox-expanded", "");
30
+ });
31
+
32
+ expandLessBtn.addEventListener("click", () => {
33
+ factboxEl.classList.remove(expandedClass);
34
+ showMoreEl.removeAttribute("data-factbox-expanded");
35
+ });
36
+ });
37
+ }
38
+
39
+ function dsFactboxAll() {
40
+ const factboxElements = Array.from(document.getElementsByClassName(`${selector}`));
41
+ dsFactbox(factboxElements);
42
+ }
@@ -0,0 +1,78 @@
1
+ {% from '@bonniernews/dn-design-system-web/foundations/icons/grade-icon.njk' import GradeIcon %}
2
+ {% from '@bonniernews/dn-design-system-web/components/button/button.njk' import Button %}
3
+ {% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
4
+
5
+ {% macro Factbox(params) %}
6
+ {% set componentClassName = "ds-factbox" %}
7
+ {% set classNamePrefix = componentClassName + "--" %}
8
+ {% set variant = [] %}
9
+ {% set grades = ["zero", "one", "two", "three", "four", "five"] %}
10
+ {% set gradesNumeric = ["0", "1", "2", "3", "4", "5"] %}
11
+ {% set activeGrade = params.grade | default("") | string %}
12
+ {% set attributes = getAttributes(params.attributes) %}
13
+
14
+ {% if params.variant %}
15
+ {% set variant = (variant.push(classNamePrefix + params.variant), variant) %}
16
+ {% else %}
17
+ {% set variant = (variant.push(classNamePrefix + "standard"), variant) %}
18
+ {% endif %}
19
+
20
+ {% if params.forcePx %}
21
+ {% set variant = (variant.push("ds-force-px"), variant) %}
22
+ {% endif %}
23
+
24
+ {% if params.forceExpand %}
25
+ {% set variant = (variant.push(classNamePrefix + "expanded"), variant) %}
26
+ {% endif %}
27
+
28
+ {% if params.classNames %}
29
+ {% set variant = (variant.push(params.classNames), variant) %}
30
+ {% endif%}
31
+
32
+ {% set classes = componentClassName + " " + variant | join(" ") %}
33
+
34
+ <div class="{{ classes }}" {{- attributes | safe }}>
35
+ <div class="{{ componentClassName + '__inner'}}">
36
+ <div class="{{ componentClassName + '__content'}}">
37
+ <h2 class="{{ componentClassName + '__title'}}">
38
+ {%- if params.vignetteHtml %}<span class="{{ componentClassName + '__vignette'}}">{{ params.vignetteHtml | safe }}</span>{%- endif %}
39
+ {{- params.titleHtml | safe -}}
40
+ </h2>
41
+ {% if activeGrade and activeGrade in grades %}
42
+ {% for grade in grades %}
43
+ {% if grade == activeGrade %}
44
+ {% set gradeTitle = "Betyg: " + gradesNumeric[loop.index0] + "." %}
45
+ {% set gradeDesc = "Betygsskala: " + gradesNumeric | first + " till " + gradesNumeric | last + "." %}
46
+ <div class="{{ componentClassName + '__grade'}}">{{- GradeIcon({ icon: activeGrade, title: gradeTitle, desc: gradeDesc }) | safe }}</div>
47
+ {% endif %}
48
+ {% endfor %}
49
+ {% endif%}
50
+ <div class="{{ componentClassName + '__body'}}">{{ params.bodyHtml | safe }}</div>
51
+ </div>
52
+ <div class="{{ componentClassName + '__show-more'}}">
53
+ {{ Button({
54
+ text: 'Visa mer',
55
+ variant: 'secondaryFilled',
56
+ size: 'small',
57
+ iconPosition: 'right',
58
+ iconName: 'expand_more',
59
+ classNames: 'ds-factbox__expand-more',
60
+ fullWidth: true,
61
+ forcePx: params.forcePx,
62
+ condensed: true
63
+ })}}
64
+ {{ Button({
65
+ text: 'Visa mindre',
66
+ variant: 'secondaryFilled',
67
+ size: 'small',
68
+ iconPosition: 'right',
69
+ iconName: 'expand_less',
70
+ classNames: 'ds-factbox__expand-less',
71
+ fullWidth: true,
72
+ forcePx: params.forcePx,
73
+ condensed: true
74
+ })}}
75
+ </div>
76
+ </div>
77
+ </div>
78
+ {% endmacro %}
@@ -0,0 +1,155 @@
1
+ @use "../../foundations/helpers/forward.helpers.scss" as *;
2
+ @use "../button/button.scss" as *;
3
+
4
+ $ds-factbox__grade-size: 40px + (ds-metrics-border-width(x2) * 2);
5
+ $ds-factbox__show-more-fade-height: 48px;
6
+ $ds-factbox__padding: ds-spacing-component(x4);
7
+ $ds-factbox__max-height: 500px - ($ds-factbox__padding * 2);
8
+
9
+ .ds-factbox {
10
+ background-color: $ds-color-surface-background;
11
+ box-sizing: border-box;
12
+ padding: $ds-factbox__padding;
13
+ padding-left: $ds-factbox__padding - ds-metrics-border-width(x2);
14
+ padding-top: $ds-factbox__padding - ds-metrics-border-width(x1);
15
+ border-top: ds-metrics-border-width(x1) solid $ds-color-border-primary;
16
+ border-left: ds-metrics-border-width(x2) solid $ds-color-component-brand;
17
+ margin: ds-spacing-layout(
18
+ gap-vertical-static-medium 0 gap-vertical-static-large
19
+ );
20
+
21
+ .ds-factbox__inner {
22
+ max-height: ds-px-to-rem($ds-factbox__max-height);
23
+ overflow: hidden;
24
+ position: relative;
25
+
26
+ @at-root .ds-force-px#{&} {
27
+ max-height: $ds-factbox__max-height;
28
+ }
29
+ }
30
+
31
+ &--expanded .ds-factbox__inner,
32
+ &--expanded.ds-force-px .ds-factbox__inner {
33
+ max-height: none;
34
+ }
35
+
36
+ .ds-factbox__body {
37
+ overflow: hidden;
38
+ @include ds-typography($ds-typography-functional-body02regular);
39
+ color: $ds-color-text-primary;
40
+ @at-root .ds-force-px#{&} {
41
+ @include ds-typography($ds-typography-functional-body02regular, true);
42
+ }
43
+ p {
44
+ margin: 0 0 ds-spacing-component(x4);
45
+ }
46
+ p:last-child {
47
+ margin-bottom: 0;
48
+ }
49
+ a {
50
+ @include ds-link($ds-link-article-body);
51
+ }
52
+ strong {
53
+ @include ds-typography($ds-typography-functional-body02medium);
54
+ @at-root .ds-force-px#{&} {
55
+ @include ds-typography($ds-typography-functional-body02medium, true);
56
+ }
57
+ }
58
+ img {
59
+ max-width: 100%;
60
+ }
61
+ }
62
+ .ds-factbox__title {
63
+ @include ds-typography($ds-typography-functional-heading01bold);
64
+ color: $ds-color-text-primary;
65
+ margin: 0 0 ds-spacing-component(x4);
66
+ @at-root .ds-force-px#{&} {
67
+ @include ds-typography($ds-typography-functional-heading01bold, true);
68
+ }
69
+ }
70
+ .ds-factbox__vignette {
71
+ color: $ds-color-component-brand;
72
+ margin-right: ds-spacing-component(x1);
73
+ }
74
+ .ds-factbox__grade {
75
+ color: $ds-color-icon-primary;
76
+ margin: 0 0 ds-spacing-component(x4);
77
+
78
+ .ds-icon {
79
+ display: block;
80
+ height: ds-px-to-rem($ds-factbox__grade-size);
81
+ svg {
82
+ height: 100%;
83
+ width: auto;
84
+ circle {
85
+ stroke: currentColor;
86
+ }
87
+ }
88
+ @at-root .ds-force-px#{&} {
89
+ height: $ds-factbox__grade-size;
90
+ }
91
+ }
92
+ }
93
+ .ds-factbox__show-more--collapsable::before {
94
+ content: "";
95
+ background: $ds-color-gradient-content-fade-up;
96
+ height: ds-px-to-rem($ds-factbox__show-more-fade-height);
97
+ width: 100%;
98
+ position: absolute;
99
+ top: -#{ds-px-to-rem($ds-factbox__show-more-fade-height)};
100
+
101
+ @at-root .ds-force-px#{&} {
102
+ height: $ds-factbox__show-more-fade-height;
103
+ top: -#{$ds-factbox__show-more-fade-height};
104
+ }
105
+ }
106
+ .ds-factbox__show-more {
107
+ display: none;
108
+ }
109
+ .ds-factbox__show-more--collapsable {
110
+ background-color: $ds-color-surface-background;
111
+ width: 100%;
112
+ button {
113
+ margin: ds-spacing-component(x4 0 0);
114
+ }
115
+ &,
116
+ &:not([data-factbox-expanded]) .ds-factbox__expand-more,
117
+ &[data-factbox-expanded] .ds-factbox__expand-less {
118
+ display: block;
119
+ }
120
+ &:not([data-factbox-expanded]) .ds-factbox__expand-less,
121
+ &[data-factbox-expanded] .ds-factbox__expand-more,
122
+ &[data-factbox-expanded]::before {
123
+ display: none;
124
+ }
125
+ &:not([data-factbox-expanded]) {
126
+ position: absolute;
127
+ bottom: 0;
128
+ }
129
+ }
130
+
131
+ &--culture {
132
+ border-left-color: $ds-color-static-kultur;
133
+ .ds-factbox__vignette {
134
+ color: $ds-color-static-kultur;
135
+ }
136
+ }
137
+ &--sport {
138
+ border-left-color: $ds-color-static-sport;
139
+ .ds-factbox__vignette {
140
+ color: $ds-color-static-sport;
141
+ }
142
+ }
143
+ &--economy {
144
+ border-left-color: $ds-color-static-economy;
145
+ .ds-factbox__vignette {
146
+ color: $ds-color-static-economy;
147
+ }
148
+ }
149
+ &--sthlm {
150
+ border-left-color: $ds-color-static-sthlm;
151
+ .ds-factbox__vignette {
152
+ color: $ds-color-static-sthlm;
153
+ }
154
+ }
155
+ }