@bonniernews/dn-design-system-web 4.8.2 → 4.8.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 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
+ ## 4.8.3 (2023-09-21)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **web:** styling fix on teaser list timeline ([#1001](https://github.com/BonnierNews/dn-design-system/issues/1001)) ([33b5520](https://github.com/BonnierNews/dn-design-system/commit/33b5520cb235c545c070472f96fc84843facb121))
12
+
13
+
14
+
6
15
  ## 4.8.2 (2023-09-21)
7
16
 
8
17
 
@@ -14,6 +14,7 @@
14
14
  |variant | string | no | icon, link, toggle, arrows | icon | The variant to render |
15
15
  |href | string | no | | | If given, the title is rendered as a link |
16
16
  |linkText | string | no | | | The link text to render (only for variant `link`) |
17
+ |showBottomBorder | boolean | no | | | If true there will be a bottom border |
17
18
  |toggleText | text | no | | | `text` parameter to ToggleButton (only for variant `toggle`) |
18
19
  |toggleSelectedText | text | no | | | `selectedText` parameter to ToggleButton (only for variant `toggle`) |
19
20
  |toggleSelected | boolean | no | | | `selected` parameter to ToggleButton (only for variant `toggle`) |
@@ -11,10 +11,11 @@
11
11
  {%- set classes = [
12
12
  componentClassName,
13
13
  classNamePrefix + (params.variant or "icon"),
14
+ classNamePrefix + 'bottom-border' if params.showBottomBorder,
14
15
  params.classNames if params.classNames
15
16
  ] | join(" ") %}
16
17
 
17
- {%- set groupHeaderInner %}
18
+ {% set groupHeaderInner %}
18
19
  <h2 class="{{ componentClassName + '__title'}}">{{ params.title}}</h2>
19
20
 
20
21
  {% if params.variant == 'link' and params.linkText and params.href %}
@@ -10,6 +10,10 @@
10
10
  color: $ds-color-text-primary;
11
11
  @include ds-typography($ds-typography-functional-body02regular);
12
12
 
13
+ &--bottom-border {
14
+ border-bottom: ds-metrics-border-width(x1) solid $ds-color-border-primary;
15
+ }
16
+
13
17
  .ds-group-header__right-link,
14
18
  .ds-group-header__icon,
15
19
  .ds-btn-toggle {
@@ -60,4 +64,8 @@
60
64
  @include ds-typography($ds-typography-functional-body02bold);
61
65
  margin: 0;
62
66
  }
67
+
68
+ &--bottom-border .ds-group-header__title {
69
+ padding-bottom: ds-spacing-component($ds-sc-x3) - ds-metrics-border-width(x1);
70
+ }
63
71
  }
@@ -1,10 +1,10 @@
1
- - GitHub: [BonnierNews/dn-design-system/../web/src/components/teaser-list-timeline](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/teaser-list-timeline)
2
- - Storybook: [TeaserListTimeline](https://designsystem.dn.se/?path=/docs/section-teaserlisttimeline--docs)
3
- - Storybook (Latest): [TeaserListTimeline](https://designsystem-latest.dn.se/?path=/docs/section-teaserlisttimeline--docs)
1
+ - GitHub: [BonnierNews/dn-design-system/../web/src/components/teaser-list-vertical](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/teaser-list-vertical)
2
+ - Storybook: [TeaserListVertical](https://designsystem.dn.se/?path=/docs/section-teaserlistvertical--docs)
3
+ - Storybook (Latest): [TeaserListVertical](https://designsystem-latest.dn.se/?path=/docs/section-teaserlistvertical--docs)
4
4
 
5
5
  ----
6
6
 
7
- # teaser-list-timeline
7
+ # teaser-list-vertical
8
8
 
9
9
  ## Parameters
10
10
 
@@ -27,9 +27,9 @@
27
27
  These are copy paste friendly examples to quickliy get started using a component.
28
28
 
29
29
  ```html
30
- {% from '@bonniernews/dn-design-system-web/components/teaser-list-timeline/teaser-list-timeline.njk' import TeaserListTimeline %}
30
+ {% from '@bonniernews/dn-design-system-web/components/teaser-list-vertical/teaser-list-vertical.njk' import TeaserListVertical %}
31
31
 
32
- {{ TeaserListTimeline({
32
+ {{ TeaserListVertical({
33
33
  listTitle: "Senaste nytt",
34
34
  listLink: { text: "Alla nyheter", url: "#"},
35
35
  flexible: true,
@@ -40,5 +40,13 @@ These are copy paste friendly examples to quickliy get started using a component
40
40
 
41
41
  ### SCSS
42
42
  ```scss
43
- @use "@bonniernews/dn-design-system-web/components/teaser-list-timeline/teaser-list-timeline" as *;
43
+ @use "@bonniernews/dn-design-system-web/components/teaser-list-vertical/teaser-list-vertical" as *;
44
+ ```
45
+ ### Javascript
46
+
47
+ Only run this if there is a scrollable list
48
+ ```javascript
49
+ import { dsTeaserListVertical } from '@bonniernews/dn-design-system-web/components/teaser-list-vertical/teaser-list-vertical.js'
50
+ const teaserListVerticalWrappers = Array.from(document.getElementsByClassName("ds-teaser-list-vertical--flexible"));
51
+ dsTeaserListVertical(teaserListVerticalWrappers);
44
52
  ```
@@ -0,0 +1,22 @@
1
+ export {
2
+ dsTeaserListVertical,
3
+ dsTeaserListVerticalStory
4
+ }
5
+
6
+ function dsTeaserListVertical(teaserListVerticalWrappers = []) {
7
+ teaserListVerticalWrappers.forEach((wrapper) => {
8
+ const teaserListGroupHeader = wrapper.querySelector(".ds-group-header--bottom-border");
9
+ teaserListGroupHeader?.classList.remove("ds-group-header--bottom-border");
10
+
11
+ const teaserListVerticalContentContainer = wrapper.querySelector(".ds-teaser-list-vertical__content");
12
+ teaserListVerticalContentContainer.addEventListener("scroll", () => {
13
+ const scrolledToTop = teaserListVerticalContentContainer.scrollTop === 0;
14
+ teaserListGroupHeader.classList.toggle("ds-group-header--bottom-border", !scrolledToTop);
15
+ });
16
+ });
17
+ }
18
+
19
+ function dsTeaserListVerticalStory() {
20
+ const teaserListVerticalWrappers = Array.from(document.getElementsByClassName("ds-teaser-list-vertical--flexible"));
21
+ dsTeaserListVertical(teaserListVerticalWrappers);
22
+ }
@@ -1,11 +1,14 @@
1
1
  {% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
2
2
  {% from '@bonniernews/dn-design-system-web/components/button/button.njk' import Button %}
3
+ {% from '@bonniernews/dn-design-system-web/components/group-header/group-header.njk' import GroupHeader %}
4
+ {% from '@bonniernews/dn-design-system-web/components/teaser-dot/teaser-dot.njk' import TeaserDot %}
3
5
 
4
- {% macro TeaserListTimeline(params) %}
5
- {% set componentClassName = "ds-teaser-list-timeline" %}
6
+ {% macro TeaserListVertical(params) %}
7
+ {% set componentClassName = "ds-teaser-list-vertical" %}
6
8
  {% set classNamePrefix = componentClassName + "--" %}
7
9
  {% set attributes = getAttributes(params.attributes) %}
8
10
  {% set showButton = params.listLink and params.listLink.text and params.listLink.url %}
11
+
9
12
  {%- set classes = [
10
13
  componentClassName,
11
14
  "ds-theme--" + params.theme,
@@ -13,15 +16,20 @@
13
16
  classNamePrefix + "linked" if showButton,
14
17
  params.classNames if params.classNames
15
18
  ] | join(" ") %}
19
+
16
20
  <div class="{{ classes }}" {{- attributes | safe }}>
17
- <h2 class="ds-teaser-list-timeline__vignette">{{ params.listTitle }}</h2>
21
+ {{ GroupHeader({
22
+ title: params.listTitle,
23
+ showBottomBorder: params.flexible
24
+ }) }}
25
+
18
26
  <div class="{{ componentClassName + '__content'}}">
19
27
  {% for teaser in params.teasers %}
20
- {{ TeaserListTimelineItem(teaser) }}
28
+ {{ TeaserListVerticalItem(teaser) }}
21
29
  {% endfor %}
22
30
  </div>
23
31
  {% if showButton %}
24
- <div class="ds-teaser-list-timeline__link">
32
+ <div class="ds-teaser-list-vertical__link">
25
33
  {{ Button({
26
34
  text: params.listLink.text,
27
35
  href: params.listLink.url,
@@ -36,18 +44,18 @@
36
44
  </div>
37
45
  {% endmacro %}
38
46
 
39
- {% macro TeaserListTimelineItem(teaser) %}
47
+ {% macro TeaserListVerticalItem(teaser) %}
40
48
  {% set attributes = getAttributes(teaser.attributes) %}
41
49
  {%- set classes = [
42
- "ds-teaser-list-timeline__item",
50
+ "ds-teaser-list-vertical__item",
43
51
  teaser.classNames if teaser.classNames
44
52
  ] | join(" ") %}
45
53
  <a href="{{teaser.targetLink}}" class="{{ classes }}" {{- attributes | safe }}>
46
- <span class="ds-teaser-list-timeline__item-dot"></span>
47
- <h3 class="ds-teaser-list-timeline__item-title">{{ teaser.highlight }} {{ teaser.title }}</h3>
54
+ {{ TeaserDot() }}
55
+ <h3 class="ds-teaser-list-vertical__item-title">{{ teaser.highlight }} {{ teaser.title }}</h3>
48
56
  {% if teaser.publicationTime or teaser.sectionName %}
49
- <div class="ds-teaser-list-timeline__item-notes">
50
- <span>{{ teaser.publicationTime }}<span>{{ " • " if teaser.publicationTime and teaser.sectionName }}<span>{{ teaser.sectionName }}</span>
57
+ <div class="ds-teaser-list-vertical__item-notes">
58
+ <span>{{ teaser.publicationTime }}</span>{{ " • " if teaser.publicationTime and teaser.sectionName }}<span>{{ teaser.sectionName }}</span>
51
59
  </div>
52
60
  {% endif %}
53
61
  </a>
@@ -0,0 +1,78 @@
1
+ @use "../../foundations/helpers/forward.helpers.scss" as *;
2
+ @use "../button/button.scss" as *;
3
+ @use "../../components/group-header/group-header";
4
+ @use "../../components/teaser-dot/teaser-dot.scss";
5
+
6
+ $ds-dot-size: ds-px-to-rem(10px);
7
+
8
+ .ds-teaser-list-vertical {
9
+ background-color: $ds-color-surface-background;
10
+
11
+ .ds-teaser-list-vertical__link {
12
+ position: relative;
13
+ padding: ds-spacing-component($ds-sc-x4, rem);
14
+
15
+ &::before {
16
+ content: "";
17
+ position: absolute;
18
+ top: 0;
19
+ left: 0;
20
+ right: 0;
21
+ height: ds-metrics-border-width(x1);
22
+ background-color: $ds-color-border-primary;
23
+ }
24
+ }
25
+
26
+ .ds-teaser-list-vertical__item {
27
+ padding: ds-spacing-component($ds-sc-x3 $ds-sc-x4, rem);
28
+ display: block;
29
+ text-decoration: none;
30
+ position: relative;
31
+
32
+ &:not(:last-child)::after {
33
+ content: "";
34
+ position: absolute;
35
+ bottom: 0;
36
+ height: ds-metrics-border-width(x1);
37
+ width: calc(100% - ds-spacing-component($ds-sc-x8));
38
+ background-color: $ds-color-border-primary;
39
+ }
40
+
41
+ .ds-teaser-dot {
42
+ position: absolute;
43
+ margin-top: ds-px-to-rem(6px);
44
+ }
45
+
46
+ .ds-teaser-list-vertical__item-title,
47
+ .ds-teaser-list-vertical__item-notes {
48
+ margin: 0 0 0 (ds-spacing-component($ds-sc-x2, rem) + $ds-dot-size);
49
+ }
50
+
51
+ .ds-teaser-list-vertical__item-title {
52
+ @include ds-typography($ds-typography-expressive-heading01bold);
53
+ color: $ds-color-text-primary;
54
+ word-break: break-word;
55
+
56
+ @include ds-hover(true) {
57
+ @include ds-underline(2px, 1px);
58
+ }
59
+ }
60
+
61
+ .ds-teaser-list-vertical__item-notes {
62
+ @include ds-typography($ds-typography-functional-meta02regular);
63
+ color: $ds-color-text-primary-02;
64
+ margin-top: ds-spacing-component($ds-sc-x2, rem);
65
+ }
66
+ }
67
+
68
+ &.ds-teaser-list-vertical--flexible {
69
+ display: flex;
70
+ flex: 1 0 300px;
71
+ flex-direction: column;
72
+ overflow: hidden;
73
+
74
+ .ds-teaser-list-vertical__content {
75
+ overflow-y: auto;
76
+ }
77
+ }
78
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonniernews/dn-design-system-web",
3
- "version": "4.8.2",
3
+ "version": "4.8.3",
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",
@@ -1,80 +0,0 @@
1
- @use "../../foundations/helpers/forward.helpers.scss" as *;
2
- @use "../button/button.scss" as *;
3
-
4
- $ds-teaser-list-timeline-dot-size: ds-px-to-rem(10px);
5
-
6
- .ds-teaser-list-timeline {
7
- background-color: $ds-color-surface-background;
8
-
9
- .ds-teaser-list-timeline__vignette {
10
- @include ds-typography($ds-typography-functional-body02bold);
11
- color: $ds-color-text-primary;
12
- padding: ds-spacing-component($ds-sc-x3 $ds-sc-x4, rem);
13
- margin: 0;
14
- }
15
-
16
- .ds-teaser-list-timeline__link {
17
- border-top: ds-metrics-border-width(x1) solid $ds-color-border-primary;
18
- padding: ds-spacing-component($ds-sc-x4, rem);
19
- }
20
-
21
- .ds-teaser-list-timeline__item {
22
- padding: ds-spacing-component($ds-sc-x3 $ds-sc-x4, rem);
23
- display: block;
24
- text-decoration: none;
25
- border-bottom: ds-metrics-border-width(x1) solid $ds-color-border-primary;
26
- position: relative;
27
-
28
- &:last-child {
29
- border: none;
30
- }
31
-
32
- .ds-teaser-list-timeline__item-dot {
33
- position: absolute;
34
-
35
- &::before {
36
- content: "";
37
- position: absolute;
38
- top: ds-px-to-rem(6px);
39
- display: inline-flex;
40
- box-sizing: border-box;
41
- background-color: $ds-theme-color;
42
- border-radius: 50%;
43
- height: $ds-teaser-list-timeline-dot-size;
44
- width: $ds-teaser-list-timeline-dot-size;
45
- }
46
- }
47
-
48
- .ds-teaser-list-timeline__item-title,
49
- .ds-teaser-list-timeline__item-notes {
50
- margin: 0 0 0 (ds-spacing-component($ds-sc-x2, rem) + $ds-teaser-list-timeline-dot-size);
51
- }
52
-
53
- .ds-teaser-list-timeline__item-title {
54
- @include ds-typography($ds-typography-expressive-heading01bold);
55
- color: $ds-color-text-primary;
56
- word-break: break-word;
57
-
58
- @include ds-hover(true) {
59
- @include ds-underline(2px, 1px);
60
- }
61
- }
62
-
63
- .ds-teaser-list-timeline__item-notes {
64
- @include ds-typography($ds-typography-functional-meta02regular);
65
- color: $ds-color-text-primary-02;
66
- margin-top: ds-spacing-component($ds-sc-x2, rem);
67
- }
68
- }
69
-
70
- &.ds-teaser-list-timeline--flexible {
71
- display: flex;
72
- flex: 1 0 300px;
73
- flex-direction: column;
74
- overflow: hidden;
75
-
76
- .ds-teaser-list-timeline__content {
77
- overflow-y: auto;
78
- }
79
- }
80
- }