@bonniernews/dn-design-system-web 2.1.0-alpha.14 → 2.1.0-alpha.16

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,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
+ ## [2.1.0-alpha.16](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@2.1.0-alpha.15...@bonniernews/dn-design-system-web@2.1.0-alpha.16) (2023-02-24)
7
+
8
+
9
+ ### Features
10
+
11
+ * **web:** web byline component ([#693](https://github.com/BonnierNews/dn-design-system/issues/693)) ([7ba1b30](https://github.com/BonnierNews/dn-design-system/commit/7ba1b30fda13c54ada24631e47bb8b3be580f274))
12
+
13
+
14
+
15
+ ## [2.1.0-alpha.15](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@2.1.0-alpha.14...@bonniernews/dn-design-system-web@2.1.0-alpha.15) (2023-02-23)
16
+
17
+
18
+ ### Features
19
+
20
+ * **web:** native variant of disclaimer ([#696](https://github.com/BonnierNews/dn-design-system/issues/696)) ([1294432](https://github.com/BonnierNews/dn-design-system/commit/1294432532d92ec7cb1c1db21e489da0a36ec43c))
21
+
22
+
23
+
6
24
  ## [2.1.0-alpha.14](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@2.1.0-alpha.13...@bonniernews/dn-design-system-web@2.1.0-alpha.14) (2023-02-23)
7
25
 
8
26
  **Note:** Version bump only for package @bonniernews/dn-design-system-web
@@ -0,0 +1,64 @@
1
+ - GitHub: [BonnierNews/dn-design-system/../web/src/components/byline](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/byline)
2
+ - Storybook: [Byline > Web > Link](https://designsystem.dn.se/?path=/story/components-app-web-article-components-byline-web--link)
3
+ - Storybook: [Byline > Web > Follow ](https://designsystem.dn.se/?path=/story/components-app-web-article-components-byline-web--follow)
4
+
5
+ ----
6
+
7
+ # Byline
8
+
9
+ The byline is a list item and should be wrapped in a list.
10
+
11
+ ## Parameters
12
+
13
+ |parameter | type | required | options | default | description |
14
+ |:--- | :--- | :--- | :--- | :--- | :--- |
15
+ |variant | String | yes | follow, link | | |
16
+ |authorName | String | yes | | | |
17
+ |bylineImage | HTML | no | | | Html image from bang. The component only makes the image round. Scaling is up to the user. Should be 44px for non retina screens. |
18
+ |role | String | no | | | Only used in variant link |
19
+ |email | String | no | | | email will be displayed instead of role for variant follow |
20
+ |authorPageUrl | String | no | | | The whole item (varant link), or the title and subtitle (variant follow) will link to this url |
21
+ |followable | Boolean | no | true, false | true | If true the toggle button to follow will be shown when using variant follow. |
22
+ |attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
23
+ |elementAttributes | Object | no | | | Sets attributes on actual toggle element and not byline list item. Same structure as attributes above, for accessability reasons it's important to send in "aria-label": "Följ " + byline.name |
24
+ |classNames | String | no | | | Ex. "my-special-class" |
25
+ |elementClassNames | String | no | | | Sets classes on actual toggle element and not byline list item. Same structure as classNames above |
26
+ |forcePx | bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
27
+
28
+ ## Minimum requirement example
29
+
30
+ ### Nunjucks
31
+
32
+ These are copy paste friendly examples to quickliy get started using a component.
33
+
34
+ ```html
35
+ {% from '@bonniernews/dn-design-system-web/components/byline/byline.njk' import Byline %}
36
+
37
+ {{ Byline({
38
+ variant: variant,
39
+ bylineImage: imageHtml(),
40
+ authorName: authorName,
41
+ role: role,
42
+ email: email,
43
+ authorPageUrl: authorPageUrl,
44
+ followable: followable,
45
+ attributes: attributes,
46
+ elementAttributes: elementAttributes,
47
+ elementClassNames: elementClassNames,
48
+ classNames: "",
49
+ forcePx: false
50
+ })}}
51
+ ```
52
+
53
+ ### SCSS
54
+ ```scss
55
+ @use "@bonniernews/dn-design-system-web/components/byline/byline";
56
+ ```
57
+
58
+ ### Javascript
59
+
60
+ ```javascript
61
+ import dsButtonToggle from '@bonniernews/dn-design-system-web/components/button-toggle/button-toggle.js'
62
+ const toggleElements = Array.from(document.getElementsByClassName("ds-btn-toggle"));
63
+ dsButtonToggle(toggleElements);
64
+ ```
@@ -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,174 @@
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
+ & + .ds-byline__outer {
13
+ .ds-byline::before {
14
+ content: none; // remove first top border on all bylines except the first
15
+ }
16
+ }
17
+ }
18
+
19
+ .ds-byline {
20
+ background-color: transparent;
21
+ border: 0;
22
+ display: inline-flex;
23
+ align-items: center;
24
+ justify-content: center;
25
+ padding: 0;
26
+ width: 100%;
27
+ position: relative;
28
+
29
+ &::before,
30
+ &::after {
31
+ content: "";
32
+ height: ds-metrics-border-width(x1);
33
+ width: calc(100% - (ds-spacing-component(x4) * 2));
34
+ background-color: $ds-color-border-primary;
35
+ position: absolute;
36
+ left: ds-spacing-component(x4);
37
+ }
38
+
39
+ &::before {
40
+ top: 0;
41
+ }
42
+
43
+ &::after {
44
+ bottom: 0;
45
+ }
46
+
47
+ .ds-byline__inner {
48
+ box-sizing: border-box;
49
+ border-radius: 0;
50
+ transition: background-color 50ms ease-out;
51
+ margin: 0;
52
+ display: flex;
53
+ align-items: center;
54
+ justify-content: space-between;
55
+ position: relative;
56
+ padding: ds-spacing-component(x4);
57
+ width: 100%;
58
+
59
+ &::before {
60
+ content: "";
61
+ border-radius: inherit;
62
+ pointer-events: none;
63
+ position: absolute;
64
+ top: 0;
65
+ left: 0;
66
+ bottom: 0;
67
+ right: 0;
68
+ transition: background-color 500ms ease;
69
+ }
70
+
71
+ .ds-icon {
72
+ position: relative;
73
+ display: flex;
74
+ height: ds-px-to-rem($ds-byline__icon-size);
75
+ width: ds-px-to-rem($ds-byline__icon-size);
76
+ margin: 0;
77
+ @at-root .ds-force-px#{&} {
78
+ height: $ds-byline__icon-size;
79
+ width: $ds-byline__icon-size;
80
+ }
81
+ svg {
82
+ fill: currentColor;
83
+ }
84
+ }
85
+ }
86
+
87
+ .ds-byline__content-wrapper {
88
+ display: flex;
89
+ align-items: center;
90
+ justify-content: space-between;
91
+ flex-grow: 1;
92
+ text-decoration: none;
93
+
94
+ &:focus-visible {
95
+ outline: ds-metrics-border-width(x2) solid $ds-color-border-focus-02;
96
+ outline-offset: 2px;
97
+ }
98
+ }
99
+
100
+ .ds-byline__image {
101
+ height: $ds-byline__image-size;
102
+ width: $ds-byline__image-size;
103
+ border-radius: 50%;
104
+ overflow: hidden;
105
+ margin-right: ds-spacing-component(x4);
106
+ background-color: $ds-color-component-primary-overlay;
107
+ flex-shrink: 0;
108
+ }
109
+
110
+ .ds-byline__titles {
111
+ display: flex;
112
+ flex-grow: 1;
113
+ flex-direction: column;
114
+ align-items: flex-start;
115
+ word-break: break-all;
116
+
117
+ .ds-byline__title {
118
+ @include ds-typography($ds-typography-functional-heading01medium);
119
+ @at-root .ds-force-px#{&} {
120
+ @include ds-typography($ds-typography-functional-heading01medium, true);
121
+ }
122
+ color: $ds-color-text-primary;
123
+ text-align: left;
124
+ }
125
+
126
+ .ds-byline__subtitle {
127
+ @include ds-typography($ds-typography-functional-body02regular);
128
+ @at-root .ds-force-px#{&} {
129
+ @include ds-typography($ds-typography-functional-body02regular, true);
130
+ }
131
+ color: $ds-color-text-primary-02;
132
+ text-align: left;
133
+ }
134
+ }
135
+
136
+ .ds-byline__icon-right {
137
+ color: $ds-color-icon-primary;
138
+ display: inline-flex;
139
+ margin-left: ds-spacing-component(x4);
140
+ }
141
+
142
+ .ds-byline__btn-toggle {
143
+ min-height: 44px;
144
+ min-width: 48px;
145
+ margin-left: ds-spacing-component(x4);
146
+ }
147
+
148
+ @include ds-hover() {
149
+ &:hover:not(.ds-byline--noninteractive) {
150
+ cursor: pointer;
151
+
152
+ .ds-byline__inner::before {
153
+ background-color: $ds-color-component-primary-overlay;
154
+ }
155
+ }
156
+ }
157
+
158
+ &:active:not(.ds-byline--noninteractive) .ds-byline__inner::before {
159
+ background-color: $ds-color-component-primary-overlay-02;
160
+ }
161
+ &:focus-visible {
162
+ outline: none;
163
+ .ds-byline__inner {
164
+ outline: ds-metrics-border-width(x2) solid $ds-color-border-focus-02;
165
+ outline-offset: -2px;
166
+ }
167
+ }
168
+
169
+ @at-root a#{&} {
170
+ box-sizing: border-box;
171
+ text-align: center;
172
+ text-decoration: none;
173
+ }
174
+ }
@@ -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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonniernews/dn-design-system-web",
3
- "version": "2.1.0-alpha.14",
3
+ "version": "2.1.0-alpha.16",
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",