@bonniernews/dn-design-system-web 25.0.0 → 25.0.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.
- package/CHANGELOG.md +20 -0
- package/components/buddy-menu/README-NJK.md +71 -0
- package/components/buddy-menu/README.md +38 -62
- package/components/buddy-menu/buddy-menu.njk +0 -4
- package/components/buddy-menu/buddy-menu.scss +0 -4
- package/components/button/README.md +1 -1
- package/components/text-input/README-NJK.md +57 -0
- package/components/text-input/README.md +28 -48
- package/components/text-input/text-input-interactions.js +26 -0
- package/components/text-input/text-input.js +12 -10
- package/components/text-input/text-input.scss +2 -1
- package/package.json +1 -1
- package/preact/assets/form-field/form-field.d.ts +1 -1
- package/preact/components/buddy-menu/buddy-menu.d.ts +49 -0
- package/preact/components/buddy-menu/buddy-menu.js +301 -0
- package/preact/components/buddy-menu/buddy-menu.js.map +7 -0
- package/preact/components/checkbox/checkbox.js +2 -2
- package/preact/components/checkbox/checkbox.js.map +2 -2
- package/preact/components/list-item/list-item.js +2 -2
- package/preact/components/list-item/list-item.js.map +2 -2
- package/preact/components/radio-button/radio-button.js +2 -2
- package/preact/components/radio-button/radio-button.js.map +2 -2
- package/preact/components/text-input/text-input.d.ts +41 -0
- package/preact/components/text-input/text-input.js +273 -0
- package/preact/components/text-input/text-input.js.map +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,26 @@ All changes to @bonniernews/dn-design-system-web will be documented in this file
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
+
## [25.0.2](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@25.0.1...@bonniernews/dn-design-system-web@25.0.2) (2025-01-16)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* **web:** text input to tsx ([#1576](https://github.com/BonnierNews/dn-design-system/issues/1576)) ([ca1ebd7](https://github.com/BonnierNews/dn-design-system/commit/ca1ebd7a574ba9014e8c15344524ef7de78acc61))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Maintenance
|
|
16
|
+
|
|
17
|
+
* prerelease packages ([491e500](https://github.com/BonnierNews/dn-design-system/commit/491e500dfe03d0b3735999fb9c747e414a198bf2))
|
|
18
|
+
* update variables ([#1575](https://github.com/BonnierNews/dn-design-system/issues/1575)) ([9d3a378](https://github.com/BonnierNews/dn-design-system/commit/9d3a378ed8c9eec82a1ca04a6530fadfbfcb1a7c))
|
|
19
|
+
|
|
20
|
+
## [25.0.1](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@25.0.0...@bonniernews/dn-design-system-web@25.0.1) (2025-01-14)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Maintenance
|
|
24
|
+
|
|
25
|
+
* **web:** rewrite buddy menu to tsx ([#1573](https://github.com/BonnierNews/dn-design-system/issues/1573)) ([e3e8c89](https://github.com/BonnierNews/dn-design-system/commit/e3e8c893512fa177d5da6f91bf431a7568b64f72))
|
|
26
|
+
|
|
7
27
|
## [25.0.0](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@24.0.0...@bonniernews/dn-design-system-web@25.0.0) (2025-01-14)
|
|
8
28
|
|
|
9
29
|
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
- GitHub: [BonnierNews/dn-design-system/../web/src/components/buddy-menu](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/buddy-menu)
|
|
2
|
+
- Storybook: [BuddyMenu](https://designsystem.dn.se/?path=/docs/page-buddymenu--docs)
|
|
3
|
+
- Storybook (Latest): [BuddyMenu](https://designsystem-latest.dn.se/?path=/docs/page-buddymenu--docs)
|
|
4
|
+
|
|
5
|
+
----
|
|
6
|
+
|
|
7
|
+
# BuddyMenu
|
|
8
|
+
|
|
9
|
+
## Parameters
|
|
10
|
+
|
|
11
|
+
|parameter | type | required | options | default | description |
|
|
12
|
+
|:--- | :--- | :--- | :--- | :--- | :--- |
|
|
13
|
+
|userName | String | no | | none | Should be populated with product specific js|
|
|
14
|
+
|links | HTML String | no | | | Should be list item components|
|
|
15
|
+
|accountLevel | String | no | | none | Should be populated with product specific js|
|
|
16
|
+
|myAccountUrl | String | yes | | | Url for "Mitt konto" button |
|
|
17
|
+
|addons | Array > Object | no | | | Ex. [{ title: 'Annonsfri', href: "https://id.dn.se/konto/?nextUrl=/vanliga-fragor/dn/#Annonsfritt" }] |
|
|
18
|
+
|attributes | Object | no | | | Ex. { "data-test": "lorem ipsum" } |
|
|
19
|
+
|classNames | String | no | | | Ex. "my-special-class" |
|
|
20
|
+
|forcePx | bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
|
|
21
|
+
|
|
22
|
+
## Minimum requirement example
|
|
23
|
+
|
|
24
|
+
### Nunjucks
|
|
25
|
+
|
|
26
|
+
These are copy paste friendly examples to quickliy get started using a component.
|
|
27
|
+
|
|
28
|
+
```html
|
|
29
|
+
{% from '@bonniernews/dn-design-system-web/components/buddy-menu/buddy-menu.njk' import BuddyMenu %}
|
|
30
|
+
|
|
31
|
+
{% macro BuddyMenuSample() %}
|
|
32
|
+
{{ ListItem({
|
|
33
|
+
title: 'Följer (ämnen och skribenter)',
|
|
34
|
+
leadingIcon: 'favorite',
|
|
35
|
+
border: true,
|
|
36
|
+
listItemType: "standard",
|
|
37
|
+
forcePx: true,
|
|
38
|
+
href: "https://www.dn.se/foljer/"
|
|
39
|
+
})}}
|
|
40
|
+
{{ ListItem({
|
|
41
|
+
title: 'Logga ut',
|
|
42
|
+
leadingIcon: 'logout',
|
|
43
|
+
border: false,
|
|
44
|
+
listItemType: "standard",
|
|
45
|
+
forcePx: true,
|
|
46
|
+
href: params.urls.logOut | default('#'),
|
|
47
|
+
classNames: "js-buddy-menu__logout"
|
|
48
|
+
})}}
|
|
49
|
+
{% endmacro %}
|
|
50
|
+
|
|
51
|
+
{{ BuddyMenu({
|
|
52
|
+
userName: "",
|
|
53
|
+
accountLevel: "",
|
|
54
|
+
myAccountUrl: "https://id.dn.se/konto/",
|
|
55
|
+
links: BuddyMenuSample(),
|
|
56
|
+
addons: [{ title: 'Annonsfri', href: "https://id.dn.se/konto/?nextUrl=/vanliga-fragor/dn/#Annonsfritt" }],
|
|
57
|
+
forcePx: true
|
|
58
|
+
})}}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### SCSS
|
|
62
|
+
```scss
|
|
63
|
+
@use "@bonniernews/dn-design-system-web/components/buddy-menu/buddy-menu" as *;
|
|
64
|
+
|
|
65
|
+
// these css variables can be overwritten to adjust
|
|
66
|
+
// top/right position:
|
|
67
|
+
--ds-buddy-menu-bottom-margin: 100px;
|
|
68
|
+
--ds-buddy-menu-position-top: 0;
|
|
69
|
+
// bottom-margin i.e. total max-height; calc(100vh - var(--ds-buddy-menu-bottom-margin))
|
|
70
|
+
--ds-buddy-menu-position-right: 0;
|
|
71
|
+
```
|
|
@@ -1,71 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
- Storybook (Latest): [BuddyMenu](https://designsystem-latest.dn.se/?path=/docs/page-buddymenu--docs)
|
|
1
|
+
BuddyMenu
|
|
2
|
+
=========
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
* GitHub: [BonnierNews/dn-design-system/../web/src/components/buddy-menu](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/buddy-menu)
|
|
5
|
+
* Storybook: [BuddyMenu](https://designsystem.dn.se/?path=/docs/page-buddymenu--docs)
|
|
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/buddy-menu/buddy-menu" as *;`
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
#### [](#adjust-buddy-menu-position)Adjust buddy menu position
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|:--- | :--- | :--- | :--- | :--- | :--- |
|
|
13
|
-
|userName | String | no | | none | Should be populated with product specific js|
|
|
14
|
-
|links | HTML String | no | | | Should be list item components|
|
|
15
|
-
|accountLevel | String | no | | none | Should be populated with product specific js|
|
|
16
|
-
|myAccountUrl | String | yes | | | Url for "Mitt konto" button |
|
|
17
|
-
|addons | Array > Object | no | | | Ex. [{ title: 'Annonsfri', href: "https://id.dn.se/konto/?nextUrl=/vanliga-fragor/dn/#Annonsfritt" }] |
|
|
18
|
-
|attributes | Object | no | | | Ex. { "data-test": "lorem ipsum" } |
|
|
19
|
-
|classNames | String | no | | | Ex. "my-special-class" |
|
|
20
|
-
|forcePx | bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
|
|
11
|
+
These css variables can be overwritten to adjust the position of the buddy menu:
|
|
21
12
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
### Nunjucks
|
|
25
|
-
|
|
26
|
-
These are copy paste friendly examples to quickliy get started using a component.
|
|
27
|
-
|
|
28
|
-
```html
|
|
29
|
-
{% from '@bonniernews/dn-design-system-web/components/buddy-menu/buddy-menu.njk' import BuddyMenu %}
|
|
30
|
-
|
|
31
|
-
{% macro BuddyMenuSample() %}
|
|
32
|
-
{{ ListItem({
|
|
33
|
-
title: 'Följer (ämnen och skribenter)',
|
|
34
|
-
leadingIcon: 'favorite',
|
|
35
|
-
border: true,
|
|
36
|
-
listItemType: "standard",
|
|
37
|
-
forcePx: true,
|
|
38
|
-
href: "https://www.dn.se/foljer/"
|
|
39
|
-
})}}
|
|
40
|
-
{{ ListItem({
|
|
41
|
-
title: 'Logga ut',
|
|
42
|
-
leadingIcon: 'logout',
|
|
43
|
-
border: false,
|
|
44
|
-
listItemType: "standard",
|
|
45
|
-
forcePx: true,
|
|
46
|
-
href: params.urls.logOut | default('#'),
|
|
47
|
-
classNames: "js-buddy-menu__logout"
|
|
48
|
-
})}}
|
|
49
|
-
{% endmacro %}
|
|
50
|
-
|
|
51
|
-
{{ BuddyMenu({
|
|
52
|
-
userName: "",
|
|
53
|
-
accountLevel: "",
|
|
54
|
-
myAccountUrl: "https://id.dn.se/konto/",
|
|
55
|
-
links: BuddyMenuSample(),
|
|
56
|
-
addons: [{ title: 'Annonsfri', href: "https://id.dn.se/konto/?nextUrl=/vanliga-fragor/dn/#Annonsfritt" }],
|
|
57
|
-
forcePx: true
|
|
58
|
-
})}}
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
### SCSS
|
|
62
|
-
```scss
|
|
63
|
-
@use "@bonniernews/dn-design-system-web/components/buddy-menu/buddy-menu" as *;
|
|
64
|
-
|
|
65
|
-
// these css variables can be overwritten to adjust
|
|
66
|
-
// top/right position:
|
|
13
|
+
```javascript
|
|
67
14
|
--ds-buddy-menu-bottom-margin: 100px;
|
|
68
15
|
--ds-buddy-menu-position-top: 0;
|
|
69
|
-
// bottom-margin i.e. total max-height; calc(100vh - var(--ds-buddy-menu-bottom-margin))
|
|
70
16
|
--ds-buddy-menu-position-right: 0;
|
|
71
17
|
```
|
|
18
|
+
|
|
19
|
+
If we are using an (list-item) accordion in the buddy menu, we need to include the following js:
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
import dsListItem from '@bonniernews/dn-design-system-web/components/list-item/list-item.js'
|
|
23
|
+
const listElements = Array.from(document.getElementsByClassName("ds-list-item"));
|
|
24
|
+
dsListItem(listElements);s
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
| Name | Description | Default |
|
|
28
|
+
|:--- | :--- | :--- |
|
|
29
|
+
| userName | Should be populated with product specific js<br />string | \- |
|
|
30
|
+
| links | Should be list item components<br />ComponentChildren | \- |
|
|
31
|
+
| accountLevel | Should be populated with product specific js<br />string | \- |
|
|
32
|
+
| myAccountUrl\* | Url for "Mitt konto" button<br />string | \- |
|
|
33
|
+
| addons | Ex. \[{ title: 'Annonsfri', href: "[https://id.dn.se/konto/?nextUrl=/vanliga-fragor/dn/#Annonsfritt](https://id.dn.se/konto/?nextUrl=/vanliga-fragor/dn/#Annonsfritt)" }\]<br />{ title: string; href?: string; classNames?: string; }\[\] | \- |
|
|
34
|
+
| addonsClassNames | string | \- |
|
|
35
|
+
| isDnSkola | boolean | false |
|
|
36
|
+
| classNames | string | \- |
|
|
37
|
+
| attributes | Ex. { target: "\_blank", "data-test": "lorem ipsum" }<br />object | \- |
|
|
38
|
+
| forcePx | Fixed pixel value is used for typography to prevent scaling based on html font-size<br />boolean | \- |
|
|
39
|
+
|
|
40
|
+
```jsx
|
|
41
|
+
<BuddyMenu
|
|
42
|
+
accountLevel="DN Digital"
|
|
43
|
+
links={<BuddyMenuLinksArkivet />}
|
|
44
|
+
myAccountUrl="https://id.dn.se/konto/"
|
|
45
|
+
userName="Anna Andersson"
|
|
46
|
+
/>
|
|
47
|
+
```
|
|
@@ -21,10 +21,10 @@ Button
|
|
|
21
21
|
| fullWidth | Button will be full width on both desktop and mobile<br />boolean | false |
|
|
22
22
|
| mobileFullWidth | Button will only full width on mobile<br />boolean | false |
|
|
23
23
|
| href | If href is set the button will be rendered as an a-tag<br />string | \- |
|
|
24
|
+
| type | "button", "submit" | "button" |
|
|
24
25
|
| emphasis | "default", "elevated", "outline", "transparent" | "default" |
|
|
25
26
|
| rounded | Button will be rounded<br />boolean | false |
|
|
26
27
|
| iconPosition | "right", "none", "left" | "none" |
|
|
27
|
-
| type | "button", "submit" | "button" |
|
|
28
28
|
|
|
29
29
|
```jsx
|
|
30
30
|
<Button
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
- GitHub: [BonnierNews/dn-design-system/../web/src/components/text-input](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/text-input)
|
|
2
|
+
- Storybook: [Form > TextInput](https://designsystem.dn.se/?path=/docs/basic-form-textinput--docs)
|
|
3
|
+
- Storybook (Latest): [Form > TextInput](https://designsystem-latest.dn.se/?path=/docs/basic-form-textinput--docs)
|
|
4
|
+
|
|
5
|
+
----
|
|
6
|
+
|
|
7
|
+
# Text input
|
|
8
|
+
|
|
9
|
+
A standard text input. It can be used as password field if the corresponding type is set.
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
|parameter | type | required | options | default | description |
|
|
14
|
+
|:--- | :--- | :--- | :--- | :--- | :--- |
|
|
15
|
+
| name | String | yes | | | It's used as name and id |
|
|
16
|
+
| type | String | yes | text, password, email, etc | text | |
|
|
17
|
+
| label | String | yes | | | A label for the input |
|
|
18
|
+
| classNames | String | no | | | Ex. "my-special-class" |
|
|
19
|
+
| attributes | Object | no | | | Ex. { data-prop: value } |
|
|
20
|
+
| required | bool | no | true, false | false | |
|
|
21
|
+
| validation | String | no | | | To use with the sites validation, some example values for dn-web: required, password, email |
|
|
22
|
+
| helpText | String | no | | | A helptext for the field if needed |
|
|
23
|
+
| error | bool | no | true, false | false | Used if error state shoud be set on load |
|
|
24
|
+
| errorMessage | String | no | | | What error message that should be displayed |
|
|
25
|
+
| disabled | bool | no | true, false | false | Set to true if the field should be disabled |
|
|
26
|
+
| autoFocus | bool | no | true, false| false | Set to true if field should have focus when loaded |
|
|
27
|
+
| forcePx | bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
|
|
28
|
+
|
|
29
|
+
## Minimum requirement example
|
|
30
|
+
|
|
31
|
+
These are copy paste friendly examples to quickliy get started using a component.
|
|
32
|
+
|
|
33
|
+
### Nunjucks
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
{% from '@bonniernews/dn-design-system-web/components/text-input/text-input.njk' import TextInput %}
|
|
37
|
+
|
|
38
|
+
{{ TextInput({
|
|
39
|
+
name: "name",
|
|
40
|
+
type: "text",
|
|
41
|
+
label: "A label for the input"
|
|
42
|
+
})}}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Scss
|
|
46
|
+
|
|
47
|
+
```scss
|
|
48
|
+
@use "@bonniernews/dn-design-system-web/components/text-input/text-input";
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Javascript
|
|
52
|
+
|
|
53
|
+
```javascript
|
|
54
|
+
import textInput from '@bonniernews/dn-design-system-web/components/text-input/text-input.js'
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
*The javascript is only needed for text fields of type password*
|
|
@@ -1,57 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
- Storybook (Latest): [Form > TextInput](https://designsystem-latest.dn.se/?path=/docs/basic-form-textinput--docs)
|
|
1
|
+
TextInput
|
|
2
|
+
=========
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
* GitHub: [BonnierNews/dn-design-system/../web/src/components/text-input](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/text-input)
|
|
5
|
+
* Storybook: [Form > TextInput](https://designsystem.dn.se/?path=/docs/basic-form-textinput--docs)
|
|
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/text-input/text-input";`
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
### [](#javascript)Javascript
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|parameter | type | required | options | default | description |
|
|
14
|
-
|:--- | :--- | :--- | :--- | :--- | :--- |
|
|
15
|
-
| name | String | yes | | | It's used as name and id |
|
|
16
|
-
| type | String | yes | text, password, email, etc | text | |
|
|
17
|
-
| label | String | yes | | | A label for the input |
|
|
18
|
-
| classNames | String | no | | | Ex. "my-special-class" |
|
|
19
|
-
| attributes | Object | no | | | Ex. { data-prop: value } |
|
|
20
|
-
| required | bool | no | true, false | false | |
|
|
21
|
-
| validation | String | no | | | To use with the sites validation, some example values for dn-web: required, password, email |
|
|
22
|
-
| helpText | String | no | | | A helptext for the field if needed |
|
|
23
|
-
| error | bool | no | true, false | false | Used if error state shoud be set on load |
|
|
24
|
-
| errorMessage | String | no | | | What error message that should be displayed |
|
|
25
|
-
| disabled | bool | no | true, false | false | Set to true if the field should be disabled |
|
|
26
|
-
| autoFocus | bool | no | true, false| false | Set to true if field should have focus when loaded |
|
|
27
|
-
| forcePx | bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
|
|
28
|
-
|
|
29
|
-
## Minimum requirement example
|
|
30
|
-
|
|
31
|
-
These are copy paste friendly examples to quickliy get started using a component.
|
|
32
|
-
|
|
33
|
-
### Nunjucks
|
|
34
|
-
|
|
35
|
-
```javascript
|
|
36
|
-
{% from '@bonniernews/dn-design-system-web/components/text-input/text-input.njk' import TextInput %}
|
|
37
|
-
|
|
38
|
-
{{ TextInput({
|
|
39
|
-
name: "name",
|
|
40
|
-
type: "text",
|
|
41
|
-
label: "A label for the input"
|
|
42
|
-
})}}
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### Scss
|
|
46
|
-
|
|
47
|
-
```scss
|
|
48
|
-
@use "@bonniernews/dn-design-system-web/components/text-input/text-input";
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
### Javascript
|
|
11
|
+
_The javascript is only needed for text fields of type password_
|
|
52
12
|
|
|
53
13
|
```javascript
|
|
54
14
|
import textInput from '@bonniernews/dn-design-system-web/components/text-input/text-input.js'
|
|
55
15
|
```
|
|
56
16
|
|
|
57
|
-
|
|
17
|
+
| Name | Description | Default |
|
|
18
|
+
|:--- | :--- | :--- |
|
|
19
|
+
| name\* | It's used as name and id<br />string | \- |
|
|
20
|
+
| type | text, password, email, etc<br />"number", "text", "search", "color", "image", "date", "datetime-local", "email" | "text" |
|
|
21
|
+
| label\* | A label for the input<br />string | \- |
|
|
22
|
+
| error | Used if error state shoud be set on load<br />boolean | \- |
|
|
23
|
+
| errorMessage | What error message that should be displayed<br />string | \- |
|
|
24
|
+
| required | boolean | \- |
|
|
25
|
+
| disabled | Set to true if the field should be disabled<br />boolean | \- |
|
|
26
|
+
| validation | To use with the sites validation, some example values for dn-web: required, password, email<br />string | \- |
|
|
27
|
+
| helpText | A helptext for the field if needed<br />string | \- |
|
|
28
|
+
| classNames | Ex. "my-special-class"<br />string | ", " |
|
|
29
|
+
| forcePx | Fixed pixel value is used for typography to prevent scaling based on html font-size<br />boolean | \- |
|
|
30
|
+
| autofocus | Set to true if field should have focus when loaded<br />boolean | \- |
|
|
31
|
+
| attributes | Ex. { data-prop: value }<br />{} | \- |
|
|
32
|
+
|
|
33
|
+
```jsx
|
|
34
|
+
<TextInput
|
|
35
|
+
label="Användarnamn"
|
|
36
|
+
/>
|
|
37
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const textInput = () => {
|
|
2
|
+
function passwordToggle(id, toggle) {
|
|
3
|
+
var x = document.getElementById(id)
|
|
4
|
+
if (x.type === 'password') {
|
|
5
|
+
x.type = 'text'
|
|
6
|
+
toggle.classList.add('ds-btn--selected')
|
|
7
|
+
toggle.setAttribute('aria-checked', 'true')
|
|
8
|
+
} else {
|
|
9
|
+
x.type = 'password'
|
|
10
|
+
toggle.classList.remove('ds-btn--selected')
|
|
11
|
+
toggle.setAttribute('aria-checked', 'false')
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const passwordInputs = document.querySelectorAll('.ds-text-input [type=password]')
|
|
16
|
+
passwordInputs.forEach((input) => {
|
|
17
|
+
const toggle = document.getElementById(`${input.id}-password-toggle`)
|
|
18
|
+
if (toggle) {
|
|
19
|
+
toggle.addEventListener('click', () => {
|
|
20
|
+
passwordToggle(input.id, toggle)
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default textInput
|
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
const textInput =
|
|
1
|
+
const textInput = () => {
|
|
2
2
|
function passwordToggle(id) {
|
|
3
|
-
var x = document.getElementById(id)
|
|
4
|
-
if (x.type ===
|
|
5
|
-
x.type =
|
|
3
|
+
var x = document.getElementById(id)
|
|
4
|
+
if (x.type === 'password') {
|
|
5
|
+
x.type = 'text'
|
|
6
6
|
} else {
|
|
7
|
-
x.type =
|
|
7
|
+
x.type = 'password'
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
const passwordInputs = document.querySelectorAll('.ds-text-input [type=password]')
|
|
11
|
+
const passwordInputs = document.querySelectorAll('.ds-text-input [type=password]')
|
|
12
12
|
passwordInputs.forEach((input) => {
|
|
13
|
-
const toggle = document.getElementById(`${input.id}-password-toggle`)
|
|
13
|
+
const toggle = document.getElementById(`${input.id}-password-toggle`)
|
|
14
14
|
if (toggle) {
|
|
15
|
-
toggle.addEventListener(
|
|
15
|
+
toggle.addEventListener('click', () => {
|
|
16
|
+
passwordToggle(input.id)
|
|
17
|
+
})
|
|
16
18
|
}
|
|
17
|
-
})
|
|
19
|
+
})
|
|
18
20
|
}
|
|
19
21
|
|
|
20
|
-
export default textInput
|
|
22
|
+
export default textInput
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
@use "../../foundations/helpers/forward.helpers.scss" as *;
|
|
2
2
|
@use "../../assets/form-field/form-field.scss";
|
|
3
|
-
@use "../icon-button/icon-button.scss";
|
|
3
|
+
@use "../icon-button-toggle/icon-button-toggle.scss";
|
|
4
|
+
@use "../icon-button/icon-button.scss"; // TODO remove when njk is removed
|
|
4
5
|
|
|
5
6
|
$ds-text-input-toggle-btn__width: 28px;
|
|
6
7
|
$ds-text-input-toggle-btn__top: 22px;
|
package/package.json
CHANGED
|
@@ -8,5 +8,5 @@ export interface FormFieldProps {
|
|
|
8
8
|
type?: string;
|
|
9
9
|
children?: ComponentChildren;
|
|
10
10
|
}
|
|
11
|
-
export declare const FormField: ({ errorMessage, wrapperClasses, helpHtml, helpText, type, children }: FormFieldProps) => import("preact").JSX.Element;
|
|
11
|
+
export declare const FormField: ({ error, errorMessage, wrapperClasses, helpHtml, helpText, type, children }: FormFieldProps) => import("preact").JSX.Element;
|
|
12
12
|
export default FormField;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ComponentChildren } from 'preact';
|
|
2
|
+
export interface BuddyMenuProps {
|
|
3
|
+
/** Should be populated with product specific js */
|
|
4
|
+
userName?: string;
|
|
5
|
+
/** Should be list item components */
|
|
6
|
+
links?: ComponentChildren;
|
|
7
|
+
/** Should be populated with product specific js */
|
|
8
|
+
accountLevel?: string;
|
|
9
|
+
/** Url for "Mitt konto" button */
|
|
10
|
+
myAccountUrl: string;
|
|
11
|
+
/** Ex. [{ title: 'Annonsfri', href: "https://id.dn.se/konto/?nextUrl=/vanliga-fragor/dn/#Annonsfritt" }] */
|
|
12
|
+
addons?: Array<{
|
|
13
|
+
title: string;
|
|
14
|
+
href?: string;
|
|
15
|
+
classNames?: string;
|
|
16
|
+
}>;
|
|
17
|
+
addonsClassNames?: string;
|
|
18
|
+
isDnSkola?: boolean;
|
|
19
|
+
classNames?: string;
|
|
20
|
+
/** Ex. { target: "_blank", "data-test": "lorem ipsum" } */
|
|
21
|
+
attributes?: object;
|
|
22
|
+
/** Fixed pixel value is used for typography to prevent scaling based on html font-size */
|
|
23
|
+
forcePx?: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* - GitHub: [BonnierNews/dn-design-system/../web/src/components/buddy-menu](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/buddy-menu)
|
|
27
|
+
* - Storybook: [BuddyMenu](https://designsystem.dn.se/?path=/docs/page-buddymenu--docs)
|
|
28
|
+
*
|
|
29
|
+
* The component will not include styling by itself. Make sure to include the right styles for the component. See example below:
|
|
30
|
+
* `@use "@bonniernews/dn-design-system-web/components/buddy-menu/buddy-menu" as *;`
|
|
31
|
+
*
|
|
32
|
+
* #### Adjust buddy menu position
|
|
33
|
+
* These css variables can be overwritten to adjust the position of the buddy menu:
|
|
34
|
+
*
|
|
35
|
+
* ```css
|
|
36
|
+
* --ds-buddy-menu-bottom-margin: 100px;
|
|
37
|
+
* --ds-buddy-menu-position-top: 0;
|
|
38
|
+
* --ds-buddy-menu-position-right: 0;
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* If we are using an (list-item) accordion in the buddy menu, we need to include the following js:
|
|
42
|
+
*
|
|
43
|
+
* ```javascript
|
|
44
|
+
* import dsListItem from '@bonniernews/dn-design-system-web/components/list-item/list-item.js'
|
|
45
|
+
* const listElements = Array.from(document.getElementsByClassName("ds-list-item"));
|
|
46
|
+
* dsListItem(listElements);s
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare const BuddyMenu: ({ userName, links, accountLevel, myAccountUrl, addons, addonsClassNames, isDnSkola, classNames, attributes, forcePx, }: BuddyMenuProps) => import("preact").JSX.Element;
|