@bonniernews/dn-design-system-web 32.4.8 → 32.5.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.
- package/CHANGELOG.md +19 -0
- package/components/article-body-image/README-NJK.md +43 -0
- package/components/article-body-image/README.md +27 -43
- package/components/byline-list/README.md +31 -0
- package/components/byline-list/byline-list.js +22 -0
- package/components/byline-list/byline-list.scss +160 -0
- package/components/list-item/README-UXD.md +0 -2
- package/components/list-item/list-item-types.ts +3 -8
- package/package.json +1 -1
- package/preact/assets/article-image/article-image.d.ts +11 -0
- package/preact/components/article-body-image/article-body-image.d.ts +9 -0
- package/preact/components/article-body-image/article-body-image.js +78 -0
- package/preact/components/article-body-image/article-body-image.js.map +7 -0
- package/preact/components/byline-list/byline-list.d.ts +39 -0
- package/preact/components/byline-list/byline-list.js +281 -0
- package/preact/components/byline-list/byline-list.js.map +7 -0
- package/preact/components/image-caption/image-caption.js +4 -4
- package/preact/components/image-caption/image-caption.js.map +2 -2
- package/preact/components/list-item/list-item-types.d.ts +5 -9
- package/preact/components/list-item/list-item.d.ts +3 -0
- package/preact/components/list-item/list-item.js +2 -7
- package/preact/components/list-item/list-item.js.map +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,25 @@ All changes to @bonniernews/dn-design-system-web will be documented in this file
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
## [32.5.0](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@32.4.9...@bonniernews/dn-design-system-web@32.5.0) (2025-06-02)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* **web:** byline list item tsx ([#1749](https://github.com/BonnierNews/dn-design-system/issues/1749)) ([93d50b8](https://github.com/BonnierNews/dn-design-system/commit/93d50b8832afba8383396a65dc60e73d536385e1))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Maintenance
|
|
16
|
+
|
|
17
|
+
* **web:** add cloudflare to white lists ([#1761](https://github.com/BonnierNews/dn-design-system/issues/1761)) ([0046451](https://github.com/BonnierNews/dn-design-system/commit/0046451d880d3a7910fbc0e4411e5ba0fba480a1))
|
|
18
|
+
|
|
19
|
+
## [32.4.9](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@32.4.8...@bonniernews/dn-design-system-web@32.4.9) (2025-05-30)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* **web:** article body image as tsx ([#1755](https://github.com/BonnierNews/dn-design-system/issues/1755)) ([8db5387](https://github.com/BonnierNews/dn-design-system/commit/8db538783e39272f866ea13ba7411484ed0a25ca))
|
|
25
|
+
|
|
7
26
|
## [32.4.8](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@32.4.7...@bonniernews/dn-design-system-web@32.4.8) (2025-05-28)
|
|
8
27
|
|
|
9
28
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
- GitHub: [BonnierNews/dn-design-system/../web/src/components/article-body-image](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/article-body-image)
|
|
2
|
+
- Storybook: [ArticleBodyImage](https://designsystem.dn.se/?path=/docs/article-articlebodyimage--docs)
|
|
3
|
+
- Storybook (Latest): [ArticleBodyImage](https://designsystem-latest.dn.se/?path=/docs/article-articlebodyimage--docs)
|
|
4
|
+
|
|
5
|
+
----
|
|
6
|
+
|
|
7
|
+
# ArticleBodyImage
|
|
8
|
+
|
|
9
|
+
## Parameters
|
|
10
|
+
|
|
11
|
+
|parameter | type | required | options | default | description |
|
|
12
|
+
|:--- | :--- | :--- | :--- | :--- | :--- |
|
|
13
|
+
|imageHtml | String | yes | | | Use to populate figure tag with image information |
|
|
14
|
+
|fullWidth | Bool | no | true, false | false | Image will have styleable wrapping element |
|
|
15
|
+
|caption | String | no | | | Ex "Detta är en bildtext" |
|
|
16
|
+
|imageType | String | no | | | Type of image. Ex "Foto" |
|
|
17
|
+
|author | String | no | | | Ex "Paul Hansen" |
|
|
18
|
+
|attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
|
|
19
|
+
|classNames | String | no | | | Ex. "my-special-class" |
|
|
20
|
+
|forcePx | Bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
|
|
21
|
+
|
|
22
|
+
## Minimum requirement example
|
|
23
|
+
|
|
24
|
+
### Nunjucks
|
|
25
|
+
|
|
26
|
+
These are copy paste friendly examples to quickliy get started using a component.
|
|
27
|
+
|
|
28
|
+
```html
|
|
29
|
+
{% from '@bonniernews/dn-design-system-web/components/article-body-image/article-body-image.njk' import ArticleBodyImage %}
|
|
30
|
+
|
|
31
|
+
{{ ArticleBodyImage({
|
|
32
|
+
imageHtml: exampleArticleBodyImageHtml(),
|
|
33
|
+
fullWidth: true,
|
|
34
|
+
caption: "En bildtext",
|
|
35
|
+
imageType: "Foto",
|
|
36
|
+
author: "Paul Hansen"
|
|
37
|
+
})}}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### SCSS
|
|
41
|
+
```scss
|
|
42
|
+
@use "@bonniernews/dn-design-system-web/components/article-body-image/article-body-image";
|
|
43
|
+
```
|
|
@@ -1,43 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
|
12
|
-
|
|
13
|
-
|
|
|
14
|
-
|
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
18
|
-
|attributes |
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
```html
|
|
29
|
-
{% from '@bonniernews/dn-design-system-web/components/article-body-image/article-body-image.njk' import ArticleBodyImage %}
|
|
30
|
-
|
|
31
|
-
{{ ArticleBodyImage({
|
|
32
|
-
imageHtml: exampleArticleBodyImageHtml(),
|
|
33
|
-
fullWidth: true,
|
|
34
|
-
caption: "En bildtext",
|
|
35
|
-
imageType: "Foto",
|
|
36
|
-
author: "Paul Hansen"
|
|
37
|
-
})}}
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### SCSS
|
|
41
|
-
```scss
|
|
42
|
-
@use "@bonniernews/dn-design-system-web/components/article-body-image/article-body-image";
|
|
43
|
-
```
|
|
1
|
+
ArticleBodyImage
|
|
2
|
+
================
|
|
3
|
+
|
|
4
|
+
* GitHub: [BonnierNews/dn-design-system/../web/src/components/article-body-image](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/article-body-image)
|
|
5
|
+
* Storybook: [ArticleBodyImage](https://designsystem.dn.se/?path=/docs/article-articlebodyimage--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/article-body-image/article-body-image.scss'`
|
|
8
|
+
|
|
9
|
+
| Name | Description | Default |
|
|
10
|
+
|:--- | :--- | :--- |
|
|
11
|
+
| imageHtml\* | string | \- |
|
|
12
|
+
| caption | string | ", " |
|
|
13
|
+
| author | string | ", " |
|
|
14
|
+
| imageType | string | ", " |
|
|
15
|
+
| fullWidth | boolean | \- |
|
|
16
|
+
| forcePx | boolean | \- |
|
|
17
|
+
| classNames | string | \- |
|
|
18
|
+
| attributes | object | \- |
|
|
19
|
+
|
|
20
|
+
```jsx
|
|
21
|
+
<ArticleBodyImage
|
|
22
|
+
author="Paul Hansen"
|
|
23
|
+
caption="Detta är en bildtext"
|
|
24
|
+
imageHtml="<div class='picture picture--placeholder' style='aspect-ratio: 1920 / 1081'><img class='picture__img' src='https://cached-images.bonnier.news/gcs/bilder/dn-mly/015275ed-234c-4762-b5aa-d61bf5ac6c94.jpeg?interpolation=lanczos-none&downsize=480:*&output-quality=80' srcset='https://cached-images.bonnier.news/gcs/bilder/dn-mly/015275ed-234c-4762-b5aa-d61bf5ac6c94.jpeg?interpolation=lanczos-none&downsize=750:*&output-quality=60 750w, https://cached-images.bonnier.news/gcs/bilder/dn-mly/015275ed-234c-4762-b5aa-d61bf5ac6c94.jpeg?interpolation=lanczos-none&downsize=960:*&output-quality=60 960w' sizes='100vw' alt='Stridsvagnssoldaterna håller sitt förbandsläger prydligt. Man tar hand om sina persedlar, även i smällkalla vintern. Skräp läggs på speciella platser, röker gör man utomhus och det luktar nykokt te i skyddsvärnen.'></div>"
|
|
25
|
+
imageType="Foto"
|
|
26
|
+
/>
|
|
27
|
+
```
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
BylineList
|
|
2
|
+
==========
|
|
3
|
+
|
|
4
|
+
* GitHub: [BonnierNews/dn-design-system/../web/src/components/byline-list](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/byline-list)
|
|
5
|
+
* Storybook: [Byline-list](https://designsystem.dn.se/?path=/docs/article-byline-list--docs)
|
|
6
|
+
|
|
7
|
+
BylineList is a component that renders a list of bylines with optional media and titles. It is used for the sheet that displays if we click a byline with more than one author.
|
|
8
|
+
|
|
9
|
+
**This is only implemented in tsx. Nkj files are not implemented. They are still using the old list item component.**
|
|
10
|
+
|
|
11
|
+
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/byline-list/byline-list.scss'`
|
|
12
|
+
|
|
13
|
+
| Name | Description | Default |
|
|
14
|
+
|:--- | :--- | :--- |
|
|
15
|
+
| bylines\* | { authorName?: string; bylineImage?: string; authorPageUrl?: string; role?: string; border?: boolean; followable?: boolean; followed?: boolean; listItemClassNames?: string; attributes?: { \[key: string\]: string; }; linkAttributes?: { ...; }; buttonAttributes?: { ...; }; buttonClassNames?: string; }\[\] | \- |
|
|
16
|
+
| attributes | { \[key: string\]: string; } | \- |
|
|
17
|
+
| forcePx | boolean | \- |
|
|
18
|
+
| classNames | string | \- |
|
|
19
|
+
|
|
20
|
+
```jsx
|
|
21
|
+
<BylineList
|
|
22
|
+
bylines={[
|
|
23
|
+
{
|
|
24
|
+
authorName: 'Byline link',
|
|
25
|
+
authorPageUrl: 'https://www.dn.se/av/peter-wolodarski',
|
|
26
|
+
bylineImage: '<div class="picture lazy-image" style="aspect-ratio: 1 / 1"><img class="picture__img picture__img--fullheight" src="https://cached-images.bonnier.news/gcs/bilder/dn-author/i3v3p74rhqjfaaz5bh55j7plztzslpgpr3go52zr4q4dzdtyit3q-450x1020.png?interpolation=lanczos-none&crop=261:261;81,2&resize=44:44&output-quality=80" srcset="https://cached-images.bonnier.news/gcs/bilder/dn-author/i3v3p74rhqjfaaz5bh55j7plztzslpgpr3go52zr4q4dzdtyit3q-450x1020.png?interpolation=lanczos-none&crop=261:261;81,2&resize=44:44&output-quality=80 44w, https://cached-images.bonnier.news/gcs/bilder/dn-author/i3v3p74rhqjfaaz5bh55j7plztzslpgpr3go52zr4q4dzdtyit3q-450x1020.png?interpolation=lanczos-none&crop=261:261;81,2&resize=88:88&output-quality=60 88w" sizes="44px" alt="" aria-hidden="true"></div>',
|
|
27
|
+
role: 'Grafik'
|
|
28
|
+
}
|
|
29
|
+
]}
|
|
30
|
+
/>
|
|
31
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { dsButtonToggle } from '@bonniernews/dn-design-system-web/components/button/button-interactions.js';
|
|
2
|
+
|
|
3
|
+
export {
|
|
4
|
+
dsBylineList,
|
|
5
|
+
dsBylineListAll
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
function dsBylineList(listElements = []) {
|
|
9
|
+
if (!listElements.length) return;
|
|
10
|
+
listElements.forEach((listEl) => {
|
|
11
|
+
const toggleElements = Array.from(listEl.getElementsByClassName("ds-btn--toggle"));
|
|
12
|
+
dsButtonToggle(toggleElements);
|
|
13
|
+
if (listEl.classList.contains('ds-btn--toggle')) {
|
|
14
|
+
dsButtonToggle(listEl);
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function dsBylineListAll() {
|
|
20
|
+
const listElements = Array.from(document.getElementsByClassName("ds-byline-list__item__content"));
|
|
21
|
+
dsBylineList(listElements);
|
|
22
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
@use "../../foundations/helpers/forward.helpers.scss" as *;
|
|
2
|
+
@use "../icon-sprite/icon-sprite.scss";
|
|
3
|
+
@use "../button-toggle/button-toggle.scss" as *;
|
|
4
|
+
|
|
5
|
+
$ds-byline-list__icon-size: 24px;
|
|
6
|
+
$ds-byline-list__portrait-size: 44px;
|
|
7
|
+
|
|
8
|
+
.ds-byline-list {
|
|
9
|
+
list-style: none;
|
|
10
|
+
margin: 0;
|
|
11
|
+
padding: ds-spacing(0 $ds-s-100);
|
|
12
|
+
|
|
13
|
+
.ds-byline-list__item {
|
|
14
|
+
background-color: transparent;
|
|
15
|
+
border: 0;
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
width: 100%;
|
|
21
|
+
list-style: none;
|
|
22
|
+
line-height: 0;
|
|
23
|
+
position: relative;
|
|
24
|
+
|
|
25
|
+
&.ds-byline-list__item--border::after {
|
|
26
|
+
content: "";
|
|
27
|
+
width: 100%;
|
|
28
|
+
height: ds-border-width(xxs);
|
|
29
|
+
background: $ds-color-border-primary;
|
|
30
|
+
position: absolute;
|
|
31
|
+
bottom: 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.ds-byline-list__item__content {
|
|
35
|
+
box-sizing: border-box;
|
|
36
|
+
border-radius: 0;
|
|
37
|
+
margin: 0;
|
|
38
|
+
display: flex;
|
|
39
|
+
gap: ds-spacing($ds-s-100);
|
|
40
|
+
align-items: center;
|
|
41
|
+
justify-content: space-between;
|
|
42
|
+
padding: ds-spacing($ds-s-100 0);
|
|
43
|
+
width: 100%;
|
|
44
|
+
border: none;
|
|
45
|
+
background: none;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
a.ds-byline-list__item__content {
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
color: $ds-color-text-primary;
|
|
51
|
+
text-decoration: none;
|
|
52
|
+
/* full-element links are covered by the opacity hover effect - adding underlines makes it too busy */
|
|
53
|
+
|
|
54
|
+
@include ds-hover(true) {
|
|
55
|
+
opacity: 0.6;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&:active {
|
|
59
|
+
opacity: 0.6;
|
|
60
|
+
}
|
|
61
|
+
&:focus-visible {
|
|
62
|
+
outline: ds-border-width(xs) solid $ds-color-border-primary-strongest;
|
|
63
|
+
outline-offset: -2px;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.ds-byline-list__item__icon-right {
|
|
68
|
+
color: $ds-color-text-primary;
|
|
69
|
+
display: inline-flex;
|
|
70
|
+
|
|
71
|
+
.ds-icon {
|
|
72
|
+
position: relative;
|
|
73
|
+
display: flex;
|
|
74
|
+
height: ds-px-to-rem($ds-byline-list__icon-size);
|
|
75
|
+
width: ds-px-to-rem($ds-byline-list__icon-size);
|
|
76
|
+
margin: 0;
|
|
77
|
+
|
|
78
|
+
@at-root .ds-force-px#{&} {
|
|
79
|
+
height: $ds-byline-list__icon-size;
|
|
80
|
+
width: $ds-byline-list__icon-size;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
svg {
|
|
84
|
+
fill: currentColor;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.ds-byline-list__item__titles {
|
|
90
|
+
display: flex;
|
|
91
|
+
flex-direction: column;
|
|
92
|
+
flex-grow: 1;
|
|
93
|
+
align-items: flex-start;
|
|
94
|
+
overflow-wrap: anywhere;
|
|
95
|
+
|
|
96
|
+
.ds-byline-list__item__title {
|
|
97
|
+
text-align: left;
|
|
98
|
+
|
|
99
|
+
@include ds-typography(
|
|
100
|
+
$ds-typography-functional-body-md,
|
|
101
|
+
$lineHeight: $ds-lineheight-md,
|
|
102
|
+
$fontWeight: $ds-fontweight-semibold
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
@at-root .ds-force-px#{&} {
|
|
106
|
+
@include ds-typography(
|
|
107
|
+
$ds-typography-functional-body-md,
|
|
108
|
+
$lineHeight: $ds-lineheight-md,
|
|
109
|
+
$forcePx: true,
|
|
110
|
+
$fontWeight: $ds-fontweight-semibold
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
a.ds-byline-list__item__title {
|
|
116
|
+
@include ds-link($ds-link-list);
|
|
117
|
+
|
|
118
|
+
&:focus-visible {
|
|
119
|
+
outline: ds-border-width(xs) solid $ds-color-border-primary-strongest;
|
|
120
|
+
outline-offset: 2px;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.ds-byline-list__item__role {
|
|
126
|
+
text-align: left;
|
|
127
|
+
text-transform: capitalize;
|
|
128
|
+
@include ds-typography($ds-typography-functional-body-md) {
|
|
129
|
+
color: $ds-color-text-primary-subtle;
|
|
130
|
+
}
|
|
131
|
+
@at-root .ds-force-px#{&} {
|
|
132
|
+
@include ds-typography($ds-typography-functional-body-md, true) {
|
|
133
|
+
color: $ds-color-text-primary-subtle;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.ds-byline-list__item__portrait {
|
|
139
|
+
border-radius: 50%;
|
|
140
|
+
overflow: hidden;
|
|
141
|
+
background-color: $ds-color-surface-primary-raised-soft;
|
|
142
|
+
flex-shrink: 0;
|
|
143
|
+
|
|
144
|
+
.picture,
|
|
145
|
+
img {
|
|
146
|
+
width: $ds-byline-list__portrait-size;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
&:active .ds-byline-list__item::before {
|
|
151
|
+
background-color: $ds-color-surface-primary-raised-soft;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
@at-root a#{&} {
|
|
155
|
+
box-sizing: border-box;
|
|
156
|
+
text-align: center;
|
|
157
|
+
text-decoration: none;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
## Anatomy
|
|
4
4
|
|
|
5
|
-
<img src="/images/uxd/list-item.png">
|
|
6
|
-
|
|
7
5
|
- **Title:** The primary content of the list item, providing a brief description or label. Titles can have various font weights including regular, semibold, or bold.
|
|
8
6
|
- **Subtitle:** Additional information accompanying the title (optional).
|
|
9
7
|
- **Expanded Content:** Additional content that can be toggled or expanded upon user interaction, such as text paragraphs.
|
|
@@ -18,7 +18,7 @@ export interface ListItemSharedProps {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export interface ListItemBaseProps extends ListItemSharedProps {
|
|
21
|
-
listItemType: 'accordion' | 'checkbox' | 'radio' | 'switch' | 'image' | '
|
|
21
|
+
listItemType: 'accordion' | 'checkbox' | 'radio' | 'switch' | 'image' | 'standard' | 'toggle'
|
|
22
22
|
radioButtons?: ButtonProps[]
|
|
23
23
|
href?: string
|
|
24
24
|
leadingIcon?: DsIcon
|
|
@@ -31,8 +31,6 @@ export interface ListItemBaseProps extends ListItemSharedProps {
|
|
|
31
31
|
checked?: boolean
|
|
32
32
|
selected?: boolean
|
|
33
33
|
stripLabel?: boolean
|
|
34
|
-
toggleText?: string
|
|
35
|
-
toggleSelectedText?: string
|
|
36
34
|
disabled?: boolean
|
|
37
35
|
}
|
|
38
36
|
|
|
@@ -75,8 +73,6 @@ export interface ToggleListItemProps
|
|
|
75
73
|
toggleSelectedText: string
|
|
76
74
|
}
|
|
77
75
|
|
|
78
|
-
export interface BylineListItemProps extends ToggleListItemProps, Pick<ListItemBaseProps, 'mediaHtml'> {}
|
|
79
|
-
|
|
80
76
|
export type ListItemProps =
|
|
81
77
|
| ({ listItemType: 'accordion' } & AccordionListItemProps)
|
|
82
78
|
| ({ listItemType: 'checkbox' } & CheckboxListItemProps)
|
|
@@ -85,7 +81,6 @@ export type ListItemProps =
|
|
|
85
81
|
| ({ listItemType: 'standard' } & StandardListItemProps)
|
|
86
82
|
| ({ listItemType: 'switch' } & SwitchListItemProps)
|
|
87
83
|
| ({ listItemType: 'toggle' } & ToggleListItemProps)
|
|
88
|
-
| ({ listItemType: 'byline' } & BylineListItemProps)
|
|
89
84
|
|
|
90
85
|
export interface InnerListItemProps
|
|
91
86
|
extends ListItemSharedProps,
|
|
@@ -100,12 +95,12 @@ export interface InnerListItemProps
|
|
|
100
95
|
| 'selected'
|
|
101
96
|
| 'value'
|
|
102
97
|
| 'forcePx'
|
|
103
|
-
| 'toggleText'
|
|
104
|
-
| 'toggleSelectedText'
|
|
105
98
|
| 'disabled'
|
|
106
99
|
>,
|
|
107
100
|
Pick<ButtonToggleStandardProps, 'variant'> {
|
|
108
101
|
componentClassName: string
|
|
102
|
+
toggleText?: string
|
|
103
|
+
toggleSelectedText?: string
|
|
109
104
|
}
|
|
110
105
|
|
|
111
106
|
export type TitleProps = Pick<ListItemBaseProps, 'title' | 'subtitle' | 'fontWeight' | 'attributes'> & {
|
package/package.json
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface ArticleImageProps {
|
|
2
|
+
imageHtml: string;
|
|
3
|
+
caption?: string;
|
|
4
|
+
author?: string;
|
|
5
|
+
imageType?: string;
|
|
6
|
+
fullWidth?: boolean;
|
|
7
|
+
forcePx?: boolean;
|
|
8
|
+
classNames?: string;
|
|
9
|
+
attributes?: object;
|
|
10
|
+
}
|
|
11
|
+
export declare const ArticleImage: ({ imageHtml, caption, author, imageType, fullWidth, forcePx, classNames, attributes, }: ArticleImageProps) => import("preact").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ArticleImageProps } from '../../assets/article-image/article-image';
|
|
2
|
+
/**
|
|
3
|
+
* - GitHub: [BonnierNews/dn-design-system/../web/src/components/article-body-image](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/article-body-image)
|
|
4
|
+
* - Storybook: [ArticleBodyImage](https://designsystem.dn.se/?path=/docs/article-articlebodyimage--docs)
|
|
5
|
+
*
|
|
6
|
+
* The component will not include styling by itself. Make sure to include the right styles for the component. See example below:
|
|
7
|
+
* `@use '@bonniernews/dn-design-system-web/components/article-body-image/article-body-image.scss'`
|
|
8
|
+
*/
|
|
9
|
+
export declare const ArticleBodyImage: ({ imageHtml, caption, author, imageType, fullWidth, forcePx, classNames, attributes, }: ArticleImageProps) => import("preact").JSX.Element;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// ../src/helpers/formatClassString.ts
|
|
2
|
+
var formatClassString = (classesArray) => {
|
|
3
|
+
return classesArray.filter((x) => !!x).join(" ");
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
// ../src/components/image-caption/image-caption.tsx
|
|
7
|
+
import { jsx, jsxs } from "preact/jsx-runtime";
|
|
8
|
+
var ImageCaption = ({ caption, author, imageType, classNames, attributes, forcePx }) => {
|
|
9
|
+
const classes = formatClassString([
|
|
10
|
+
"ds-image-caption",
|
|
11
|
+
forcePx && "ds-force-px",
|
|
12
|
+
classNames
|
|
13
|
+
]);
|
|
14
|
+
const authorText = imageType && author ? `${imageType.charAt(0).toUpperCase() + imageType.slice(1)}: ${author}` : author;
|
|
15
|
+
const authorClasses = [
|
|
16
|
+
"ds-article-image__credits",
|
|
17
|
+
authorText && authorText.length >= 27 && authorText.length < 60 ? "ds-article-image__credits--nowrap-bigscreen" : authorText && authorText.length < 27 ? "ds-article-image__credits--nowrap" : null
|
|
18
|
+
].filter(Boolean).join(" ");
|
|
19
|
+
return /* @__PURE__ */ jsxs("figcaption", { className: classes, "aria-hidden": "true", ...attributes, children: [
|
|
20
|
+
caption && /* @__PURE__ */ jsx("span", { children: caption }),
|
|
21
|
+
" ",
|
|
22
|
+
authorText && /* @__PURE__ */ jsx("span", { className: authorClasses, children: authorText })
|
|
23
|
+
] });
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// ../src/assets/article-image/article-image.tsx
|
|
27
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "preact/jsx-runtime";
|
|
28
|
+
var ArticleImage = ({
|
|
29
|
+
imageHtml,
|
|
30
|
+
caption = "",
|
|
31
|
+
author = "",
|
|
32
|
+
imageType = "",
|
|
33
|
+
fullWidth,
|
|
34
|
+
forcePx,
|
|
35
|
+
classNames,
|
|
36
|
+
attributes
|
|
37
|
+
}) => {
|
|
38
|
+
const componentClassName = "ds-article-image";
|
|
39
|
+
const classes = formatClassString([componentClassName, forcePx && "ds-force-px", classNames]);
|
|
40
|
+
const showCaption = !!caption || !!author;
|
|
41
|
+
return /* @__PURE__ */ jsxs2("figure", { className: classes, ...attributes, children: [
|
|
42
|
+
fullWidth ? /* @__PURE__ */ jsx2("div", { className: "ds-full-width-element", dangerouslySetInnerHTML: { __html: imageHtml } }) : /* @__PURE__ */ jsx2("span", { dangerouslySetInnerHTML: { __html: imageHtml } }),
|
|
43
|
+
showCaption && /* @__PURE__ */ jsx2(ImageCaption, { caption, author, imageType, forcePx })
|
|
44
|
+
] });
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// ../src/components/article-body-image/article-body-image.tsx
|
|
48
|
+
import { jsx as jsx3 } from "preact/jsx-runtime";
|
|
49
|
+
var ArticleBodyImage = ({
|
|
50
|
+
imageHtml,
|
|
51
|
+
caption = "",
|
|
52
|
+
author = "",
|
|
53
|
+
imageType = "",
|
|
54
|
+
fullWidth,
|
|
55
|
+
forcePx,
|
|
56
|
+
classNames,
|
|
57
|
+
attributes
|
|
58
|
+
}) => {
|
|
59
|
+
const componentClassName = "ds-article-image--body";
|
|
60
|
+
const classes = formatClassString([componentClassName, classNames]);
|
|
61
|
+
return /* @__PURE__ */ jsx3(
|
|
62
|
+
ArticleImage,
|
|
63
|
+
{
|
|
64
|
+
imageHtml,
|
|
65
|
+
caption,
|
|
66
|
+
author,
|
|
67
|
+
imageType,
|
|
68
|
+
fullWidth,
|
|
69
|
+
forcePx,
|
|
70
|
+
classNames: classes,
|
|
71
|
+
attributes
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
export {
|
|
76
|
+
ArticleBodyImage
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=article-body-image.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../helpers/formatClassString.ts", "../../../components/image-caption/image-caption.tsx", "../../../assets/article-image/article-image.tsx", "../../../components/article-body-image/article-body-image.tsx"],
|
|
4
|
+
"sourcesContent": ["export const formatClassString = (classesArray: (string|undefined|false)[]): string => {\n return classesArray.filter(x => !!x).join(' ');\n}\n", "import { formatClassString } from '@bonniernews/dn-design-system-web/helpers/formatClassString.ts';\n\nexport interface ImageCaptionProps {\n /** Ex \"Detta \u00E4r en bildtext\" */\n caption?: string;\n /** Ex \"Paul Hansen\" */\n author?: string;\n /** Type of image. Ex \"Foto\" or \"Illustration\" */\n imageType?: string;\n /** Ex. \"my-special-class another-class\" */\n classNames?: string;\n /** Ex. { target: \"_blank\", \"data-test\": \"lorem ipsum\" } */\n attributes?: object;\n /** Fixed pixel value is used for typography to prevent scaling based on html font-size */\n forcePx?: boolean;\n}\n\n/**\n * - GitHub: [BonnierNews/dn-design-system/../web/src/components/image-caption](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/image-caption)\n * - Storybook: [ImageCaption](https://designsystem.dn.se/?path=/docs/article-image-caption--docs)\n *\n * The component will not include styling by itself. Make sure to include the right styles for the component. See example below:\n * `@use '@bonniernews/dn-design-system-web/components/image-caption/image-caption.scss'`\n */\nexport const ImageCaption = ({caption, author, imageType, classNames, attributes, forcePx}: ImageCaptionProps) => {\n const classes = formatClassString([\n 'ds-image-caption',\n forcePx && 'ds-force-px',\n classNames,\n ]);\n\n const authorText = imageType && author ? `${imageType.charAt(0).toUpperCase() + imageType.slice(1)}: ${author}` : author;\n\n const authorClasses = [\n 'ds-article-image__credits',\n authorText && authorText.length >= 27 && authorText.length < 60 // Low estimate of how much will fit on tablet/desktop\n ? 'ds-article-image__credits--nowrap-bigscreen' : authorText && authorText.length < 27 // Low estimate of how much will fit on 320px mobile\n ? 'ds-article-image__credits--nowrap' : null,\n ].filter(Boolean).join(' ');\n\n return (\n <figcaption className={classes} aria-hidden='true' {...attributes} >\n {/* This needs to be on the same line to maintain a space between the caption-span and author-span */}\n {caption && <span>{caption}</span>} {authorText && <span className={authorClasses}>{authorText}</span>}\n </figcaption>\n );\n};\n", "import { ImageCaption } from '../../components/image-caption/image-caption'\nimport { formatClassString } from '../../helpers/formatClassString'\n\nexport interface ArticleImageProps {\n imageHtml: string\n caption?: string\n author?: string\n imageType?: string\n fullWidth?: boolean\n forcePx?: boolean\n classNames?: string\n attributes?: object\n}\n\nexport const ArticleImage = ({\n imageHtml,\n caption = '',\n author = '',\n imageType = '',\n fullWidth,\n forcePx,\n classNames,\n attributes,\n}: ArticleImageProps) => {\n const componentClassName = 'ds-article-image'\n const classes = formatClassString([componentClassName, forcePx && 'ds-force-px', classNames])\n const showCaption = !!caption || !!author\n\n return (\n <figure className={classes} {...attributes}>\n {fullWidth ? (\n <div className='ds-full-width-element' dangerouslySetInnerHTML={{ __html: imageHtml }}></div>\n ) : (\n <span dangerouslySetInnerHTML={{ __html: imageHtml }}></span> // TODO: check this, don't want a wrapping span\n )}\n {showCaption && <ImageCaption caption={caption} author={author} imageType={imageType} forcePx={forcePx} />}\n </figure>\n )\n}\n", "import { ArticleImage, ArticleImageProps } from '../../assets/article-image/article-image'\nimport { formatClassString } from '../../helpers/formatClassString'\n\n/**\n * - GitHub: [BonnierNews/dn-design-system/../web/src/components/article-body-image](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/article-body-image)\n * - Storybook: [ArticleBodyImage](https://designsystem.dn.se/?path=/docs/article-articlebodyimage--docs)\n *\n * The component will not include styling by itself. Make sure to include the right styles for the component. See example below:\n * `@use '@bonniernews/dn-design-system-web/components/article-body-image/article-body-image.scss'`\n */\nexport const ArticleBodyImage = ({\n imageHtml,\n caption = '',\n author = '',\n imageType = '',\n fullWidth,\n forcePx,\n classNames,\n attributes,\n}: ArticleImageProps) => {\n const componentClassName = 'ds-article-image--body'\n const classes = formatClassString([componentClassName, classNames])\n\n return (\n <ArticleImage\n imageHtml={imageHtml}\n caption={caption}\n author={author}\n imageType={imageType}\n fullWidth={fullWidth}\n forcePx={forcePx}\n classNames={classes}\n attributes={attributes}\n />\n )\n}"],
|
|
5
|
+
"mappings": ";AAAO,IAAM,oBAAoB,CAAC,iBAAqD;AACrF,SAAO,aAAa,OAAO,OAAK,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG;AAC/C;;;ACuCI,SAEc,KAFd;AAjBG,IAAM,eAAe,CAAC,EAAC,SAAS,QAAQ,WAAW,YAAY,YAAY,QAAO,MAAyB;AAChH,QAAM,UAAU,kBAAkB;AAAA,IAChC;AAAA,IACA,WAAW;AAAA,IACX;AAAA,EACF,CAAC;AAED,QAAM,aAAa,aAAa,SAAS,GAAG,UAAU,OAAO,CAAC,EAAE,YAAY,IAAI,UAAU,MAAM,CAAC,CAAC,KAAK,MAAM,KAAK;AAElH,QAAM,gBAAgB;AAAA,IACpB;AAAA,IACA,cAAc,WAAW,UAAU,MAAM,WAAW,SAAS,KACzD,gDAAgD,cAAc,WAAW,SAAS,KAClF,sCAAsC;AAAA,EAC5C,EAAE,OAAO,OAAO,EAAE,KAAK,GAAG;AAE1B,SACE,qBAAC,gBAAW,WAAW,SAAS,eAAY,QAAQ,GAAG,YAEpD;AAAA,eAAW,oBAAC,UAAM,mBAAQ;AAAA,IAAQ;AAAA,IAAE,cAAc,oBAAC,UAAK,WAAW,eAAgB,sBAAW;AAAA,KACjG;AAEJ;;;ACjBI,SAEI,OAAAA,MAFJ,QAAAC,aAAA;AAfG,IAAM,eAAe,CAAC;AAAA,EAC3B;AAAA,EACA,UAAU;AAAA,EACV,SAAS;AAAA,EACT,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAyB;AACvB,QAAM,qBAAqB;AAC3B,QAAM,UAAU,kBAAkB,CAAC,oBAAoB,WAAW,eAAe,UAAU,CAAC;AAC5F,QAAM,cAAc,CAAC,CAAC,WAAW,CAAC,CAAC;AAEnC,SACE,gBAAAA,MAAC,YAAO,WAAW,SAAU,GAAG,YAC7B;AAAA,gBACC,gBAAAD,KAAC,SAAI,WAAU,yBAAwB,yBAAyB,EAAE,QAAQ,UAAU,GAAG,IAEvF,gBAAAA,KAAC,UAAK,yBAAyB,EAAE,QAAQ,UAAU,GAAG;AAAA,IAEvD,eAAe,gBAAAA,KAAC,gBAAa,SAAkB,QAAgB,WAAsB,SAAkB;AAAA,KAC1G;AAEJ;;;ACdI,gBAAAE,YAAA;AAdG,IAAM,mBAAmB,CAAC;AAAA,EAC/B;AAAA,EACA,UAAU;AAAA,EACV,SAAS;AAAA,EACT,YAAY;AAAA,EACZ;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,MAAyB;AACvB,QAAM,qBAAqB;AAC3B,QAAM,UAAU,kBAAkB,CAAC,oBAAoB,UAAU,CAAC;AAElE,SACE,gBAAAA;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,YAAY;AAAA,MACZ;AAAA;AAAA,EACF;AAEJ;",
|
|
6
|
+
"names": ["jsx", "jsxs", "jsx"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface BylineListProps {
|
|
2
|
+
bylines: Array<{
|
|
3
|
+
authorName?: string;
|
|
4
|
+
bylineImage?: string;
|
|
5
|
+
authorPageUrl?: string;
|
|
6
|
+
role?: string;
|
|
7
|
+
border?: boolean;
|
|
8
|
+
followable?: boolean;
|
|
9
|
+
followed?: boolean;
|
|
10
|
+
listItemClassNames?: string;
|
|
11
|
+
attributes?: {
|
|
12
|
+
[key: string]: string;
|
|
13
|
+
};
|
|
14
|
+
linkAttributes?: {
|
|
15
|
+
[key: string]: string;
|
|
16
|
+
};
|
|
17
|
+
buttonAttributes?: {
|
|
18
|
+
[key: string]: string;
|
|
19
|
+
};
|
|
20
|
+
buttonClassNames?: string;
|
|
21
|
+
}>;
|
|
22
|
+
attributes?: {
|
|
23
|
+
[key: string]: string;
|
|
24
|
+
};
|
|
25
|
+
forcePx?: boolean;
|
|
26
|
+
classNames?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* - GitHub: [BonnierNews/dn-design-system/../web/src/components/byline-list](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/byline-list)
|
|
30
|
+
* - Storybook: [Byline-list](https://designsystem.dn.se/?path=/docs/article-byline-list--docs)
|
|
31
|
+
*
|
|
32
|
+
* BylineList is a component that renders a list of bylines with optional media and titles. It is used for the sheet that displays if we click a byline with more than one author.
|
|
33
|
+
*
|
|
34
|
+
* **This is only implemented in tsx. Nkj files are not implemented. They are still using the old list item component.**
|
|
35
|
+
*
|
|
36
|
+
* The component will not include styling by itself. Make sure to include the right styles for the component. See example below:
|
|
37
|
+
* `@use '@bonniernews/dn-design-system-web/components/byline-list/byline-list.scss'`
|
|
38
|
+
*/
|
|
39
|
+
export declare const BylineList: ({ bylines, attributes, forcePx, classNames, }: BylineListProps) => import("preact").JSX.Element;
|