@bonniernews/dn-design-system-web 3.0.0-alpha.2 → 3.0.0-alpha.3
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 +9 -0
- package/assets/article-image/article-image.njk +33 -0
- package/assets/article-image/article-image.scss +20 -0
- package/components/article-body-image/README.md +42 -0
- package/components/article-body-image/article-body-image.njk +23 -0
- package/components/article-body-image/article-body-image.scss +8 -0
- package/components/article-top-image/README.md +40 -0
- package/components/article-top-image/article-top-image.njk +23 -0
- package/components/article-top-image/article-top-image.scss +6 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,15 @@
|
|
|
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
|
+
## [3.0.0-alpha.3](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@3.0.0-alpha.2...@bonniernews/dn-design-system-web@3.0.0-alpha.3) (2023-03-08)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **web:** article image ([#697](https://github.com/BonnierNews/dn-design-system/issues/697)) ([e3e9cec](https://github.com/BonnierNews/dn-design-system/commit/e3e9cecd96f4d6240854ffc593a082f7d6c66793))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
6
15
|
## [3.0.0-alpha.2](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@3.0.0-alpha.1...@bonniernews/dn-design-system-web@3.0.0-alpha.2) (2023-03-06)
|
|
7
16
|
|
|
8
17
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{% macro ArticleImage(params) %}
|
|
2
|
+
{% set macroClassName = "ds-article-image" %}
|
|
3
|
+
{% set additionalClasses = [] %}
|
|
4
|
+
|
|
5
|
+
{% if params.classNames %}
|
|
6
|
+
{% set additionalClasses = (additionalClasses.push(params.classNames), additionalClasses) %}
|
|
7
|
+
{% endif %}
|
|
8
|
+
|
|
9
|
+
{% set classes = macroClassName + " " + additionalClasses | join(" ") %}
|
|
10
|
+
|
|
11
|
+
<figure class="{{ classes }}" {{- params.attributes | safe }}>
|
|
12
|
+
{% if params.fullWidth %}
|
|
13
|
+
<div class="ds-full-width-element">
|
|
14
|
+
{{ params.imageHtml | safe }}
|
|
15
|
+
</div>
|
|
16
|
+
{% else %}
|
|
17
|
+
{{ params.imageHtml | safe }}
|
|
18
|
+
{% endif %}
|
|
19
|
+
|
|
20
|
+
{% if params.caption or params.author %}
|
|
21
|
+
<figcaption>
|
|
22
|
+
{% if params.caption %}
|
|
23
|
+
<span aria-hidden="true">{{ params.caption | safe }}</span>
|
|
24
|
+
{% endif %}
|
|
25
|
+
{% if params.author %}
|
|
26
|
+
<span class="ds-article-image__credits">
|
|
27
|
+
{%- if params.imageType %}{{ params.imageType | capitalize }}: {% endif %}{{ params.author -}}
|
|
28
|
+
</span>
|
|
29
|
+
{% endif %}
|
|
30
|
+
</figcaption>
|
|
31
|
+
{% endif %}
|
|
32
|
+
</figure>
|
|
33
|
+
{% endmacro %}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
@use "../../foundations/helpers/forward.helpers.scss" as *;
|
|
2
|
+
|
|
3
|
+
.ds-article-image {
|
|
4
|
+
margin: 0;
|
|
5
|
+
|
|
6
|
+
> figcaption {
|
|
7
|
+
@include ds-typography($ds-typography-functional-body01regular);
|
|
8
|
+
margin-top: ds-spacing-component(x2);
|
|
9
|
+
color: $ds-color-text-primary;
|
|
10
|
+
|
|
11
|
+
@at-root .ds-force-px#{&} {
|
|
12
|
+
@include ds-typography($ds-typography-functional-body01regular, true);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
> .ds-article-image__credits {
|
|
16
|
+
display: block;
|
|
17
|
+
color: $ds-color-text-primary-02;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
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: [Disclaimer > Web](https://designsystem.dn.se/?path=/story/components-app-web-article-components-image-bodyimage-web--article-body-image)
|
|
3
|
+
|
|
4
|
+
----
|
|
5
|
+
|
|
6
|
+
# ArticleBodyImage
|
|
7
|
+
|
|
8
|
+
## Parameters
|
|
9
|
+
|
|
10
|
+
|parameter | type | required | options | default | description |
|
|
11
|
+
|:--- | :--- | :--- | :--- | :--- | :--- |
|
|
12
|
+
|imageHtml | String | yes | | | Use to populate figure tag with image information |
|
|
13
|
+
|fullWidth | Bool | no | true, false | false | Image will have styleable wrapping element |
|
|
14
|
+
|caption | String | no | | | Ex "Detta är en bildtext" |
|
|
15
|
+
|imageType | String | no | | | Type of image. Ex "Foto" |
|
|
16
|
+
|author | String | no | | | Ex "Paul Hansen" |
|
|
17
|
+
|attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
|
|
18
|
+
|classNames | String | no | | | Ex. "my-special-class" |
|
|
19
|
+
|forcePx | Bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
|
|
20
|
+
|
|
21
|
+
## Minimum requirement example
|
|
22
|
+
|
|
23
|
+
### Nunjucks
|
|
24
|
+
|
|
25
|
+
These are copy paste friendly examples to quickliy get started using a component.
|
|
26
|
+
|
|
27
|
+
```html
|
|
28
|
+
{% from '@bonniernews/dn-design-system-web/components/article-body-image/article-body-image.njk' import ArticleBodyImage %}
|
|
29
|
+
|
|
30
|
+
{{ ArticleBodyImage({
|
|
31
|
+
imageHtml: exampleArticleBodyImageHtml(),
|
|
32
|
+
fullWidth: true,
|
|
33
|
+
caption: "En bildtext",
|
|
34
|
+
imageType: "Foto",
|
|
35
|
+
author: "Paul Hansen",
|
|
36
|
+
})}}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### SCSS
|
|
40
|
+
```scss
|
|
41
|
+
@use "@bonniernews/dn-design-system-web/components/article-body-image/article-body-image";
|
|
42
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
|
|
2
|
+
{% from '@bonniernews/dn-design-system-web/assets/article-image/article-image.njk' import ArticleImage %}
|
|
3
|
+
{% set classes = [] %}
|
|
4
|
+
|
|
5
|
+
{% macro ArticleBodyImage(params) %}
|
|
6
|
+
{% set componentClassName = "ds-article-image--body" %}
|
|
7
|
+
{% set additionalClasses = [] %}
|
|
8
|
+
{% set attributes = getAttributes(params.attributes) %}
|
|
9
|
+
|
|
10
|
+
{% if params.classNames %}
|
|
11
|
+
{% set additionalClasses = (additionalClasses.push(params.classNames), additionalClasses) %}
|
|
12
|
+
{% endif %}
|
|
13
|
+
|
|
14
|
+
{% if params.forcePx %}
|
|
15
|
+
{% set additionalClasses = (additionalClasses.push("ds-force-px"), additionalClasses) %}
|
|
16
|
+
{% endif %}
|
|
17
|
+
|
|
18
|
+
{% set classes = componentClassName + " " + additionalClasses | join(" ") %}
|
|
19
|
+
|
|
20
|
+
{% set imageParams = { fullWidth: params.fullWidth, caption: params.caption, imageType: params.imageType, author: params.author, imageHtml: params.imageHtml, classNames: classes, attributes: attributes } %}
|
|
21
|
+
|
|
22
|
+
{% call ArticleImage(imageParams) %}{% endcall %}
|
|
23
|
+
{% endmacro %}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
- 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)
|
|
2
|
+
- Storybook: [Disclaimer > Web](https://designsystem.dn.se/?path=/story/components-app-web-article-components-image-topimage-web--article-top-image)
|
|
3
|
+
|
|
4
|
+
----
|
|
5
|
+
|
|
6
|
+
# ArticleTopImage
|
|
7
|
+
|
|
8
|
+
## Parameters
|
|
9
|
+
|
|
10
|
+
|parameter | type | required | options | default | description |
|
|
11
|
+
|:--- | :--- | :--- | :--- | :--- | :--- |
|
|
12
|
+
|imageHtml | String | yes | | | Use to populate figure tag with image information |
|
|
13
|
+
|caption | String | no | | | Ex "Detta är en bildtext" |
|
|
14
|
+
|imageType | String | no | | | Type of image. Ex "Foto" |
|
|
15
|
+
|author | String | no | | | Ex "Paul Hansen" |
|
|
16
|
+
|attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
|
|
17
|
+
|classNames | String | no | | | Ex. "my-special-class" |
|
|
18
|
+
|forcePx | Bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
|
|
19
|
+
|
|
20
|
+
## Minimum requirement example
|
|
21
|
+
|
|
22
|
+
### Nunjucks
|
|
23
|
+
|
|
24
|
+
These are copy paste friendly examples to quickliy get started using a component.
|
|
25
|
+
|
|
26
|
+
```html
|
|
27
|
+
{% from '@bonniernews/dn-design-system-web/components/article-top-image/article-top-image.njk' import ArticleTopImage %}
|
|
28
|
+
|
|
29
|
+
{{ ArticleTopImage({
|
|
30
|
+
imageHtml: exampleArticleTopImageHtml(),
|
|
31
|
+
caption: "En bildtext",
|
|
32
|
+
imageType: "Foto",
|
|
33
|
+
author: "Beatrice Lundborg",
|
|
34
|
+
})}}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### SCSS
|
|
38
|
+
```scss
|
|
39
|
+
@use "@bonniernews/dn-design-system-web/components/article-top-image/article-top-image";
|
|
40
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
|
|
2
|
+
{% from '@bonniernews/dn-design-system-web/assets/article-image/article-image.njk' import ArticleImage %}
|
|
3
|
+
{% set classes = [] %}
|
|
4
|
+
|
|
5
|
+
{% macro ArticleTopImage(params) %}
|
|
6
|
+
{% set componentClassName = "ds-article-image--top" %}
|
|
7
|
+
{% set additionalClasses = [] %}
|
|
8
|
+
{% set attributes = getAttributes(params.attributes) %}
|
|
9
|
+
|
|
10
|
+
{% if params.classNames %}
|
|
11
|
+
{% set additionalClasses = (additionalClasses.push(params.classNames), additionalClasses) %}
|
|
12
|
+
{% endif %}
|
|
13
|
+
|
|
14
|
+
{% if params.forcePx %}
|
|
15
|
+
{% set additionalClasses = (additionalClasses.push("ds-force-px"), additionalClasses) %}
|
|
16
|
+
{% endif %}
|
|
17
|
+
|
|
18
|
+
{% set classes = componentClassName + " " + additionalClasses | join(" ") %}
|
|
19
|
+
|
|
20
|
+
{% set imageParams = { fullWidth: true, caption: params.caption, imageType: params.imageType, author: params.author, imageHtml: params.imageHtml, classNames: classes, attributes: attributes } %}
|
|
21
|
+
|
|
22
|
+
{% call ArticleImage(imageParams) %}{% endcall %}
|
|
23
|
+
{% endmacro %}
|
package/package.json
CHANGED