@bonniernews/dn-design-system-web 2.1.0-alpha.16 → 2.1.0-alpha.18
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 +18 -0
- package/components/blocked-content/README.md +61 -0
- package/components/blocked-content/blocked-content.js +84 -0
- package/components/blocked-content/blocked-content.njk +38 -0
- package/components/blocked-content/blocked-content.scss +34 -0
- package/components/byline/byline.scss +0 -14
- package/package.json +1 -1
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.18](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@2.1.0-alpha.17...@bonniernews/dn-design-system-web@2.1.0-alpha.18) (2023-02-27)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **web:** removed top border and update tests threshold ([#701](https://github.com/BonnierNews/dn-design-system/issues/701)) ([058b8d6](https://github.com/BonnierNews/dn-design-system/commit/058b8d68e5521ecc82f5ee879e317384042ec81b))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## 2.1.0-alpha.17 (2023-02-27)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* **web:** blocked content component ([#691](https://github.com/BonnierNews/dn-design-system/issues/691)) ([15ac04e](https://github.com/BonnierNews/dn-design-system/commit/15ac04e5af5785ad99a34a11281e39dfd330dbae))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
6
24
|
## [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
25
|
|
|
8
26
|
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
- GitHub: [BonnierNews/dn-design-system/../web/src/components/blocked-content](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/blocked-content)
|
|
2
|
+
- Storybook (PROD): [BlockedContent > Web](https://designsystem.dn.se/?path=/story/components-app-web-article-components-blocked-content-web--standard)
|
|
3
|
+
- Storybook (LATEST): [BlockedContent > Web](https://designsystem-latest.dn.se/?path=/story/components-app-web-article-components-blocked-content-web--standard)
|
|
4
|
+
|
|
5
|
+
----
|
|
6
|
+
|
|
7
|
+
# Blocked Content
|
|
8
|
+
|
|
9
|
+
This component is available as either a Nunjuck component or a JavaScript component. In Bang we only use the JavaScript variant. The Nunjuck implementation is mostly used to generate the html markup used in the JavaScript component.
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
|parameter | type | required | options | default | description |
|
|
14
|
+
|:--- | :--- | :--- | :--- | :--- | :--- |
|
|
15
|
+
|title | String | yes | | | |
|
|
16
|
+
|body | HTML String | yes | | | |
|
|
17
|
+
|attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
|
|
18
|
+
|elementAttributes | Object | no | | | Sets attributes on button element. Same structure as attributes above |
|
|
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
|
+
|vendor | String | yes (only in JavaScript) | | | JavaScript attribute, not available as njk-parameter |
|
|
22
|
+
|
|
23
|
+
## Minimum requirement example
|
|
24
|
+
|
|
25
|
+
### Nunjucks
|
|
26
|
+
|
|
27
|
+
These are copy paste friendly examples to quickliy get started using a component.
|
|
28
|
+
|
|
29
|
+
```html
|
|
30
|
+
{% from '@bonniernews/dn-design-system-web/components/blocked-content/blocked-content.njk' import BlockedContent %}
|
|
31
|
+
|
|
32
|
+
{{ BlockedContent({
|
|
33
|
+
title: 'Hoppsan, här saknas något',
|
|
34
|
+
body: 'Innehållet från Twitter kunde inte visas på grund av dina val i cookie-inställningarna.'
|
|
35
|
+
})}}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### SCSS
|
|
39
|
+
```scss
|
|
40
|
+
@use "@bonniernews/dn-design-system-web/components/blocked-content/blocked-content" as *;
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Javascript
|
|
44
|
+
|
|
45
|
+
```javascript
|
|
46
|
+
import dsBlockedContent from '@bonniernews/dn-design-system-web/components/blocked-content/blocked-content.js'
|
|
47
|
+
const blockedContentElement = Array.from(document.getElementsByClassName("ds-blocked-content"))[0];
|
|
48
|
+
|
|
49
|
+
// avalaible javascript parameters, matches njk paramaters + vendor:
|
|
50
|
+
const parameters = {
|
|
51
|
+
vendor: "YouTube",
|
|
52
|
+
title: "Videon kunde ej visas",
|
|
53
|
+
body: "För att spela videon behöver du gå till “Inställningar per partner” och godkänna Screen9 AB", // overrides vendor
|
|
54
|
+
classNames: "test-class",
|
|
55
|
+
forcePx: false,
|
|
56
|
+
attributes: { "data-test" : "test-value" },
|
|
57
|
+
elementAttributes: { "onclick": "javascript:Didomi.notice.show()" }
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
dsBlockedContent(blockedContentElement, parameters);
|
|
61
|
+
```
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export {
|
|
2
|
+
dsBlockedContent,
|
|
3
|
+
dsBlockedContentStory
|
|
4
|
+
};
|
|
5
|
+
|
|
6
|
+
function dsBlockedContent(blockedContentEl, params) {
|
|
7
|
+
if (!blockedContentEl) return;
|
|
8
|
+
params = params || {};
|
|
9
|
+
|
|
10
|
+
const blockedContentTmpl = document.createElement("div");
|
|
11
|
+
// NOTE: this should match output of blocked-content.njk
|
|
12
|
+
blockedContentTmpl.innerHTML = `
|
|
13
|
+
<div class="ds-blocked-content">
|
|
14
|
+
<div class="ds-blocked-content__inner">
|
|
15
|
+
<div class="ds-blocked-content__content">
|
|
16
|
+
<h2 class="ds-blocked-content__title">Hoppsan, här saknas något</h2>
|
|
17
|
+
<div class="ds-blocked-content__body">Innehållet från <span class='ds-blocked-content__vendor'></span> kunde inte visas på grund av dina val i cookie-inställningarna.</div>
|
|
18
|
+
</div>
|
|
19
|
+
<button type="button" class="ds-btn ds-btn--secondaryFilled ds-btn--condensed ds-btn--small ds-btn--full-width">
|
|
20
|
+
<div class="ds-btn__inner">
|
|
21
|
+
<span>Integritetsinställningar</span>
|
|
22
|
+
<div class="ds-spinner ds-spinner--small ds-spinner--primary">
|
|
23
|
+
<div class="ds-spinner__inner"></div>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
</button>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
const newBlockedContent = blockedContentTmpl.getElementsByClassName("ds-blocked-content")[0];
|
|
32
|
+
const btnEl = newBlockedContent.getElementsByClassName("ds-btn")[0];
|
|
33
|
+
|
|
34
|
+
if (params.vendor) {
|
|
35
|
+
const vendorEl = newBlockedContent.getElementsByClassName("ds-blocked-content__vendor")[0];
|
|
36
|
+
vendorEl.textContent = params.vendor;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (params.title) {
|
|
40
|
+
const titleEl = newBlockedContent.getElementsByClassName("ds-blocked-content__title")[0];
|
|
41
|
+
titleEl.textContent = params.title;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
if (params.body) {
|
|
45
|
+
const titleEl = newBlockedContent.getElementsByClassName("ds-blocked-content__body")[0];
|
|
46
|
+
titleEl.textContent = params.body;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (params.classNames) {
|
|
50
|
+
newBlockedContent.classList.add(params.classNames);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (params.forcePx) {
|
|
54
|
+
newBlockedContent.classList.add("ds-force-px");
|
|
55
|
+
btnEl.classList.add("ds-force-px");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (params.attributes) {
|
|
59
|
+
for (const [key, value] of Object.entries(params.attributes)) {
|
|
60
|
+
newBlockedContent.setAttribute(key, value);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (params.elementAttributes) {
|
|
65
|
+
for (const [key, value] of Object.entries(params.elementAttributes)) {
|
|
66
|
+
btnEl.setAttribute(key, value);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return newBlockedContent;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** only use in storybook */
|
|
74
|
+
function dsBlockedContentStory() {
|
|
75
|
+
const blockedContentElements = Array.from(document.getElementsByClassName("js-ds-blocked-content-story"));
|
|
76
|
+
if (!blockedContentElements.length) return;
|
|
77
|
+
|
|
78
|
+
blockedContentElements.forEach((blockedContentEl) => {
|
|
79
|
+
const params = JSON.parse(blockedContentEl.getAttribute("data-params"));
|
|
80
|
+
|
|
81
|
+
const newBlockedContent = dsBlockedContent(blockedContentEl, params);
|
|
82
|
+
blockedContentEl.replaceWith(newBlockedContent);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
|
|
2
|
+
{% from '@bonniernews/dn-design-system-web/components/button/button.njk' import Button %}
|
|
3
|
+
|
|
4
|
+
{% macro BlockedContent(params) %}
|
|
5
|
+
{% set componentClassName = "ds-blocked-content" %}
|
|
6
|
+
{% set classNamePrefix = componentClassName + "--" %}
|
|
7
|
+
{% set variant = [] %}
|
|
8
|
+
{% set attributes = getAttributes(params.attributes) %}
|
|
9
|
+
|
|
10
|
+
{% if params.forcePx %}
|
|
11
|
+
{% set variant = (variant.push("ds-force-px"), variant) %}
|
|
12
|
+
{% endif %}
|
|
13
|
+
|
|
14
|
+
{% if params.classNames %}
|
|
15
|
+
{% set variant = (variant.push(params.classNames), variant) %}
|
|
16
|
+
{% endif%}
|
|
17
|
+
|
|
18
|
+
{% set classes = componentClassName + " " + variant | join(" ") %}
|
|
19
|
+
|
|
20
|
+
<div class="{{ classes }}" {{- attributes | safe }}>
|
|
21
|
+
<div class="{{ componentClassName + '__inner'}}">
|
|
22
|
+
<div class="{{ componentClassName + '__content'}}">
|
|
23
|
+
<h2 class="{{ componentClassName + '__title'}}">{{ params.title }}</h2>
|
|
24
|
+
<div class="{{ componentClassName + '__body'}}">{{ params.body }}</div>
|
|
25
|
+
</div>
|
|
26
|
+
{{ Button({
|
|
27
|
+
text: 'Integritetsinställningar',
|
|
28
|
+
variant: 'secondaryFilled',
|
|
29
|
+
size: 'small',
|
|
30
|
+
classNames: '',
|
|
31
|
+
fullWidth: true,
|
|
32
|
+
forcePx: params.forcePx,
|
|
33
|
+
condensed: true,
|
|
34
|
+
attributes: params.elementAttributes
|
|
35
|
+
})}}
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
{% endmacro %}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
@use "../../foundations/helpers/forward.helpers.scss" as *;
|
|
2
|
+
@use "../button/button.scss" as *;
|
|
3
|
+
|
|
4
|
+
.ds-blocked-content {
|
|
5
|
+
background-color: $ds-color-surface-background;
|
|
6
|
+
margin: 0;
|
|
7
|
+
padding: ds-spacing-layout(
|
|
8
|
+
gap-vertical-static-medium 0 gap-vertical-static-large
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
.ds-blocked-content__inner {
|
|
12
|
+
text-align: center;
|
|
13
|
+
border: ds-metrics-border-width(x1) solid $ds-color-border-primary;
|
|
14
|
+
border-radius: ds-metrics-border-radius(x1);
|
|
15
|
+
padding: ds-spacing-component(x8 x4 x4);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.ds-blocked-content__body {
|
|
19
|
+
margin: ds-spacing-component(0 0 x8);
|
|
20
|
+
@include ds-typography($ds-typography-functional-body02regular);
|
|
21
|
+
color: $ds-color-text-primary;
|
|
22
|
+
@at-root .ds-force-px#{&} {
|
|
23
|
+
@include ds-typography($ds-typography-functional-body02regular, true);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
.ds-blocked-content__title {
|
|
27
|
+
@include ds-typography($ds-typography-functional-heading01medium);
|
|
28
|
+
color: $ds-color-text-primary;
|
|
29
|
+
margin: 0 0 ds-spacing-component(x2);
|
|
30
|
+
@at-root .ds-force-px#{&} {
|
|
31
|
+
@include ds-typography($ds-typography-functional-heading01medium, true);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -8,12 +8,6 @@ $ds-byline__image-size: 44px;
|
|
|
8
8
|
.ds-byline__outer {
|
|
9
9
|
list-style: none;
|
|
10
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
11
|
}
|
|
18
12
|
|
|
19
13
|
.ds-byline {
|
|
@@ -26,7 +20,6 @@ $ds-byline__image-size: 44px;
|
|
|
26
20
|
width: 100%;
|
|
27
21
|
position: relative;
|
|
28
22
|
|
|
29
|
-
&::before,
|
|
30
23
|
&::after {
|
|
31
24
|
content: "";
|
|
32
25
|
height: ds-metrics-border-width(x1);
|
|
@@ -34,13 +27,6 @@ $ds-byline__image-size: 44px;
|
|
|
34
27
|
background-color: $ds-color-border-primary;
|
|
35
28
|
position: absolute;
|
|
36
29
|
left: ds-spacing-component(x4);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
&::before {
|
|
40
|
-
top: 0;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
&::after {
|
|
44
30
|
bottom: 0;
|
|
45
31
|
}
|
|
46
32
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bonniernews/dn-design-system-web",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.18",
|
|
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",
|