@bonniernews/dn-design-system-web 3.0.0-alpha.90 → 3.0.0-alpha.92

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,28 @@
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.92](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@3.0.0-alpha.91...@bonniernews/dn-design-system-web@3.0.0-alpha.92) (2023-06-08)
7
+
8
+
9
+ ### Features
10
+
11
+ * **web:** add js-rendered teaser-standard ([#873](https://github.com/BonnierNews/dn-design-system/issues/873)) ([4cabd62](https://github.com/BonnierNews/dn-design-system/commit/4cabd6242afd5e717fd2a6758724e92d68340130))
12
+
13
+
14
+
15
+ ## [3.0.0-alpha.91](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@3.0.0-alpha.90...@bonniernews/dn-design-system-web@3.0.0-alpha.91) (2023-06-07)
16
+
17
+
18
+ ### ⚠ BREAKING CHANGES
19
+
20
+ * **foundations:** update tokens from Figma (#872)
21
+
22
+ ### Miscellaneous Chores
23
+
24
+ * **foundations:** update tokens from Figma ([#872](https://github.com/BonnierNews/dn-design-system/issues/872)) ([2bf7b9f](https://github.com/BonnierNews/dn-design-system/commit/2bf7b9f79430d0f81e0d856f00d26498b7e0fffe))
25
+
26
+
27
+
6
28
  ## 3.0.0-alpha.90 (2023-06-07)
7
29
 
8
30
 
@@ -15,15 +15,10 @@
15
15
  .ds-teaser__content {
16
16
  display: flex;
17
17
  flex-direction: row;
18
- @include ds-spacing-layout($ds-sl-teaser-vertical $ds-sl-teaser-horizontal);
19
-
20
- // Special case for large teaser, should be replaced with dynamic spacing layout token when available
21
- @include ds-mq-only-breakpoint(mobile) {
22
- padding-bottom: ds-spacing-component($ds-sc-x3);
23
- }
24
- @include ds-mq-smallest-breakpoint(tablet) {
25
- padding-bottom: ds-spacing-component($ds-sc-x4);
26
- }
18
+ @include ds-spacing-layout(
19
+ $ds-sl-teaser-vertical-small $ds-sl-teaser-horizontal
20
+ $ds-sl-teaser-vertical-medium
21
+ );
27
22
 
28
23
  .ds-teaser__content-inner {
29
24
  display: flex;
@@ -2,7 +2,9 @@
2
2
  @use "../../assets/teaser/teaser.scss" as *;
3
3
 
4
4
  .ds-teaser.ds-teaser--onsite {
5
- @include ds-spacing-layout($ds-sl-teaser-vertical $ds-sl-teaser-horizontal);
5
+ @include ds-spacing-layout(
6
+ $ds-sl-teaser-vertical-medium $ds-sl-teaser-horizontal
7
+ );
6
8
  display: flex;
7
9
 
8
10
  .ds-teaser__title {
@@ -6,7 +6,9 @@
6
6
  display: flex;
7
7
  flex-direction: row;
8
8
  align-items: center;
9
- @include ds-spacing-layout($ds-sl-teaser-vertical $ds-sl-teaser-horizontal);
9
+ @include ds-spacing-layout(
10
+ $ds-sl-teaser-vertical-medium $ds-sl-teaser-horizontal
11
+ );
10
12
 
11
13
  .ds-teaser__content {
12
14
  padding-left: ds-spacing-component($ds-sc-x3);
@@ -14,7 +14,12 @@
14
14
  }
15
15
 
16
16
  .ds-teaser__content {
17
- @include ds-spacing-layout($ds-sl-teaser-vertical $ds-sl-teaser-horizontal);
17
+ @include ds-spacing-layout(
18
+ $ds-sl-teaser-vertical-medium $ds-sl-teaser-horizontal
19
+ );
20
+ padding-bottom: ds-spacing-component(
21
+ $ds-sc-x4
22
+ ) !important; // !important to override spacing set in media query above
18
23
  display: block;
19
24
  color: $ds-color-text-primary;
20
25
 
@@ -2,7 +2,10 @@
2
2
  @use "../../assets/teaser/teaser.scss" as *;
3
3
 
4
4
  .ds-split-container {
5
- @include ds-spacing-layout($ds-sl-teaser-vertical $ds-sl-teaser-horizontal);
5
+ @include ds-spacing-layout(
6
+ $ds-sl-teaser-vertical-small $ds-sl-teaser-horizontal
7
+ $ds-sl-teaser-vertical-medium
8
+ );
6
9
  display: flex;
7
10
  flex-wrap: wrap;
8
11
  position: relative;
@@ -49,8 +52,8 @@
49
52
  &:nth-child(4)::before {
50
53
  display: block;
51
54
  content: "";
52
- @include ds-spacing-layout($ds-sl-teaser-vertical, margin-top);
53
- @include ds-spacing-layout($ds-sl-teaser-vertical, padding-top);
55
+ @include ds-spacing-layout($ds-sl-teaser-vertical-medium, margin-top);
56
+ @include ds-spacing-layout($ds-sl-teaser-vertical-small, padding-top);
54
57
  border-top: ds-metrics-border-width(x1) solid $ds-color-border-primary;
55
58
 
56
59
  @include ds-mq-smallest-breakpoint(tablet) {
@@ -29,11 +29,9 @@
29
29
  |~forcePx~ | | | | | Not supported |
30
30
 
31
31
  ## Minimum requirement example
32
-
33
- ### Nunjucks
34
-
35
32
  These are copy paste friendly examples to quickliy get started using a component.
36
33
 
34
+ ### Nunjucks
37
35
  ```html
38
36
  {% from '@bonniernews/dn-design-system-web/components/teaser-standard/teaser-standard.njk' import TeaserStandard %}
39
37
 
@@ -48,3 +46,20 @@ These are copy paste friendly examples to quickliy get started using a component
48
46
  ```scss
49
47
  @use "@bonniernews/dn-design-system-web/components/teaser-standard/teaser-standard" as *;
50
48
  ```
49
+
50
+ ### Javascript
51
+ This version is rarely used to render a teaser dynamically in the browser. For example, it is used to render reserv-teasers in failover. This version **ONLY** supports the `title`, `text`, `targetLink`, `classNames` and `attributes` parameters.
52
+
53
+ ```javascript
54
+ import { dsTeaserStandard } from "@bonniernews/dn-design-system-web/components/teaser-standard/teaser-standard";
55
+
56
+ // NB: javascript only supports a subset of all parameters
57
+ const parameters = {
58
+ title: "Upp på börsen",
59
+ text: "Det ser ganska normalt ut på Stockholmsbörsen",
60
+ targetLink: "https://www.dn.se/ekonomi/",
61
+ attributes: { "data-test" : "test-value" }
62
+ }
63
+
64
+ const teaserStandardHtml = dsTeaserStandard(parameters);
65
+ ```
@@ -0,0 +1,53 @@
1
+ export {
2
+ dsTeaserStandard,
3
+ dsTeaserStandardStory
4
+ };
5
+
6
+ function dsTeaserStandard(params = {}) {
7
+ const teaser = document.createElement("a");
8
+ // NOTE: this should match output of teaser-standard.njk for a subset of the parameters
9
+ teaser.innerHTML = `
10
+ <div class="ds-teaser__content">
11
+ <div class="ds-teaser__title"></div>
12
+ <p class="ds-teaser__text">
13
+ <span class="ds-teaser-dot"></span>
14
+ </p>
15
+ </div>`;
16
+ teaser.classList.add("ds-teaser");
17
+ teaser.classList.add("ds-teaser--standard");
18
+
19
+ if (params.targetLink) {
20
+ teaser.setAttribute("href", params.targetLink)
21
+ }
22
+
23
+ if (params.title) {
24
+ const titleEl = teaser.getElementsByClassName("ds-teaser__title")[0];
25
+ titleEl.textContent = params.title;
26
+ }
27
+
28
+ if (params.text) {
29
+ const textEl = teaser.getElementsByClassName("ds-teaser__text")[0];
30
+ textEl.appendChild(document.createTextNode(params.text))
31
+ }
32
+
33
+ if (params.classNames) {
34
+ teaser.classList.add(params.classNames);
35
+ }
36
+
37
+ if (params.attributes) {
38
+ for (const [key, value] of Object.entries(params.attributes)) {
39
+ teaser.setAttribute(key, value);
40
+ }
41
+ }
42
+
43
+ return teaser;
44
+ }
45
+
46
+ /** only use in storybook */
47
+ function dsTeaserStandardStory() {
48
+ const jsTeasers = Array.from(document.getElementsByClassName("js-ds-teaser-standard-story"));
49
+ jsTeasers.forEach((teaserEl) => {
50
+ const params = JSON.parse(teaserEl.getAttribute("data-params"));
51
+ teaserEl.replaceWith(dsTeaserStandard(params));
52
+ });
53
+ }
@@ -3,8 +3,10 @@
3
3
 
4
4
  .ds-teaser.ds-teaser--standard {
5
5
  display: flex;
6
-
7
- @include ds-spacing-layout($ds-sl-teaser-vertical $ds-sl-teaser-horizontal);
6
+ @include ds-spacing-layout(
7
+ $ds-sl-teaser-vertical-small $ds-sl-teaser-horizontal
8
+ $ds-sl-teaser-vertical-medium
9
+ );
8
10
 
9
11
  .ds-teaser__title {
10
12
  @include ds-typography($ds-typography-expressive-heading03bold);
@@ -3,7 +3,10 @@
3
3
 
4
4
  .ds-teaser.ds-teaser--tipsa {
5
5
  .ds-teaser__content {
6
- @include ds-spacing-layout($ds-sl-teaser-vertical $ds-sl-teaser-horizontal);
6
+ @include ds-spacing-layout(
7
+ $ds-sl-teaser-vertical-small $ds-sl-teaser-horizontal
8
+ $ds-sl-teaser-vertical-medium
9
+ );
7
10
  }
8
11
 
9
12
  .ds-teaser__title {
@@ -9,7 +9,8 @@ $spacingLayout: (
9
9
  gap-horizontal-static-small: 8,
10
10
  gap-vertical-static-small: 8,
11
11
  page-top-xsmall: 4,
12
- teaser-vertical: 8,
12
+ teaser-vertical-small: 8,
13
13
  teaser-horizontal: 16,
14
- gap-vertical-xsmall: 4
14
+ gap-vertical-xsmall: 4,
15
+ teaser-vertical-medium: 12
15
16
  );
@@ -5,9 +5,10 @@ $spacingLayoutLargeScreen: (
5
5
  page-horizontal: 32,
6
6
  gap-vertical-medium: 32,
7
7
  page-top-xsmall: 8,
8
- teaser-vertical: 12,
8
+ teaser-vertical-small: 12,
9
9
  teaser-horizontal: 16,
10
10
  gap-vertical-xsmall: 8,
11
+ teaser-vertical-medium: 16,
11
12
  gap-vertical-static-medium: 16,
12
13
  gap-vertical-static-large: 32,
13
14
  gap-horizontal-static-small: 8,
@@ -8,6 +8,7 @@ $ds-sl-gap-vertical-static-large: gap-vertical-static-large;
8
8
  $ds-sl-gap-horizontal-static-small: gap-horizontal-static-small;
9
9
  $ds-sl-gap-vertical-static-small: gap-vertical-static-small;
10
10
  $ds-sl-page-top-xsmall: page-top-xsmall;
11
- $ds-sl-teaser-vertical: teaser-vertical;
11
+ $ds-sl-teaser-vertical-small: teaser-vertical-small;
12
12
  $ds-sl-teaser-horizontal: teaser-horizontal;
13
13
  $ds-sl-gap-vertical-xsmall: gap-vertical-xsmall;
14
+ $ds-sl-teaser-vertical-medium: teaser-vertical-medium;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonniernews/dn-design-system-web",
3
- "version": "3.0.0-alpha.90",
3
+ "version": "3.0.0-alpha.92",
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",
@@ -9,7 +9,8 @@
9
9
  "gap-horizontal-static-small": "gap-horizontal-static-small",
10
10
  "gap-vertical-static-small": "gap-vertical-static-small",
11
11
  "page-top-xsmall": "page-top-xsmall",
12
- "teaser-vertical": "teaser-vertical",
12
+ "teaser-vertical-small": "teaser-vertical-small",
13
13
  "teaser-horizontal": "teaser-horizontal",
14
- "gap-vertical-xsmall": "gap-vertical-xsmall"
14
+ "gap-vertical-xsmall": "gap-vertical-xsmall",
15
+ "teaser-vertical-medium": "teaser-vertical-medium"
15
16
  }