@bonniernews/dn-design-system-web 20.1.1 → 20.2.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 +13 -0
- package/components/icon-button/README.md +1 -0
- package/components/icon-button/icon-button.njk +1 -0
- package/components/icon-button/icon-button.scss +0 -2
- package/components/pagination/README-UXD.md +0 -0
- package/components/pagination/README.md +55 -0
- package/components/pagination/pagination.njk +60 -0
- package/components/pagination/pagination.scss +47 -0
- package/components/text-button/README.md +1 -0
- package/components/text-button/text-button.njk +1 -0
- package/components/text-button/text-button.scss +12 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,19 @@ All changes to @bonniernews/dn-design-system-web will be documented in this file
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
## [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)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* **web:** pagination component ([#1397](https://github.com/BonnierNews/dn-design-system/issues/1397)) ([42ee258](https://github.com/BonnierNews/dn-design-system/commit/42ee2581cc56184d96940a793a1eebea5fe51087))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Maintenance
|
|
16
|
+
|
|
17
|
+
* 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))
|
|
18
|
+
* prerelease packages ([3bc50c6](https://github.com/BonnierNews/dn-design-system/commit/3bc50c66efc6e4279d3f07ebfeff63bd26a1ad69))
|
|
19
|
+
|
|
7
20
|
## [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
21
|
|
|
9
22
|
|
|
@@ -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" } |
|
|
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
|
+
}
|
|
@@ -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