@bonniernews/dn-design-system-web 22.1.0 → 22.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.
Files changed (39) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/components/button/README-NJK.md +53 -0
  3. package/components/button/README.md +36 -53
  4. package/components/button/button-types.ts +87 -0
  5. package/components/button-toggle/README-NJK.md +56 -0
  6. package/components/button-toggle/README.md +31 -48
  7. package/components/divider/README.md +9 -1
  8. package/components/footer/README.md +190 -179
  9. package/components/game-header/README.md +17 -7
  10. package/components/icon-button/README-NJK.md +47 -0
  11. package/components/icon-button/README.md +31 -47
  12. package/components/icon-button-toggle/README-NJK.md +53 -0
  13. package/components/icon-button-toggle/README.md +30 -45
  14. package/components/quote/README.md +10 -2
  15. package/components/spinner/README.md +13 -5
  16. package/components/teaser-card/README.md +16 -8
  17. package/components/teaser-onsite/README.md +19 -1
  18. package/components/thematic-break/README.md +7 -2
  19. package/package.json +1 -1
  20. package/preact/components/button/button-base.d.ts +5 -0
  21. package/preact/components/button/button-base.js +161 -0
  22. package/preact/components/button/button-base.js.map +7 -0
  23. package/preact/components/button/button-types.d.ts +73 -0
  24. package/preact/components/button/button.d.ts +10 -0
  25. package/preact/components/button/button.js +201 -0
  26. package/preact/components/button/button.js.map +7 -0
  27. package/preact/components/button-toggle/button-toggle.d.ts +19 -0
  28. package/preact/components/button-toggle/button-toggle.js +201 -0
  29. package/preact/components/button-toggle/button-toggle.js.map +7 -0
  30. package/preact/components/icon-button/icon-button.d.ts +10 -0
  31. package/preact/components/icon-button/icon-button.js +197 -0
  32. package/preact/components/icon-button/icon-button.js.map +7 -0
  33. package/preact/components/icon-button-toggle/icon-button-toggle.d.ts +18 -0
  34. package/preact/components/icon-button-toggle/icon-button-toggle.js +199 -0
  35. package/preact/components/icon-button-toggle/icon-button-toggle.js.map +7 -0
  36. package/preact/components/spinner/spinner.d.ts +2 -2
  37. package/preact/components/spinner/spinner.js.map +1 -1
  38. package/preact/foundations/a11y/visually-hidden.d.ts +4 -0
  39. package/tsconfig.json +3 -0
package/CHANGELOG.md CHANGED
@@ -4,6 +4,20 @@ All changes to @bonniernews/dn-design-system-web will be documented in this file
4
4
 
5
5
 
6
6
 
7
+ ## [22.2.0](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@22.1.1...@bonniernews/dn-design-system-web@22.2.0) (2024-12-18)
8
+
9
+
10
+ ### Features
11
+
12
+ * **web:** tsx buttons ([#1529](https://github.com/BonnierNews/dn-design-system/issues/1529)) ([5659dfc](https://github.com/BonnierNews/dn-design-system/commit/5659dfc0bba1dbb5eae739c704c9df704964d709))
13
+
14
+ ## [22.1.1](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@22.1.0...@bonniernews/dn-design-system-web@22.1.1) (2024-12-18)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **web:** link story and component in tsx ([#1550](https://github.com/BonnierNews/dn-design-system/issues/1550)) ([c69955d](https://github.com/BonnierNews/dn-design-system/commit/c69955dc42002f7350f785c723985adee6cd83d5))
20
+
7
21
  ## [22.1.0](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@22.0.0...@bonniernews/dn-design-system-web@22.1.0) (2024-12-17)
8
22
 
9
23
 
@@ -0,0 +1,53 @@
1
+ - GitHub: [BonnierNews/dn-design-system/../web/src/components/button](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/button)
2
+ - Storybook: [Buttons > Button](https://designsystem.dn.se/?path=/docs/basic-buttons-button--docs)
3
+ - Storybook (Latest): [Buttons > Button](https://designsystem-latest.dn.se/?path=/docs/basic-buttons-button--docs)
4
+
5
+ ----
6
+
7
+ # Button
8
+
9
+ ## Parameters
10
+
11
+ |parameter | type | required | options | default | description |
12
+ |:--- | :--- | :--- | :--- | :--- | :--- |
13
+ |text | String | yes | | | |
14
+ |disabled | bool | no | true, false | false | Note: only works on button-tag, not on a-tag |
15
+ |variant | String | no | primary, secondary, brand, staticWhite | primary | Design variant |
16
+ |emphasis | String | no | default, elevated, outline, transparent | default | |
17
+ |rounded | bool | no | true, false | false | Button will be rounded |
18
+ |size| String | no | small, medium, large, xlarge | medium | |
19
+ |fullWidth | bool | no | true, false | false | Button will be full width on both desktop and mobile |
20
+ |mobile.fullWidth | bool | no | true, false | false | Ex mobile: { fullWidth: true } |
21
+ |iconPosition | String | no | none, left, right | none | |
22
+ |iconName | String | no | add, arrow_back, arrow_forward etc | | For all available icons see: https://designsystem.dn.se/?path=/story/foundations-icons--all-icons |
23
+ |loading | bool | no | true, false | false | |
24
+ |type | String | no | button, submit | button | |
25
+ |href | String | no | | | If href is set the button will be rendered as an a-tag |
26
+ |attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
27
+ |classNames | String | no | | | Ex. "my-special-class" |
28
+ |forcePx | bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
29
+
30
+ ## Minimum requirement example
31
+
32
+ ### Nunjucks
33
+
34
+ These are copy paste friendly examples to quickliy get started using a component.
35
+
36
+ ```html
37
+ {% from '@bonniernews/dn-design-system-web/components/button/button.njk' import Button %}
38
+
39
+ {{ Button({
40
+ text: 'Primary with icon',
41
+ variant: 'primary',
42
+ iconPosition: 'left',
43
+ iconName: 'plus',
44
+ mobile: {
45
+ fullWidth: true
46
+ },
47
+ })}}
48
+ ```
49
+
50
+ ### SCSS
51
+ ```scss
52
+ @use "@bonniernews/dn-design-system-web/components/button/button";
53
+ ```
@@ -1,53 +1,36 @@
1
- - GitHub: [BonnierNews/dn-design-system/../web/src/components/button](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/button)
2
- - Storybook: [Buttons > Button](https://designsystem.dn.se/?path=/docs/basic-buttons-button--docs)
3
- - Storybook (Latest): [Buttons > Button](https://designsystem-latest.dn.se/?path=/docs/basic-buttons-button--docs)
4
-
5
- ----
6
-
7
- # Button
8
-
9
- ## Parameters
10
-
11
- |parameter | type | required | options | default | description |
12
- |:--- | :--- | :--- | :--- | :--- | :--- |
13
- |text | String | yes | | | |
14
- |disabled | bool | no | true, false | false | Note: only works on button-tag, not on a-tag |
15
- |variant | String | no | primary, secondary, brand, staticWhite | primary | Design variant |
16
- |emphasis | String | no | default, elevated, outline, transparent | default | |
17
- |rounded | bool | no | true, false | false | Button will be rounded |
18
- |size| String | no | small, medium, large, xlarge | medium | |
19
- |fullWidth | bool | no | true, false | false | Button will be full width on both desktop and mobile |
20
- |mobile.fullWidth | bool | no | true, false | false | Ex mobile: { fullWidth: true } |
21
- |iconPosition | String | no | none, left, right | none | |
22
- |iconName | String | no | add, arrow_back, arrow_forward etc | | For all available icons see: https://designsystem.dn.se/?path=/story/foundations-icons--all-icons |
23
- |loading | bool | no | true, false | false | |
24
- |type | String | no | button, submit | button | |
25
- |href | String | no | | | If href is set the button will be rendered as an a-tag |
26
- |attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
27
- |classNames | String | no | | | Ex. "my-special-class" |
28
- |forcePx | bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
29
-
30
- ## Minimum requirement example
31
-
32
- ### Nunjucks
33
-
34
- These are copy paste friendly examples to quickliy get started using a component.
35
-
36
- ```html
37
- {% from '@bonniernews/dn-design-system-web/components/button/button.njk' import Button %}
38
-
39
- {{ Button({
40
- text: 'Primary with icon',
41
- variant: 'primary',
42
- iconPosition: 'left',
43
- iconName: 'plus',
44
- mobile: {
45
- fullWidth: true
46
- },
47
- })}}
48
- ```
49
-
50
- ### SCSS
51
- ```scss
52
- @use "@bonniernews/dn-design-system-web/components/button/button";
53
- ```
1
+ Button
2
+ ======
3
+
4
+ * GitHub: [BonnierNews/dn-design-system/../web/src/components/button](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/button)
5
+ * Storybook: [Buttons > Button](https://designsystem.dn.se/?path=/docs/basic-buttons-button--docs)
6
+
7
+ The component will not include styling by itself. Make sure to include the right styles for the component. See example below: `@use '@bonniernews/dn-design-system-web/components/button/button.scss'`
8
+
9
+
10
+ | Name | Description | Default |
11
+ |:--- | :--- | :--- |
12
+ | text\* | string | \- |
13
+ | disabled | Note: only works on button-tag, not on a-tag<br />boolean | false |
14
+ | classNames | string | \- |
15
+ | attributes | Ex. { target: "\_blank", "data-test": "lorem ipsum" }<br />{ \[key: string\]: string; } | \- |
16
+ | forcePx | Fixed pixel value is used for typography to prevent scaling based on html font-size<br />boolean | false |
17
+ | size | "large", "small", "medium", "xlarge" | "medium" |
18
+ | loading | boolean | false |
19
+ | iconName | add, arrow\_back, arrow\_forward etc | | For all available icons see: [https://designsystem.dn.se/?path=/story/foundations-icons--all-icons](https://designsystem.dn.se/?path=/story/foundations-icons--all-icons)<br />"add", "arrow\_back", "arrow\_forward", "arrow\_outward", "arrow\_upward", "bookmark-filled", "bookmarked", "campaign" | \- |
20
+ | variant | Design variant<br />"brand", "secondary", "primary", "staticWhite" | "primary" |
21
+ | emphasis | "default", "elevated", "outline", "transparent" | "default" |
22
+ | rounded | Button will be rounded<br />boolean | false |
23
+ | href | If href is set the button will be rendered as an a-tag<br />string | \- |
24
+ | fullWidth | Button will be full width on both desktop and mobile<br />boolean | false |
25
+ | mobileFullWidth | Button will only full width on mobile<br />boolean | false |
26
+ | iconPosition | "right", "none", "left" | "none" |
27
+ | type | "button", "submit" | "button" |
28
+
29
+ ```jsx
30
+ <Button
31
+ emphasis="default"
32
+ size="medium"
33
+ text="Primary"
34
+ variant="primary"
35
+ />
36
+ ```
@@ -0,0 +1,87 @@
1
+ import type { DsIcon } from '../../types-lib/ds-icon'
2
+
3
+ export interface ButtonSharedProps {
4
+ /** Note: only works on button-tag, not on a-tag */
5
+ disabled?: boolean
6
+ classNames?: string
7
+ /** Ex. { target: "_blank", "data-test": "lorem ipsum" } */
8
+ attributes?: { [key: string]: string }
9
+ /** Fixed pixel value is used for typography to prevent scaling based on html font-size */
10
+ forcePx?: boolean
11
+ size?: 'small' | 'medium' | 'large' | 'xlarge'
12
+ loading?: boolean
13
+ }
14
+
15
+ export interface AllyProps {
16
+ visuallyHidden?: string
17
+ }
18
+
19
+ export interface ButtonBaseProps extends ButtonSharedProps {
20
+ /** Design variant */
21
+ variant?: 'primary' | 'secondary' | 'brand' | 'staticWhite'
22
+ text?: string
23
+ emphasis?: 'default' | 'elevated' | 'outline' | 'transparent'
24
+ /** Button will be rounded */
25
+ rounded?: boolean
26
+ /** Button will be full width on both desktop and mobile */
27
+ fullWidth?: boolean
28
+ /** Button will only full width on mobile */
29
+ mobileFullWidth?: boolean
30
+ iconPosition?: 'none' | 'left' | 'right'
31
+ /** add, arrow_back, arrow_forward etc | | For all available icons see: https://designsystem.dn.se/?path=/story/foundations-icons--all-icons */
32
+ iconName?: DsIcon
33
+ type?: 'button' | 'submit'
34
+ /** If href is set the button will be rendered as an a-tag */
35
+ href?: string
36
+ isIconButton?: boolean
37
+ a11y?: AllyProps
38
+ selected?: boolean
39
+ isToggle?: boolean
40
+ selectedIconName?: DsIcon
41
+ selectedText?: string
42
+ }
43
+
44
+ export interface InnerButtonProps {
45
+ text?: string
46
+ isIconButton?: boolean
47
+ attributes?: object | any
48
+ a11y?: AllyProps
49
+ icon?: any
50
+ loadingHtml?: any
51
+ }
52
+
53
+ export interface ToggleWrapperProps {
54
+ selected?: boolean
55
+ classes?: string
56
+ attributes?: object
57
+ disabled?: boolean
58
+ loadingHtml?: any
59
+ onChild?: any
60
+ offChild?: any
61
+ }
62
+
63
+ export interface ButtonProps
64
+ extends ButtonSharedProps,
65
+ Pick<
66
+ ButtonBaseProps,
67
+ 'text' | 'variant' | 'emphasis' | 'rounded' | 'fullWidth' | 'mobileFullWidth' | 'iconPosition' | 'iconName' | 'type' | 'href'
68
+ > {
69
+ text: string // set as required
70
+ }
71
+
72
+ export interface ButtonToggleProps
73
+ extends ButtonSharedProps,
74
+ Pick<ButtonBaseProps, 'selected' | 'text' | 'selectedText' | 'fullWidth' | 'mobileFullWidth'> {
75
+ selectedText: string // set as required
76
+ variant?: 'primary' | 'secondary' | 'brand'
77
+ }
78
+ export interface IconButtonProps extends ButtonSharedProps, Pick<ButtonBaseProps, 'iconName' | 'emphasis' | 'rounded' | 'href'> {
79
+ a11y?: object;
80
+ variant?: 'primary' | 'secondary' | 'brand'
81
+ }
82
+
83
+
84
+ export interface IconButtonToggleProps extends ButtonSharedProps, Pick<ButtonBaseProps, 'iconName' | 'emphasis' | 'selectedIconName'> {
85
+ selected?: boolean;
86
+ variant?: 'primary' | 'secondary' | 'brand'
87
+ }
@@ -0,0 +1,56 @@
1
+ - GitHub: [BonnierNews/dn-design-system/../web/src/components/button-toggle](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/button-toggle)
2
+ - Storybook: [Buttons > ButtonToggle](https://designsystem.dn.se/?path=/docs/basic-buttons-buttontoggle--docs)
3
+ - Storybook (Latest): [Buttons > ButtonToggle](https://designsystem-latest.dn.se/?path=/docs/basic-buttons-buttontoggle--docs)
4
+
5
+ ----
6
+
7
+ # ButtonToggle
8
+
9
+ ## Parameters
10
+
11
+ |parameter | type | required | options | default | description |
12
+ |:--- | :--- | :--- | :--- | :--- | :--- |
13
+ |selected | bool | no | true, false | false | |
14
+ |text | String | yes | | | |
15
+ |selectedText | String | yes | | | |
16
+ |disabled | bool | no | true, false | false | |
17
+ |variant | String | no | primary, secondary, brand | primary | Design variant |
18
+ |size| String | no | small, medium, large | medium | |
19
+ |fullWidth | bool | no | true, false | false | Button will be full width on both desktop and mobile |
20
+ |mobile.fullWidth | bool | no | true, false | false | Ex mobile: { fullWidth: true } |
21
+ |loading | bool | no | true, false | false | |
22
+ |attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
23
+ |classNames | String | no | | | Ex. "my-special-class" |
24
+ |forcePx | bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
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/button-toggle/button-toggle.njk' import ButtonToggle %}
34
+
35
+ {{ ButtonToggle({
36
+ text: 'Följ',
37
+ selectedText: 'Följer',
38
+ variant: 'brand',
39
+ mobile: {
40
+ fullWidth: true
41
+ }
42
+ })}}
43
+ ```
44
+
45
+ ### SCSS
46
+ ```scss
47
+ @use "@bonniernews/dn-design-system-web/components/button-toggle/button-toggle";
48
+ ```
49
+
50
+ ### Javascript
51
+
52
+ ```javascript
53
+ import dsButtonToggle from '@bonniernews/dn-design-system-web/components/button/button.js'
54
+ const toggleElements = Array.from(document.getElementsByClassName("ds-btn--toggle"));
55
+ dsButtonToggle(toggleElements);
56
+ ```
@@ -1,56 +1,39 @@
1
- - GitHub: [BonnierNews/dn-design-system/../web/src/components/button-toggle](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/button-toggle)
2
- - Storybook: [Buttons > ButtonToggle](https://designsystem.dn.se/?path=/docs/basic-buttons-buttontoggle--docs)
3
- - Storybook (Latest): [Buttons > ButtonToggle](https://designsystem-latest.dn.se/?path=/docs/basic-buttons-buttontoggle--docs)
1
+ ButtonToggle
2
+ ============
4
3
 
5
- ----
4
+ * GitHub: [BonnierNews/dn-design-system/../web/src/components/button-toggle](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/button-toggle)
5
+ * Storybook: [Buttons > ButtonToggle](https://designsystem.dn.se/?path=/docs/basic-buttons-buttontoggle--docs)
6
6
 
7
- # ButtonToggle
8
-
9
- ## Parameters
10
-
11
- |parameter | type | required | options | default | description |
12
- |:--- | :--- | :--- | :--- | :--- | :--- |
13
- |selected | bool | no | true, false | false | |
14
- |text | String | yes | | | |
15
- |selectedText | String | yes | | | |
16
- |disabled | bool | no | true, false | false | |
17
- |variant | String | no | primary, secondary, brand | primary | Design variant |
18
- |size| String | no | small, medium, large | medium | |
19
- |fullWidth | bool | no | true, false | false | Button will be full width on both desktop and mobile |
20
- |mobile.fullWidth | bool | no | true, false | false | Ex mobile: { fullWidth: true } |
21
- |loading | bool | no | true, false | false | |
22
- |attributes | Object | no | | | Ex. { target: "_blank", "data-test": "lorem ipsum" } |
23
- |classNames | String | no | | | Ex. "my-special-class" |
24
- |forcePx | bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
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/button-toggle/button-toggle.njk' import ButtonToggle %}
34
-
35
- {{ ButtonToggle({
36
- text: 'Följ',
37
- selectedText: 'Följer',
38
- variant: 'brand',
39
- mobile: {
40
- fullWidth: true
41
- }
42
- })}}
43
- ```
44
-
45
- ### SCSS
46
- ```scss
47
- @use "@bonniernews/dn-design-system-web/components/button-toggle/button-toggle";
48
- ```
49
-
50
- ### Javascript
7
+ ### [](#javascript)Javascript
51
8
 
52
9
  ```javascript
53
10
  import dsButtonToggle from '@bonniernews/dn-design-system-web/components/button/button.js'
54
11
  const toggleElements = Array.from(document.getElementsByClassName("ds-btn--toggle"));
55
12
  dsButtonToggle(toggleElements);
56
13
  ```
14
+
15
+ The component will not include styling by itself. Make sure to include the right styles for the component. See example below: `@use "@bonniernews/dn-design-system-web/components/button-toggle/button-toggle.scss";`
16
+
17
+ | Name | Description | Default |
18
+ |:--- | :--- | :--- |
19
+ | selectedText\* | string | \- |
20
+ | variant | "brand", "secondary", "primary" | "primary" |
21
+ | disabled | Note: only works on button-tag, not on a-tag<br />boolean | false |
22
+ | classNames | string | \- |
23
+ | attributes | Ex. { target: "\_blank", "data-test": "lorem ipsum" }<br />{ \[key: string\]: string; } | { } |
24
+ | forcePx | Fixed pixel value is used for typography to prevent scaling based on html font-size<br />boolean | false |
25
+ | size | "large", "small", "medium", "xlarge" | "medium" |
26
+ | loading | boolean | false |
27
+ | text | string | \- |
28
+ | selected | boolean | false |
29
+ | fullWidth | Button will be full width on both desktop and mobile<br />boolean | false |
30
+ | mobileFullWidth | Button will only full width on mobile<br />boolean | false |
31
+
32
+ ```jsx
33
+ <ButtonToggle
34
+ selectedText="Följer"
35
+ size="large"
36
+ text="Följ"
37
+ variant="brand"
38
+ />
39
+ ```
@@ -6,4 +6,12 @@ Divider
6
6
 
7
7
  The component will not include styling by itself. Make sure to include the right styles for the component. See example below: `@use '@bonniernews/dn-design-system-web/components/divider/divider.scss'`
8
8
 
9
- <table class="docblock-argstable sb-unstyled css-v2ifgj"><thead class="docblock-argstable-head"><tr><th><span>Name</span></th><th><span>Description</span></th><th><span>Default</span></th></tr></thead><tbody class="docblock-argstable-body"><tr><td class="css-4lbn0a"><span class="css-in3yi3">variant</span></td><td><div class="css-1f9domv"><div class="css-13nzt7e"><span class="css-o1d7ko">"soft"</span><span class="css-o1d7ko">"medium"</span><span class="css-o1d7ko">"hard"</span></div></div></td><td><div class="css-13nzt7e"><span class="css-o1d7ko">"soft"</span></div></td></tr><tr><td class="css-4lbn0a"><span class="css-in3yi3">classNames</span></td><td><div class="css-1f9domv"><div class="css-13nzt7e"><span class="css-o1d7ko">string</span></div></div></td><td><span>-</span></td></tr><tr><td class="css-4lbn0a"><span class="css-in3yi3">attributes</span></td><td><div class="css-1f9domv"><div class="css-13nzt7e"><span class="css-o1d7ko">object</span></div></div></td><td><span>-</span></td></tr></tbody></table>
9
+ | Name | Description | Default |
10
+ |:--- | :--- | :--- |
11
+ | variant | "soft", "medium", "hard" | "soft" |
12
+ | classNames | string | \- |
13
+ | attributes | object | \- |
14
+
15
+ ```jsx
16
+ <Divider variant="soft" />
17
+ ```