@bonniernews/dn-design-system-web 32.7.21 → 32.7.22
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 +7 -0
- package/components/article-top-image/README.md +27 -41
- package/package.json +1 -1
- package/preact/components/article-top-image/article-top-image.d.ts +12 -0
- package/preact/components/article-top-image/article-top-image.js +66 -0
- package/preact/components/article-top-image/article-top-image.js.map +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@ All changes to @bonniernews/dn-design-system-web will be documented in this file
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
## [32.7.22](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@32.7.21...@bonniernews/dn-design-system-web@32.7.22) (2025-07-09)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* **web:** article top image as tsx ([#1819](https://github.com/BonnierNews/dn-design-system/issues/1819)) ([172220a](https://github.com/BonnierNews/dn-design-system/commit/172220a250aa42e6b2f8fc016627acc21e5d380d))
|
|
13
|
+
|
|
7
14
|
## [32.7.21](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@32.7.20...@bonniernews/dn-design-system-web@32.7.21) (2025-07-08)
|
|
8
15
|
|
|
9
16
|
|
|
@@ -1,41 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
|
12
|
-
|
|
13
|
-
|
|
|
14
|
-
|caption |
|
|
15
|
-
|
|
|
16
|
-
|
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
{% from '@bonniernews/dn-design-system-web/components/article-top-image/article-top-image.njk' import ArticleTopImage %}
|
|
29
|
-
|
|
30
|
-
{{ ArticleTopImage({
|
|
31
|
-
imageHtml: exampleArticleTopImageHtml(),
|
|
32
|
-
caption: "En bildtext",
|
|
33
|
-
imageType: "Foto",
|
|
34
|
-
author: "Beatrice Lundborg"
|
|
35
|
-
})}}
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
### SCSS
|
|
39
|
-
```scss
|
|
40
|
-
@use "@bonniernews/dn-design-system-web/components/article-top-image/article-top-image";
|
|
41
|
-
```
|
|
1
|
+
ArticleTopImage
|
|
2
|
+
===============
|
|
3
|
+
|
|
4
|
+
* GitHub: [BonnierNews/dn-design-system/../web/src/components/article-top-image](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/article-top-image)
|
|
5
|
+
* Storybook: [ArticleTopImage](https://designsystem.dn.se/?path=/docs/article-articletopimage--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-top-image/article-top-image.scss'`
|
|
8
|
+
|
|
9
|
+
| Name | Description | Default |
|
|
10
|
+
|:--- | :--- | :--- |
|
|
11
|
+
| classNames | Ex. "my-special-class"<br />string | \- |
|
|
12
|
+
| attributes | Ex. { target: "\_blank", "data-test": "lorem ipsum" }<br />Record<string, unknown> | \- |
|
|
13
|
+
| image\* | ComponentChild | \- |
|
|
14
|
+
| caption | string | \- |
|
|
15
|
+
| author | string | \- |
|
|
16
|
+
| imageType | string | \- |
|
|
17
|
+
| fullWidth | boolean | \- |
|
|
18
|
+
| forcePx | boolean | \- |
|
|
19
|
+
|
|
20
|
+
```jsx
|
|
21
|
+
<ArticleTopImage
|
|
22
|
+
author="Beatrice Lundborg"
|
|
23
|
+
caption="Detta är en bildtext"
|
|
24
|
+
image={<ExamplePicture className="picture picture--placeholder" src="https://cached-images.bonnier.news/gcs/bilder/dn-mly/2f8cb117-f4b2-4a3b-a4cc-e51ba294fc1b.jpeg?interpolation=lanczos-none&fit=around%7C1010:569&crop=1010:h;center,top&output-quality=80" srcSet="https://cached-images.bonnier.news/gcs/bilder/dn-mly/2f8cb117-f4b2-4a3b-a4cc-e51ba294fc1b.jpeg?interpolation=lanczos-none&fit=around%7C770:434&crop=770:h;center,top&output-quality=80 770w, https://cached-images.bonnier.news/gcs/bilder/dn-mly/2f8cb117-f4b2-4a3b-a4cc-e51ba294fc1b.jpeg?interpolation=lanczos-none&fit=around%7C1010:569&crop=1010:h;center,top&output-quality=80 1010w, https://cached-images.bonnier.news/gcs/bilder/dn-mly/2f8cb117-f4b2-4a3b-a4cc-e51ba294fc1b.jpeg?interpolation=lanczos-none&fit=around%7C1540:867&crop=1540:h;center,top&output-quality=60 1540w, https://cached-images.bonnier.news/gcs/bilder/dn-mly/2f8cb117-f4b2-4a3b-a4cc-e51ba294fc1b.jpeg?interpolation=lanczos-none&fit=around%7C2020:1137&crop=2020:h;center,top&output-quality=60 2020w" style={{aspectRatio: '16 / 9'}}/>}
|
|
25
|
+
imageType="Foto"
|
|
26
|
+
/>
|
|
27
|
+
```
|
package/package.json
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SharedProps } from '@bonniernews/dn-design-system-web/assets/types/shared-props.ts';
|
|
2
|
+
import { ArticleImageProps } from '@bonniernews/dn-design-system-web/assets/article-image/article-image.tsx';
|
|
3
|
+
export interface ArticleTopImageProps extends SharedProps, ArticleImageProps {
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* - GitHub: [BonnierNews/dn-design-system/../web/src/components/article-top-image](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/article-top-image)
|
|
7
|
+
* - Storybook: [ArticleTopImage](https://designsystem.dn.se/?path=/docs/article-articletopimage--docs)
|
|
8
|
+
*
|
|
9
|
+
* The component will not include styling by itself. Make sure to include the right styles for the component. See example below:
|
|
10
|
+
* `@use '@bonniernews/dn-design-system-web/components/article-top-image/article-top-image.scss'`
|
|
11
|
+
*/
|
|
12
|
+
export declare const ArticleTopImage: ({ caption, imageType, author, image, forcePx, classNames, attributes }: ArticleTopImageProps) => import("preact").JSX.Element;
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
image,
|
|
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", children: image }) : image,
|
|
43
|
+
showCaption && /* @__PURE__ */ jsx2(ImageCaption, { caption, author, imageType, forcePx })
|
|
44
|
+
] });
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// ../src/components/article-top-image/article-top-image.tsx
|
|
48
|
+
import { jsx as jsx3 } from "preact/jsx-runtime";
|
|
49
|
+
var ArticleTopImage = ({ caption, imageType, author, image, forcePx, classNames, attributes }) => {
|
|
50
|
+
const classes = formatClassString(["ds-article-image--top", classNames]);
|
|
51
|
+
const imageParams = {
|
|
52
|
+
fullWidth: true,
|
|
53
|
+
caption,
|
|
54
|
+
imageType,
|
|
55
|
+
author,
|
|
56
|
+
image,
|
|
57
|
+
forcePx,
|
|
58
|
+
classNames: classes,
|
|
59
|
+
attributes
|
|
60
|
+
};
|
|
61
|
+
return /* @__PURE__ */ jsx3(ArticleImage, { ...imageParams });
|
|
62
|
+
};
|
|
63
|
+
export {
|
|
64
|
+
ArticleTopImage
|
|
65
|
+
};
|
|
66
|
+
//# sourceMappingURL=article-top-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-top-image/article-top-image.tsx"],
|
|
4
|
+
"sourcesContent": ["export const formatClassString = (classesArray: (string|undefined|false)[]): string => {\n return classesArray.filter(x => !!x).join(' ');\n}\n", "import type { SharedProps } from \"@bonniernews/dn-design-system-web/assets/types/shared-props.ts\";\nimport { formatClassString } from '@bonniernews/dn-design-system-web/helpers/formatClassString.ts';\n\nexport interface ImageCaptionProps extends SharedProps {\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 /** 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 { ComponentChild } from 'preact'\nimport type { SharedProps } from \"@bonniernews/dn-design-system-web/assets/types/shared-props.ts\";\nimport { ImageCaption } from '../../components/image-caption/image-caption'\nimport { formatClassString } from '../../helpers/formatClassString'\n\nexport interface ArticleImageProps extends SharedProps {\n image: ComponentChild\n caption?: string\n author?: string\n imageType?: string\n fullWidth?: boolean\n forcePx?: boolean\n}\n\nexport const ArticleImage = ({\n image,\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'>{image}</div>\n ) : (\n image\n )}\n {showCaption && <ImageCaption caption={caption} author={author} imageType={imageType} forcePx={forcePx} />}\n </figure>\n )\n}\n", "import type { SharedProps } from '@bonniernews/dn-design-system-web/assets/types/shared-props.ts'\nimport { formatClassString } from '@bonniernews/dn-design-system-web/helpers/formatClassString.ts'\nimport { ArticleImage, ArticleImageProps } from '@bonniernews/dn-design-system-web/assets/article-image/article-image.tsx'\n\nexport interface ArticleTopImageProps extends SharedProps, ArticleImageProps { }\n\n/**\n * - GitHub: [BonnierNews/dn-design-system/../web/src/components/article-top-image](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/article-top-image)\n * - Storybook: [ArticleTopImage](https://designsystem.dn.se/?path=/docs/article-articletopimage--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-top-image/article-top-image.scss'`\n */\nexport const ArticleTopImage = ({ caption, imageType, author, image, forcePx, classNames, attributes }: ArticleTopImageProps) => {\n const classes = formatClassString(['ds-article-image--top', classNames])\n\n const imageParams = {\n fullWidth: true,\n caption,\n imageType,\n author,\n image,\n forcePx,\n classNames: classes,\n attributes,\n }\n\n return (\n <ArticleImage {...imageParams} />\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAAO,IAAM,oBAAoB,CAAC,iBAAqD;AACrF,SAAO,aAAa,OAAO,OAAK,CAAC,CAAC,CAAC,EAAE,KAAK,GAAG;AAC/C;;;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