@bonniernews/dn-design-system-web 20.1.1 → 20.3.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
@@ -4,6 +4,31 @@ All changes to @bonniernews/dn-design-system-web will be documented in this file
4
4
 
5
5
 
6
6
 
7
+ ## [20.3.0](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@20.2.0...@bonniernews/dn-design-system-web@20.3.0) (2024-09-12)
8
+
9
+
10
+ ### Features
11
+
12
+ * **web:** add articlecount to tagheader and profileheader ([#1395](https://github.com/BonnierNews/dn-design-system/issues/1395)) ([90eba4a](https://github.com/BonnierNews/dn-design-system/commit/90eba4a4e132c0748bf126d5e0f6bc1f733d4e76))
13
+
14
+
15
+ ### Maintenance
16
+
17
+ * **deps:** bump express from 4.19.2 to 4.20.0 in /web ([#1398](https://github.com/BonnierNews/dn-design-system/issues/1398)) ([67314ce](https://github.com/BonnierNews/dn-design-system/commit/67314ce6e2983cc8752650c95e2d199c1522ce67))
18
+
19
+ ## [20.2.0](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@20.1.1...@bonniernews/dn-design-system-web@20.2.0) (2024-09-12)
20
+
21
+
22
+ ### Features
23
+
24
+ * **web:** pagination component ([#1397](https://github.com/BonnierNews/dn-design-system/issues/1397)) ([42ee258](https://github.com/BonnierNews/dn-design-system/commit/42ee2581cc56184d96940a793a1eebea5fe51087))
25
+
26
+
27
+ ### Maintenance
28
+
29
+ * bump node to 20.x in gh actions ([#1394](https://github.com/BonnierNews/dn-design-system/issues/1394)) ([d83371e](https://github.com/BonnierNews/dn-design-system/commit/d83371e0aa82fe8962d996ba5dc718f41f6d1ad1))
30
+ * prerelease packages ([3bc50c6](https://github.com/BonnierNews/dn-design-system/commit/3bc50c66efc6e4279d3f07ebfeff63bd26a1ad69))
31
+
7
32
  ## [20.1.1](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@20.1.0...@bonniernews/dn-design-system-web@20.1.1) (2024-09-09)
8
33
 
9
34
 
@@ -14,6 +14,7 @@
14
14
  |disabled | bool | no | true, false | false | Note: only works on button-tag, not on a-tag |
15
15
  |variant | String | no | primary, secondary, brand, staticWhite | primary | Design variant |
16
16
  |emphasis | String | no | default, elevated, outline, transparent | default | |
17
+ |rounded | bool | no | true, false | true | Button will be rounded to the max |
17
18
  |size| String | no | small, medium, large, xlarge | medium | |
18
19
  |loading | bool | no | true, false | false | |
19
20
  |a11y.visuallyHidden | Object | no | | | Ex. a11y: { visuallyHidden: "Dela på TikTok" } |
@@ -7,6 +7,7 @@
7
7
  variant: params.variant,
8
8
  href: params.href,
9
9
  emphasis: params.emphasis,
10
+ rounded: false if params.rounded === false else true,
10
11
  disabled: params.disabled,
11
12
  size: params.size,
12
13
  iconName: params.iconName,
@@ -2,8 +2,6 @@
2
2
  @use "../button/button.scss" as *;
3
3
 
4
4
  .ds-btn.ds-btn--icon-only {
5
- border-radius: 50%;
6
-
7
5
  &.ds-btn--small {
8
6
  padding: ds-px-to-rem(ds-spacing($ds-s-025) - $ds-btn-outlined__border-width);
9
7
  @at-root .ds-force-px#{&} {
File without changes
@@ -0,0 +1,55 @@
1
+ - GitHub: [BonnierNews/dn-design-system/../web/src/components/pagination](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/pagination)
2
+ - Storybook: [Pagination](https://designsystem.dn.se/?path=/docs/basic-pagination--docs)
3
+ - Storybook (Latest): [Pagination](https://designsystem-latest.dn.se/?path=/docs/basic-pagination--docs)
4
+
5
+ ----
6
+
7
+ # Pagination
8
+
9
+ ## Parameters
10
+
11
+ |parameter | type | required | options | default | description |
12
+ |:--- | :--- | :--- | :--- | :--- | :--- |
13
+ |pages | Array | no | | | Array with link objects. Ex. [ { label: '8' , url: 'https://www.dn.se/om/danmark/?offset=40', current: true, attributes: {} } ] |
14
+ |previousLabel | String | no | 'Föregående' | | Previous button/link label |
15
+ |previousUrl | String | no | | | |
16
+ |previousAttributes | Object | no | | | |
17
+ |previousClassNames | String | no | | | |
18
+ |nextLabel | String | no | 'Nästa' | | Next button/link label |
19
+ |nextUrl | String | no | | | |
20
+ |nextAttributes | Object | no | | | |
21
+ |nextClassNames | String | no | | | |
22
+ |attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
23
+ |classNames | String | no | | | Ex. "my-special-class" |
24
+ |~forcePx~ | | | | | Not supported |
25
+
26
+ ## Minimum requirement example
27
+
28
+ ### Nunjucks
29
+
30
+ These are copy paste friendly examples to quickliy get started using a component.
31
+
32
+ ```html
33
+ {% from '@bonniernews/dn-design-system-web/components/pagination/pagination.njk' import Pagination %}
34
+
35
+ {{ Pagination({
36
+ nextUrl: 'https://www.dn.se/om/danmark/?offset=48',
37
+ nextLabel: undefined,
38
+ previousUrl: 'https://www.dn.se/om/danmark/?offset=0',
39
+ previousLabel: undefined,
40
+ pages: [
41
+ { label: '6' , url: 'https://www.dn.se/om/danmark/?offset=24', attributes: {} },
42
+ { label: '7' , url: 'https://www.dn.se/om/danmark/?offset=32' },
43
+ { label: '8' , url: 'https://www.dn.se/om/danmark/?offset=40', current: true },
44
+ { label: '9' , url: 'https://www.dn.se/om/danmark/?offset=48' },
45
+ { label: '10' , url: 'https://www.dn.se/om/danmark/?offset=56' },
46
+ ],
47
+ attributes: {},
48
+ classNames: undefined,
49
+ })}}
50
+ ```
51
+
52
+ ### SCSS
53
+ ```scss
54
+ @use "@bonniernews/dn-design-system-web/components/pagination/pagination" as *;
55
+ ```
@@ -0,0 +1,60 @@
1
+ {% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
2
+ {% from '@bonniernews/dn-design-system-web/components/text-button/text-button.njk' import TextButton %}
3
+ {% from '@bonniernews/dn-design-system-web/components/icon-button/icon-button.njk' import IconButton %}
4
+
5
+ {% macro Pagination(params) %}
6
+ {%- set componentClassName = "ds-pagination" %}
7
+ {%- set classNamePrefix = componentClassName + "--" %}
8
+ {%- set classes = [
9
+ componentClassName,
10
+ componentClassName + "--simple " if not params.pages,
11
+ params.classNames if params.classNames
12
+ ] | join(" ") %}
13
+ {%- set attributes = getAttributes(params.attributes) %}
14
+ {%- set visiblePages = 5 %}
15
+ <div class="{{ classes }}" {{- attributes | safe }}>
16
+ {%- set prevClasses = [
17
+ componentClassName + "__prev ",
18
+ params.previousClassNames if params.previousClassNames
19
+ ] | join(" ") %}
20
+ {{ TextButton({
21
+ text: params.previousLabel if params.previousLabel else 'Föregående',
22
+ size: 'large',
23
+ hideTextOnMobile: true if params.pages,
24
+ iconPosition: 'left',
25
+ iconName: 'arrow_back',
26
+ classNames: prevClasses,
27
+ attributes: params.previousAttributes,
28
+ href: params.previousUrl,
29
+ disabled: true if not params.previousUrl else false
30
+ })}}
31
+ {% if params.pages %}
32
+ <div class="{{ componentClassName }}__pages">
33
+ {% for page in params.pages %}
34
+ {%- set pageAttributes = getAttributes(page.attributes) %}
35
+ {%- set pageClass = componentClassName + "__page" %}
36
+ {% if page.current %}
37
+ <span class="{{ pageClass }} {{ pageClass }}--current" {{- pageAttributes | safe }}>{{ page.label }}</span>
38
+ {% else %}
39
+ <a href="{{ page.url }}" class="{{ pageClass }}" {{- pageAttributes | safe }}>{{ page.label }}</a>
40
+ {% endif %}
41
+ {% endfor %}
42
+ </div>
43
+ {% endif %}
44
+ {%- set nextClasses = [
45
+ componentClassName + "__next ",
46
+ params.nextClassNames if params.nextClassNames
47
+ ] | join(" ") %}
48
+ {{ TextButton({
49
+ text: params.nextLabel if params.nextLabel else 'Nästa',
50
+ size: 'large',
51
+ hideTextOnMobile: true if params.pages,
52
+ iconPosition: 'right',
53
+ iconName: 'arrow_forward',
54
+ classNames: nextClasses,
55
+ attributes: params.nextAttributes,
56
+ href: params.nextUrl,
57
+ disabled: true if not params.nextUrl else false
58
+ })}}
59
+ </div>
60
+ {% endmacro %}
@@ -0,0 +1,47 @@
1
+ @use "../../foundations/helpers/forward.helpers.scss" as *;
2
+ @use "../../components/text-button/text-button";
3
+
4
+ .ds-pagination {
5
+ background-color: $ds-color-surface-background;
6
+ display: flex;
7
+ justify-content: center;
8
+ flex-wrap: wrap;
9
+ width: 100%;
10
+ padding: ds-spacing($ds-s-050 $ds-s-100);
11
+
12
+ &--simple {
13
+ padding: ds-spacing($ds-s-100);
14
+ }
15
+
16
+ &__pages {
17
+ display: flex;
18
+ }
19
+ &__page {
20
+ @include ds-typography($ds-typography-functionalbody02);
21
+ color: $ds-color-text-primary;
22
+ margin: ds-spacing($ds-s-050);
23
+ min-height: ds-px-to-rem(32);
24
+ min-width: ds-px-to-rem(32);
25
+ display: flex;
26
+ align-items: center;
27
+ justify-content: center;
28
+
29
+ &--current {
30
+ color: $ds-color-text-secondary;
31
+ background-color: $ds-color-component-primary;
32
+ border-radius: 100%;
33
+ }
34
+
35
+ &:not(.ds-pagination__page--current) {
36
+ @include ds-link($ds-link-list);
37
+ }
38
+ }
39
+
40
+ .ds-pagination__prev {
41
+ margin-right: auto;
42
+ }
43
+
44
+ .ds-pagination__next {
45
+ margin-left: auto;
46
+ }
47
+ }
@@ -13,6 +13,7 @@
13
13
  |title | String | yes | | | H1 Title |
14
14
  |mediaHtml | String | no | | | Main image |
15
15
  |descriptionHtml | String | no | | | Intended use is text, links |
16
+ |articleCount | int | no | | | Total articles on this list-page |
16
17
  |toggle | Bool | no | true, false | false | Show/hide toggle button |
17
18
  |toggleText | text | no | | | `text` parameter to ToggleButton (only if `toggle` is enabled) |
18
19
  |toggleSelectedText | text | no | | | `selectedText` parameter to ToggleButton (only if `toggle` is enabled) |
@@ -39,6 +39,9 @@
39
39
  {{ params.descriptionHtml | safe }}
40
40
  </div>
41
41
  {% endif %}
42
+ {% if params.articleCount %}
43
+ <p class="{{ componentClassName }}__article-count">{{ params.articleCount }} {% if params.articleCount === 1 %}artikel{% else %}artiklar{% endif %}</p>
44
+ {% endif %}
42
45
  </div>
43
46
  </div>
44
47
  {% endmacro %}
@@ -4,7 +4,7 @@
4
4
  .ds-profile-header {
5
5
  width: 100%;
6
6
  background-color: $ds-color-surface-background;
7
- padding: 0;
7
+ padding-bottom: ds-spacing($ds-s-100);
8
8
  display: flex;
9
9
 
10
10
  .ds-profile-header__content {
@@ -43,12 +43,18 @@
43
43
  margin: 0;
44
44
  }
45
45
 
46
+ .ds-profile-header__article-count {
47
+ margin: ds-spacing($ds-s-050 $ds-s-100 0);
48
+ @include ds-typography($ds-typography-functionalbody02);
49
+ color: $ds-color-text-primary-02;
50
+ }
51
+
46
52
  .ds-profile-header__description {
47
53
  @include ds-typography($ds-typography-functionalbody02);
48
54
  color: $ds-color-text-primary;
49
55
  margin: ds-spacing(0 $ds-s-100 0);
50
56
  border-top: ds-border-width(x1) solid $ds-color-border-primary;
51
- padding: ds-spacing($ds-s-100 0);
57
+ padding: ds-spacing($ds-s-100 0 0 0);
52
58
 
53
59
  a {
54
60
  @include ds-link($ds-link-article-body);
@@ -15,6 +15,7 @@
15
15
  |vignetteTargetUrl | String | no | | | Target URL for the vignette |
16
16
  |mediaHtml | String | no | | | Main image |
17
17
  |descriptionHtml | String | no | | | Intended use is text, links |
18
+ |articleCount | int | no | | | Total articles on this list-page |
18
19
  |theme | String | no | nyheter, kultur, ekonomi, sport, sthlm | (empty) | The theme-class to apply to the vignette |
19
20
  |toggle | Bool | no | true, false | false | Show/hide toggle button |
20
21
  |toggleText | text | no | | | `text` parameter to ToggleButton (only if `toggle` is enabled) |
@@ -47,6 +47,9 @@
47
47
  {{ params.descriptionHtml | safe }}
48
48
  </div>
49
49
  {% endif %}
50
+ {% if params.articleCount %}
51
+ <p class="{{ componentClassName }}__article-count">{{ params.articleCount }} {% if params.articleCount === 1 %}artikel{% else %}artiklar{% endif %}</p>
52
+ {% endif %}
50
53
  </div>
51
54
  </div>
52
55
  {% endmacro %}
@@ -70,6 +70,12 @@
70
70
  }
71
71
  }
72
72
 
73
+ .ds-tag-header__article-count {
74
+ margin: ds-spacing($ds-s-050 $ds-s-100 0);
75
+ @include ds-typography($ds-typography-functionalbody02);
76
+ color: $ds-color-text-primary-02;
77
+ }
78
+
73
79
  .ds-tag-header__description {
74
80
  @include ds-typography($ds-typography-functionalbody02);
75
81
  color: $ds-color-text-primary;
@@ -11,6 +11,7 @@
11
11
  |parameter | type | required | options | default | description |
12
12
  |:--- | :--- | :--- | :--- | :--- | :--- |
13
13
  |text | String | yes | | | |
14
+ |hideTextOnMobile | bool | no | true, false | false | Text will be hidden on mobile, make sure to use with icon |
14
15
  |size| String | no | default, small | default | |
15
16
  |disabled | bool | no | true, false | false | Note: only works on button-tag, not on a-tag |
16
17
  |fullWidth | bool | no | true, false | false | Button will be full width on both desktop and mobile |
@@ -18,6 +18,7 @@
18
18
  classNamePrefix + "full-width" if params.fullWidth,
19
19
  classNamePrefix + "mobile-full-width" if params.mobile and params.mobile.fullwWidth,
20
20
  classNamePrefix + "icon-" + params.iconPosition if iconSvg,
21
+ classNamePrefix + "icon-only-mobile" if params.hideTextOnMobile,
21
22
  params.classNames if params.classNames
22
23
  ] | join(" ") %}
23
24
  {%- set text = params.text %}
@@ -35,6 +35,18 @@ $ds-text-btn__underline-offset: 2px;
35
35
  }
36
36
  }
37
37
 
38
+ &.ds-text-btn--icon-only-mobile {
39
+ &.ds-text-btn--icon-left,
40
+ &.ds-text-btn--icon-right {
41
+ @include ds-mq-only-breakpoint(mobile) {
42
+ --ds-text-btn__icon-margin: 0;
43
+ .ds-text-btn__text {
44
+ display: none;
45
+ }
46
+ }
47
+ }
48
+ }
49
+
38
50
  cursor: pointer;
39
51
  background-color: transparent;
40
52
  border: 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonniernews/dn-design-system-web",
3
- "version": "20.1.1",
3
+ "version": "20.3.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",