@bonniernews/dn-design-system-web 31.0.0 → 31.0.1-beta.2

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.
File without changes
@@ -0,0 +1,67 @@
1
+ - GitHub: [BonnierNews/dn-design-system/../web/src/components/teaser-standard](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/teaser-standard)
2
+ - Storybook: [TeaserStandard](https://designsystem.dn.se/?path=/docs/section-teaserstandard--docs)
3
+ - Storybook (Latest): [TeaserStandard](https://designsystem-latest.dn.se/?path=/docs/section-teaserstandard--docs)
4
+
5
+ ----
6
+
7
+ # teaser-standard
8
+
9
+ ## Parameters
10
+
11
+ |parameter | type | required | options | default | description |
12
+ |:--- | :--- | :--- | :--- | :--- | :--- |
13
+ |title | String | yes | | | Heading of the teaser |
14
+ |targetLink | String | yes | | | Target URL for the teaser |
15
+ |variant | String | no | "default" or "podcast" | "default" | |
16
+ |areaType | String | no | "right" or "bauta" or "bautaxl" | | The area where the column is rendered |
17
+ |theme | String | no | nyheter, kultur | (empty) | The theme-class to apply to the teaser |
18
+ |text | String | no | | | Teaser subtext |
19
+ |vignette | String | no | | | Top text in the teaser |
20
+ |highlight | String | no | | | Text before the heading |
21
+ |sticker | String | no | | | Red text before the text |
22
+ |mediaHtml | HTML String | no | | | Main image or other media |
23
+ |isItalicHeadline | bool | no | true, false | false | If the headline should be italic |
24
+ |isCompact | bool | no | true, false | false | If the headline should be compact |
25
+ |isFlashingDot | bool | no | true, false | false | If there should be a flashing ball before the text |
26
+ |publicationTime | string | no | | null | Publication time text. |
27
+ |duration | string | no | | null | Duration of podcast. |
28
+ |isSquareImage | boolean | no | | false | Flag so we can handle square teaser images |
29
+ |attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
30
+ |classNames | String | no | | | Ex. "my-special-class" |
31
+ |~forcePx~ | | | | | Not supported |
32
+
33
+ ## Minimum requirement example
34
+ These are copy paste friendly examples to quickliy get started using a component.
35
+
36
+ ### Nunjucks
37
+ ```html
38
+ {% from '@bonniernews/dn-design-system-web/components/teaser-standard/teaser-standard.njk' import TeaserStandard %}
39
+
40
+ {{ TeaserStandard({
41
+ title: "Upp på börsen",
42
+ text: "Det ser ganska normalt ut på Stockholmsbörsen.",
43
+ highlight: "Ekonominytt:"
44
+ })}}
45
+ ```
46
+
47
+ ### SCSS
48
+ ```scss
49
+ @use "@bonniernews/dn-design-system-web/components/teaser-standard/teaser-standard" as *;
50
+ ```
51
+
52
+ ### Javascript
53
+ 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.
54
+
55
+ ```javascript
56
+ import { dsTeaserStandard } from "@bonniernews/dn-design-system-web/components/teaser-standard/teaser-standard";
57
+
58
+ // NB: javascript only supports a subset of all parameters
59
+ const parameters = {
60
+ title: "Upp på börsen",
61
+ text: "Det ser ganska normalt ut på Stockholmsbörsen",
62
+ targetLink: "https://www.dn.se/ekonomi/",
63
+ attributes: { "data-test" : "test-value" }
64
+ }
65
+
66
+ const teaserStandardHtml = dsTeaserStandard(parameters);
67
+ ```
@@ -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
+ }
@@ -0,0 +1,42 @@
1
+ {% from '@bonniernews/dn-design-system-web/components/teaser-card/teaser-card.njk' import TeaserCard %}
2
+ {% from '@bonniernews/dn-design-system-web/components/teaser-dot/teaser-dot.njk' import TeaserDot %}
3
+ {% from '@bonniernews/dn-design-system-web/components/teaser-footer/teaser-footer.njk' import TeaserFooter %}
4
+ {% from '@bonniernews/dn-design-system-web/components/icon-sprite/icon-sprite.njk' import IconUse %}
5
+
6
+ {% macro TeaserTextOnImage(params) %}
7
+ {% set componentClassName = "ds-teaser" %}
8
+ {% set classNamePrefix = componentClassName + "--" %}
9
+
10
+ {% set extraClasses = [
11
+ "ds-teaser--text-on-image",
12
+ params.classNames if params.classNames
13
+ ] | join(" ") %}
14
+
15
+ {% call TeaserCard({
16
+ targetLink: params.targetLink,
17
+ areaType: params.areaType,
18
+ theme: params.theme,
19
+ attributes: params.attributes,
20
+ classNames: extraClasses
21
+ }) %}
22
+ <div class="{{ componentClassName + '__content'}}">
23
+ {% if params.mediaHtml %}
24
+ <div class="{{ componentClassName + '__media' }}">
25
+ {{ params.mediaHtml }}
26
+ </div>
27
+ {% endif %}
28
+
29
+ <div class="{{ componentClassName + '__text-content'}}">
30
+ <h2 class="{{ componentClassName + '__title'}} {{ componentClassName + '__title--italic' if params.isItalicHeadline}}">
31
+ {{ params.title }}
32
+ </h2>
33
+
34
+ {% if params.text%}
35
+ <p class="{{ componentClassName + '__text' }}">
36
+ {{ params.text }}
37
+ </p>
38
+ {% endif %}
39
+ </div>
40
+ </div>
41
+ {% endcall %}
42
+ {% endmacro %}
@@ -0,0 +1,66 @@
1
+ @use "../../foundations/helpers/forward.helpers.scss" as *;
2
+ @use "../../assets/teaser/teaser.scss" as *;
3
+
4
+ .ds-teaser.ds-teaser--text-on-image {
5
+ overflow: hidden;
6
+
7
+ .ds-teaser__vignette {
8
+ margin-top: ds-spacing($ds-s-025);
9
+ }
10
+
11
+ .ds-teaser__title,
12
+ .ds-teaser__text {
13
+ position: relative;
14
+ color: $ds-color-surface-primary;
15
+ margin-top: ds-spacing($ds-s-100);
16
+ }
17
+
18
+ .ds-teaser__title {
19
+ @include ds-typography($ds-typography-detail-teaser-text-i-bild, $forcePx: true);
20
+
21
+ &--italic {
22
+ @include ds-typography($ds-typography-detail-medryckare);
23
+ }
24
+ }
25
+ .ds-teaser__content {
26
+ position: relative;
27
+
28
+ &:after {
29
+ content: "";
30
+ position: absolute;
31
+ top: 0;
32
+ left: 0;
33
+ width: 100%;
34
+ height: 100%;
35
+ background: linear-gradient(var(--ds-color-gradients-overlay-end), var(--ds-color-gradients-overlay-start));
36
+ z-index: 2;
37
+ }
38
+ }
39
+
40
+ .ds-teaser-image__byline,
41
+ .ds-teaser__text-content {
42
+ z-index: 3;
43
+ }
44
+
45
+ .ds-teaser__text-content {
46
+ position: absolute;
47
+ bottom: ds-spacing($ds-s-100);
48
+ left: ds-spacing($ds-s-100);
49
+ max-width: 90%;
50
+
51
+ @include ds-mq-only-breakpoint(desktop) {
52
+ max-width: 75%;
53
+ }
54
+ }
55
+
56
+ .ds-teaser__media {
57
+ .picture {
58
+ width: 100%;
59
+ height: 100%;
60
+ }
61
+
62
+ .ds-teaser-image__byline {
63
+ @include ds-typography($ds-typography-functional-meta-sm, $forcePx: true, $lineHeight: $ds-lineheight-lg);
64
+ }
65
+ }
66
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonniernews/dn-design-system-web",
3
- "version": "31.0.0",
3
+ "version": "31.0.1-beta.2",
4
4
  "description": "DN design system for web.",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/BonnierNews/dn-design-system/tree/main/web/src#readme",