@bonniernews/dn-design-system-web 4.0.0 → 4.1.0-alpha.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 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
+ ## 4.1.0-alpha.0 (2023-08-23)
7
+
8
+
9
+ ### Features
10
+
11
+ * **web:** add link to blockedcontent ([#919](https://github.com/BonnierNews/dn-design-system/issues/919)) ([98c0d92](https://github.com/BonnierNews/dn-design-system/commit/98c0d92d6ce19c2e3b42ed97f142374662b02fc4))
12
+
13
+
14
+
15
+ ## 4.0.1-alpha.0 (2023-08-21)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **web:** overly generous has-selector in teaser-package ([#930](https://github.com/BonnierNews/dn-design-system/issues/930)) ([99bd04b](https://github.com/BonnierNews/dn-design-system/commit/99bd04b74cbf65701c482c090b51d7a79bb09bbe))
21
+
22
+
23
+
6
24
  ## 4.0.0 (2023-08-16)
7
25
 
8
26
 
@@ -14,6 +14,7 @@ This component is available as either a Nunjuck component or a JavaScript compon
14
14
  |:--- | :--- | :--- | :--- | :--- | :--- |
15
15
  |title | String | yes | | | |
16
16
  |body | HTML String | yes | | | |
17
+ |link | String | no | | | Ex "https://twitter.com/LAGalaxy/status/1665752957919592448" will be injected on a new line below body |
17
18
  |attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
18
19
  |elementAttributes | Object | no | | | Sets attributes on button element. Same structure as attributes above |
19
20
  |classNames | String | no | | | Ex. "my-special-class" |
@@ -31,7 +32,8 @@ These are copy paste friendly examples to quickliy get started using a component
31
32
 
32
33
  {{ BlockedContent({
33
34
  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
+ body: 'Innehållet från Twitter kunde inte visas på grund av dina val i cookie-inställningarna.',
36
+ link: 'https://twitter.com/LAGalaxy/status/1665752957919592448'
35
37
  })}}
36
38
  ```
37
39
 
@@ -46,14 +48,14 @@ These are copy paste friendly examples to quickliy get started using a component
46
48
  import { dsBlockedContent } from '@bonniernews/dn-design-system-web/components/blocked-content/blocked-content.js'
47
49
 
48
50
  // avalaible javascript parameters, matches njk paramaters + vendor:
49
- const parameters = {
51
+ const parameters = {
50
52
  vendor: "YouTube",
51
53
  title: "Videon kunde ej visas",
52
54
  body: "För att spela videon behöver du gå till “Inställningar per partner” och godkänna Screen9 AB", // overrides vendor
53
55
  classNames: "test-class",
54
56
  forcePx: false,
55
57
  attributes: { "data-test" : "test-value" },
56
- elementAttributes: { "onclick": "javascript:Didomi.notice.show()" }
58
+ elementAttributes: { "onClick": "javascript:Didomi.notice.show()" }
57
59
  }
58
60
 
59
61
  const blockedContentHtml = dsBlockedContent(parameters);
@@ -13,7 +13,7 @@ function dsBlockedContent(params) {
13
13
  <div class="ds-blocked-content__inner">
14
14
  <div class="ds-blocked-content__content">
15
15
  <h2 class="ds-blocked-content__title">Hoppsan, här saknas något</h2>
16
- <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>
16
+ <div class="ds-blocked-content__body">Innehållet ${ params.vendor ? `från ${params.vendor}` : '' } kunde inte visas på grund av dina val i cookie-inställningarna.</div>
17
17
  </div>
18
18
  <button type="button" class="ds-btn ds-btn--secondaryFilled ds-btn--condensed ds-btn--small ds-btn--full-width">
19
19
  <div class="ds-btn__inner">
@@ -29,20 +29,28 @@ function dsBlockedContent(params) {
29
29
 
30
30
  const newBlockedContent = blockedContentTmpl.getElementsByClassName("ds-blocked-content")[0];
31
31
  const btnEl = newBlockedContent.getElementsByClassName("ds-btn")[0];
32
+ const bodyEl = newBlockedContent.getElementsByClassName("ds-blocked-content__body")[0];
32
33
 
33
- if (params.vendor) {
34
- const vendorEl = newBlockedContent.getElementsByClassName("ds-blocked-content__vendor")[0];
35
- vendorEl.textContent = params.vendor;
36
- }
37
-
38
34
  if (params.title) {
39
35
  const titleEl = newBlockedContent.getElementsByClassName("ds-blocked-content__title")[0];
40
36
  titleEl.textContent = params.title;
41
37
  }
42
38
 
43
39
  if (params.body) {
44
- const titleEl = newBlockedContent.getElementsByClassName("ds-blocked-content__body")[0];
45
- titleEl.textContent = params.body;
40
+ bodyEl.textContent = params.body;
41
+ }
42
+
43
+ if (params.link) {
44
+ const linkContainerEl = document.createElement("div");
45
+ const linkEl = document.createElement("a");
46
+ linkEl.href = params.link;
47
+ linkEl.innerText = params.link;
48
+ linkEl.className = "ds-blocked-content__link";
49
+ if (params.vendor) {
50
+ linkEl.setAttribute("aria-label", `Länk till innehåll på ${params.vendor}`);
51
+ }
52
+ linkContainerEl.appendChild(linkEl)
53
+ bodyEl.appendChild(linkContainerEl);
46
54
  }
47
55
 
48
56
  if (params.classNames) {
@@ -21,7 +21,10 @@
21
21
  <div class="{{ componentClassName + '__inner'}}">
22
22
  <div class="{{ componentClassName + '__content'}}">
23
23
  <h2 class="{{ componentClassName + '__title'}}">{{ params.title }}</h2>
24
- <div class="{{ componentClassName + '__body'}}">{{ params.body }}</div>
24
+ <div class="{{ componentClassName + '__body'}}">
25
+ {{ params.body }}
26
+ <a class="{{ componentClassName + '__link'}}" href="{{ params.link }}">{{params.link}}</a>
27
+ </div>
25
28
  </div>
26
29
  {{ Button({
27
30
  text: 'Integritetsinställningar',
@@ -23,6 +23,14 @@
23
23
  @include ds-typography($ds-typography-functional-body02regular, true);
24
24
  }
25
25
  }
26
+
27
+ .ds-blocked-content__link {
28
+ @include ds-link($ds-link-paragraph);
29
+ display: inline-block;
30
+ margin-top: ds-spacing-component($ds-sc-x2);
31
+ word-break: break-word;
32
+ }
33
+
26
34
  .ds-blocked-content__title {
27
35
  @include ds-typography($ds-typography-functional-heading01semibold);
28
36
  color: $ds-color-text-primary;
@@ -39,7 +39,7 @@
39
39
  z-index: 5;
40
40
  }
41
41
 
42
- &:has(.ds-teaser:only-child)::after {
42
+ &:has(> .ds-teaser:only-child)::after {
43
43
  display: none;
44
44
  }
45
45
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonniernews/dn-design-system-web",
3
- "version": "4.0.0",
3
+ "version": "4.1.0-alpha.0",
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",