@bonniernews/dn-design-system-web 32.4.9 → 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 +12 -0
- 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/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/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,18 @@ 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
|
+
|
|
7
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)
|
|
8
20
|
|
|
9
21
|
|
|
@@ -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,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;
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
// ../src/helpers/formatClassString.ts
|
|
2
|
+
var formatClassString = (classesArray) => {
|
|
3
|
+
return classesArray.filter((x) => !!x).join(" ");
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
// ../src/foundations/icons/sprite.svg
|
|
7
|
+
import { h } from "preact";
|
|
8
|
+
import { jsx, jsxs } from "preact/jsx-runtime";
|
|
9
|
+
|
|
10
|
+
// ../src/components/icon-sprite/icon-sprite.tsx
|
|
11
|
+
import { jsx as jsx2 } from "preact/jsx-runtime";
|
|
12
|
+
var IconUse = ({ iconName, classNames, attributes }) => {
|
|
13
|
+
const componentClassName = "ds-icon";
|
|
14
|
+
const classes = formatClassString([
|
|
15
|
+
componentClassName,
|
|
16
|
+
`${componentClassName}--sprite`,
|
|
17
|
+
`${componentClassName}--${iconName}`,
|
|
18
|
+
classNames
|
|
19
|
+
]);
|
|
20
|
+
return /* @__PURE__ */ jsx2("i", { className: classes, ...attributes, children: /* @__PURE__ */ jsx2("svg", { children: /* @__PURE__ */ jsx2("use", { xlinkHref: `#ds-${iconName}` }) }) });
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// ../src/components/spinner/spinner.tsx
|
|
24
|
+
import { jsx as jsx3 } from "preact/jsx-runtime";
|
|
25
|
+
var Spinner = ({ variant = "primary", size = "large", forcePx, classNames, attributes }) => {
|
|
26
|
+
const componentClassName = "ds-spinner";
|
|
27
|
+
const classes = formatClassString([
|
|
28
|
+
`${componentClassName}`,
|
|
29
|
+
`${componentClassName}--${variant}`,
|
|
30
|
+
`${componentClassName}--${size}`,
|
|
31
|
+
forcePx && "ds-force-px",
|
|
32
|
+
classNames
|
|
33
|
+
]);
|
|
34
|
+
return /* @__PURE__ */ jsx3("span", { className: classes, ...attributes, children: /* @__PURE__ */ jsx3("span", { className: `${componentClassName}__inner` }) });
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
// ../src/components/button/button-base.tsx
|
|
38
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "preact/jsx-runtime";
|
|
39
|
+
var InnerButton = ({ text, isIconButton = false, attributes, icon, loadingHtml }) => {
|
|
40
|
+
let optionalHtml;
|
|
41
|
+
if (!isIconButton && attributes["aria-label"]) {
|
|
42
|
+
optionalHtml = /* @__PURE__ */ jsx4("span", { "aria-hidden": "true", children: text });
|
|
43
|
+
} else if (!isIconButton) {
|
|
44
|
+
optionalHtml = /* @__PURE__ */ jsx4("span", { children: text });
|
|
45
|
+
}
|
|
46
|
+
return /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
47
|
+
optionalHtml,
|
|
48
|
+
icon,
|
|
49
|
+
loadingHtml
|
|
50
|
+
] });
|
|
51
|
+
};
|
|
52
|
+
var ToggleWrapper = ({
|
|
53
|
+
selected = false,
|
|
54
|
+
disabled = false,
|
|
55
|
+
attributes,
|
|
56
|
+
classes,
|
|
57
|
+
onChild,
|
|
58
|
+
offChild,
|
|
59
|
+
loadingHtml
|
|
60
|
+
}) => {
|
|
61
|
+
return /* @__PURE__ */ jsxs2("button", { type: "button", role: "switch", "aria-checked": selected, className: classes, ...attributes, disabled, children: [
|
|
62
|
+
/* @__PURE__ */ jsx4("span", { className: "ds-btn__off", "aria-hidden": "true", children: onChild }),
|
|
63
|
+
/* @__PURE__ */ jsx4("span", { className: "ds-btn__on", "aria-hidden": "true", children: offChild }),
|
|
64
|
+
loadingHtml
|
|
65
|
+
] });
|
|
66
|
+
};
|
|
67
|
+
var ButtonBase = ({
|
|
68
|
+
text,
|
|
69
|
+
disabled = false,
|
|
70
|
+
variant = "primary",
|
|
71
|
+
size = "md",
|
|
72
|
+
fullWidth = false,
|
|
73
|
+
mobileFullWidth = false,
|
|
74
|
+
iconPosition = "none",
|
|
75
|
+
iconName,
|
|
76
|
+
loading = false,
|
|
77
|
+
type = "button",
|
|
78
|
+
href,
|
|
79
|
+
classNames,
|
|
80
|
+
attributes = {},
|
|
81
|
+
forcePx = false,
|
|
82
|
+
isIconButton = false,
|
|
83
|
+
selected = false,
|
|
84
|
+
isToggle = false,
|
|
85
|
+
selectedIconName,
|
|
86
|
+
selectedText
|
|
87
|
+
}) => {
|
|
88
|
+
if (isIconButton && text && !attributes["aria-label"]) {
|
|
89
|
+
attributes["aria-label"] = text;
|
|
90
|
+
} else if (isToggle && text && selectedText && !attributes["aria-label"]) {
|
|
91
|
+
attributes["aria-label"] = selected ? selectedText : text;
|
|
92
|
+
}
|
|
93
|
+
let spinnerVariant = "secondary";
|
|
94
|
+
if (variant === "staticWhite" || variant === "transparent") {
|
|
95
|
+
spinnerVariant = "staticBlack";
|
|
96
|
+
} else if (variant === "secondaryFilled" || variant === "secondaryOutline") {
|
|
97
|
+
spinnerVariant = "primary";
|
|
98
|
+
}
|
|
99
|
+
const loadingHtml = /* @__PURE__ */ jsx4(Spinner, { ...{ size: "small", variant: spinnerVariant, forcePx, attributes: { "aria-hidden": "true" } } });
|
|
100
|
+
let icon;
|
|
101
|
+
if (iconName && (iconPosition != "none" || isIconButton == true)) {
|
|
102
|
+
icon = /* @__PURE__ */ jsx4(IconUse, { ...{ iconName, attributes: { "aria-hidden": "true" } } });
|
|
103
|
+
}
|
|
104
|
+
const classNamePrefix = "ds-btn--";
|
|
105
|
+
const classes = formatClassString([
|
|
106
|
+
"ds-btn",
|
|
107
|
+
`${classNamePrefix}${variant}`,
|
|
108
|
+
`${classNamePrefix}${size}`,
|
|
109
|
+
isToggle && selected && `${classNamePrefix}selected`,
|
|
110
|
+
fullWidth && `${classNamePrefix}full-width`,
|
|
111
|
+
mobileFullWidth && `${classNamePrefix}mobile-full-width`,
|
|
112
|
+
icon && !isIconButton && `${classNamePrefix}icon-${iconPosition}`,
|
|
113
|
+
isIconButton && `${classNamePrefix}icon-only`,
|
|
114
|
+
isToggle && `${classNamePrefix}toggle`,
|
|
115
|
+
loading && "ds-loading",
|
|
116
|
+
forcePx && "ds-force-px",
|
|
117
|
+
classNames
|
|
118
|
+
]);
|
|
119
|
+
let buttonToRender;
|
|
120
|
+
if (isToggle) {
|
|
121
|
+
let onChild, offChild;
|
|
122
|
+
if (isIconButton && iconName && selectedIconName) {
|
|
123
|
+
onChild = /* @__PURE__ */ jsx4(IconUse, { iconName });
|
|
124
|
+
offChild = /* @__PURE__ */ jsx4(IconUse, { iconName: selectedIconName });
|
|
125
|
+
} else {
|
|
126
|
+
onChild = /* @__PURE__ */ jsx4("span", { children: text });
|
|
127
|
+
offChild = /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
128
|
+
/* @__PURE__ */ jsx4(IconUse, { iconName: "check" }),
|
|
129
|
+
/* @__PURE__ */ jsx4("span", { children: selectedText })
|
|
130
|
+
] });
|
|
131
|
+
}
|
|
132
|
+
buttonToRender = /* @__PURE__ */ jsx4(ToggleWrapper, { ...{ selected, classes, attributes, disabled, onChild, offChild, loadingHtml } });
|
|
133
|
+
} else {
|
|
134
|
+
const buttonParams = { isIconButton, text, icon, loadingHtml, attributes };
|
|
135
|
+
if (href) {
|
|
136
|
+
const params = { ...buttonParams, loadingHtml: null };
|
|
137
|
+
buttonToRender = /* @__PURE__ */ jsx4("a", { href, className: classes, ...attributes, children: /* @__PURE__ */ jsx4(InnerButton, { ...params }) });
|
|
138
|
+
} else {
|
|
139
|
+
buttonToRender = /* @__PURE__ */ jsx4("button", { type, className: classes, ...attributes, disabled, children: /* @__PURE__ */ jsx4(InnerButton, { ...buttonParams }) });
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return /* @__PURE__ */ jsx4(Fragment, { children: buttonToRender });
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
// ../src/components/button-toggle/button-toggle.tsx
|
|
146
|
+
import { jsx as jsx5 } from "preact/jsx-runtime";
|
|
147
|
+
var ButtonToggle = ({
|
|
148
|
+
selected = false,
|
|
149
|
+
text,
|
|
150
|
+
selectedText,
|
|
151
|
+
disabled = false,
|
|
152
|
+
variant = "primary",
|
|
153
|
+
size = "md",
|
|
154
|
+
fullWidth = false,
|
|
155
|
+
mobileFullWidth = false,
|
|
156
|
+
isIconButton = false,
|
|
157
|
+
iconName,
|
|
158
|
+
selectedIconName,
|
|
159
|
+
loading = false,
|
|
160
|
+
attributes = {},
|
|
161
|
+
classNames,
|
|
162
|
+
forcePx = false
|
|
163
|
+
}) => {
|
|
164
|
+
return /* @__PURE__ */ jsx5(
|
|
165
|
+
ButtonBase,
|
|
166
|
+
{
|
|
167
|
+
...{
|
|
168
|
+
selected,
|
|
169
|
+
text,
|
|
170
|
+
disabled,
|
|
171
|
+
variant,
|
|
172
|
+
size,
|
|
173
|
+
fullWidth,
|
|
174
|
+
mobileFullWidth,
|
|
175
|
+
isIconButton,
|
|
176
|
+
iconName,
|
|
177
|
+
selectedIconName,
|
|
178
|
+
loading,
|
|
179
|
+
classNames,
|
|
180
|
+
attributes,
|
|
181
|
+
forcePx,
|
|
182
|
+
isToggle: true,
|
|
183
|
+
selectedText,
|
|
184
|
+
type: "button"
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
);
|
|
188
|
+
};
|
|
189
|
+
var button_toggle_default = ButtonToggle;
|
|
190
|
+
|
|
191
|
+
// ../src/components/byline-list/byline-list.tsx
|
|
192
|
+
import { jsx as jsx6, jsxs as jsxs3 } from "preact/jsx-runtime";
|
|
193
|
+
var BylineList = ({
|
|
194
|
+
bylines,
|
|
195
|
+
attributes,
|
|
196
|
+
forcePx,
|
|
197
|
+
classNames
|
|
198
|
+
}) => {
|
|
199
|
+
const componentClassName = "ds-byline-list__item";
|
|
200
|
+
const classes = formatClassString([
|
|
201
|
+
"ds-byline-list",
|
|
202
|
+
forcePx && "ds-force-px",
|
|
203
|
+
classNames
|
|
204
|
+
]);
|
|
205
|
+
return /* @__PURE__ */ jsx6("ul", { className: classes, ...attributes, children: bylines && bylines.map((byline) => /* @__PURE__ */ jsxs3(BylineListInner, { ...{ ...byline, forcePx }, children: [
|
|
206
|
+
byline.bylineImage && /* @__PURE__ */ jsx6(
|
|
207
|
+
"div",
|
|
208
|
+
{
|
|
209
|
+
className: `${componentClassName}__portrait`,
|
|
210
|
+
dangerouslySetInnerHTML: { __html: byline.bylineImage }
|
|
211
|
+
}
|
|
212
|
+
),
|
|
213
|
+
byline.authorName && /* @__PURE__ */ jsx6(
|
|
214
|
+
Title,
|
|
215
|
+
{
|
|
216
|
+
title: byline.authorName,
|
|
217
|
+
role: byline.role,
|
|
218
|
+
authorPageUrl: byline.followable ? byline.authorPageUrl : "",
|
|
219
|
+
attributes: byline.linkAttributes
|
|
220
|
+
}
|
|
221
|
+
)
|
|
222
|
+
] })) });
|
|
223
|
+
};
|
|
224
|
+
var BylineListInner = ({
|
|
225
|
+
disabled,
|
|
226
|
+
attributes,
|
|
227
|
+
linkAttributes,
|
|
228
|
+
authorPageUrl,
|
|
229
|
+
listItemClassNames,
|
|
230
|
+
buttonAttributes,
|
|
231
|
+
buttonClassNames,
|
|
232
|
+
followable,
|
|
233
|
+
followed,
|
|
234
|
+
border = true,
|
|
235
|
+
forcePx,
|
|
236
|
+
children
|
|
237
|
+
}) => {
|
|
238
|
+
const componentClassName = "ds-byline-list__item";
|
|
239
|
+
const classes = formatClassString([
|
|
240
|
+
componentClassName,
|
|
241
|
+
listItemClassNames,
|
|
242
|
+
border && `${componentClassName}--border`
|
|
243
|
+
]);
|
|
244
|
+
const isLink = authorPageUrl && !followable;
|
|
245
|
+
return /* @__PURE__ */ jsx6("li", { className: classes, ...attributes, children: isLink ? /* @__PURE__ */ jsxs3("a", { href: authorPageUrl, className: `${componentClassName}__content`, ...linkAttributes, children: [
|
|
246
|
+
children,
|
|
247
|
+
/* @__PURE__ */ jsx6("span", { className: `${componentClassName}__icon-right`, children: IconUse({ iconName: "arrow_forward" }) })
|
|
248
|
+
] }) : /* @__PURE__ */ jsxs3("div", { className: `${componentClassName}__content`, children: [
|
|
249
|
+
children,
|
|
250
|
+
followable && /* @__PURE__ */ jsx6(
|
|
251
|
+
button_toggle_default,
|
|
252
|
+
{
|
|
253
|
+
...{
|
|
254
|
+
text: "F\xF6lj",
|
|
255
|
+
selectedText: "F\xF6ljer",
|
|
256
|
+
variant: "secondaryFilled",
|
|
257
|
+
size: "sm",
|
|
258
|
+
selected: followed,
|
|
259
|
+
disabled,
|
|
260
|
+
forcePx,
|
|
261
|
+
attributes: buttonAttributes,
|
|
262
|
+
classNames: buttonClassNames
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
)
|
|
266
|
+
] }) });
|
|
267
|
+
};
|
|
268
|
+
var Title = ({ title, role, authorPageUrl, attributes }) => {
|
|
269
|
+
const componentClassName = "ds-byline-list__item";
|
|
270
|
+
const titleClasses = formatClassString([
|
|
271
|
+
`${componentClassName}__title`
|
|
272
|
+
]);
|
|
273
|
+
return /* @__PURE__ */ jsxs3("div", { className: `${componentClassName}__titles`, children: [
|
|
274
|
+
authorPageUrl ? /* @__PURE__ */ jsx6("a", { href: authorPageUrl, className: titleClasses, ...attributes, children: title }) : /* @__PURE__ */ jsx6("span", { className: titleClasses, ...attributes, children: title }),
|
|
275
|
+
role && /* @__PURE__ */ jsx6("span", { className: `${componentClassName}__role`, children: role })
|
|
276
|
+
] });
|
|
277
|
+
};
|
|
278
|
+
export {
|
|
279
|
+
BylineList
|
|
280
|
+
};
|
|
281
|
+
//# sourceMappingURL=byline-list.js.map
|