@bonniernews/dn-design-system-web 14.0.5-beta.0 → 14.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 +9 -1
- package/components/group-header/README.md +1 -1
- package/components/group-header/group-header.njk +4 -1
- package/components/group-header/group-header.scss +13 -0
- package/components/tag-header/tag-header.scss +4 -4
- package/components/teaser-footer/teaser-footer.scss +2 -2
- package/components/teaser-large/teaser-large.scss +3 -3
- package/components/teaser-split/teaser-split.scss +1 -1
- package/components/teaser-standard/teaser-standard.scss +2 -2
- package/components/tooltip/README.md +51 -0
- package/components/tooltip/tooltip.js +48 -0
- package/components/tooltip/tooltip.njk +38 -0
- package/components/tooltip/tooltip.scss +63 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,12 +4,20 @@ All changes to @bonniernews/dn-design-system-web will be documented in this file
|
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
## [14.
|
|
7
|
+
## [14.2.0](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@14.1.0...@bonniernews/dn-design-system-web@14.2.0) (2024-03-12)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* **web:** tooltip ([#1210](https://github.com/BonnierNews/dn-design-system/issues/1210)) ([0f68d20](https://github.com/BonnierNews/dn-design-system/commit/0f68d20d9d950b42af3931f33b61d6d7260dec7d))
|
|
13
|
+
|
|
14
|
+
## [14.1.0](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@14.0.4...@bonniernews/dn-design-system-web@14.1.0) (2024-03-11)
|
|
8
15
|
|
|
9
16
|
|
|
10
17
|
### Features
|
|
11
18
|
|
|
12
19
|
* **app:** create ImageListItem and add font weight prop to all list items ([#1234](https://github.com/BonnierNews/dn-design-system/issues/1234)) ([73e06e9](https://github.com/BonnierNews/dn-design-system/commit/73e06e9df30f2bdb1677dd4bde015ddea9ddb185))
|
|
20
|
+
* **web:** support for images in group header ([#1235](https://github.com/BonnierNews/dn-design-system/issues/1235)) ([f4148dc](https://github.com/BonnierNews/dn-design-system/commit/f4148dc90b104326cd53e72f930510393bb533a6))
|
|
13
21
|
|
|
14
22
|
|
|
15
23
|
### Maintenance
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|parameter | type | required | options | default | description |
|
|
12
12
|
|:--- | :--- | :--- | :--- | :--- | :--- |
|
|
13
13
|
|title | string | yes | | | The title text |
|
|
14
|
-
|variant | string | no | icon, link, toggle, arrows | icon | The variant to render |
|
|
14
|
+
|variant | string | no | icon, link, toggle, arrows, image, bauta, bauataxl, image | 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 variants `link` and `direkt`) |
|
|
17
17
|
|showBottomBorder | boolean | no | | | If true there will be a bottom border |
|
|
@@ -16,7 +16,10 @@
|
|
|
16
16
|
] | join(" ") %}
|
|
17
17
|
|
|
18
18
|
{% set groupHeaderInner %}
|
|
19
|
-
|
|
19
|
+
{% if params.variant == 'image' %}
|
|
20
|
+
<div class="{{ componentClassName + '__image'}}">{{ params.mediaHtml }}</div>
|
|
21
|
+
{% endif %}
|
|
22
|
+
<h2 class="{{ componentClassName + '__title'}}">{{ params.title }}</h2>
|
|
20
23
|
|
|
21
24
|
{% if params.variant == 'link' and params.linkText and params.href %}
|
|
22
25
|
<span class="{{ componentClassName + '__right-link' }}">
|
|
@@ -112,4 +112,17 @@
|
|
|
112
112
|
&--bautaxl .ds-group-header__title {
|
|
113
113
|
@include ds-typography($ds-typography-detailbaota-xl-label);
|
|
114
114
|
}
|
|
115
|
+
|
|
116
|
+
.ds-group-header__image {
|
|
117
|
+
margin-left: ds-spacing($ds-s-100);
|
|
118
|
+
max-height: 24px;
|
|
119
|
+
|
|
120
|
+
figure {
|
|
121
|
+
margin: 0;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
+ .ds-group-header__title {
|
|
125
|
+
padding-left: ds-spacing($ds-s-075);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
115
128
|
}
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
.ds-tag-header__vignette {
|
|
36
|
-
@include ds-typography($ds-typography-
|
|
36
|
+
@include ds-typography($ds-typography-functional-meta02bold);
|
|
37
37
|
color: $ds-theme-color;
|
|
38
38
|
margin-bottom: ds-spacing($ds-s-025);
|
|
39
39
|
display: block;
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
.ds-tag-header__title {
|
|
47
|
-
@include ds-typography($ds-typography-
|
|
47
|
+
@include ds-typography($ds-typography-functional-heading03bold);
|
|
48
48
|
color: $ds-color-text-primary;
|
|
49
49
|
margin: 0;
|
|
50
50
|
word-break: break-word;
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
.ds-tag-header__description {
|
|
63
|
-
@include ds-typography($ds-typography-
|
|
63
|
+
@include ds-typography($ds-typography-functional-body02regular);
|
|
64
64
|
color: $ds-color-text-primary;
|
|
65
65
|
margin: ds-spacing($ds-s-100 $ds-s-100 0);
|
|
66
66
|
border-top: ds-metrics-border-width(x1) solid $ds-color-border-primary;
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
|
|
73
73
|
b,
|
|
74
74
|
strong {
|
|
75
|
-
@include ds-typography($ds-typography-
|
|
75
|
+
@include ds-typography($ds-typography-functional-body02semibold);
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
p {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
.ds-teaser-footer__notes {
|
|
12
|
-
@include ds-typography($ds-typography-
|
|
12
|
+
@include ds-typography($ds-typography-functional-meta02regular);
|
|
13
13
|
display: block;
|
|
14
14
|
color: $ds-color-text-primary-02;
|
|
15
15
|
}
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
margin-top: ds-spacing($ds-s-050);
|
|
22
22
|
|
|
23
23
|
.ds-teaser-footer__title {
|
|
24
|
-
@include ds-typography($ds-typography-
|
|
24
|
+
@include ds-typography($ds-typography-functional-body01semibold);
|
|
25
25
|
color: $ds-color-text-primary;
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
.ds-teaser__title {
|
|
36
|
-
@include ds-typography($ds-typography-
|
|
36
|
+
@include ds-typography($ds-typography-expressive-heading04bold);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
@include ds-hover(true) {
|
|
@@ -44,13 +44,13 @@
|
|
|
44
44
|
|
|
45
45
|
&.ds-teaser--large-big-italic {
|
|
46
46
|
.ds-teaser__title {
|
|
47
|
-
@include ds-typography($ds-typography-
|
|
47
|
+
@include ds-typography($ds-typography-expressive-heading04italicregular);
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
&.ds-teaser--large-italic {
|
|
52
52
|
.ds-teaser__title {
|
|
53
|
-
@include ds-typography($ds-typography-
|
|
53
|
+
@include ds-typography($ds-typography-expressive-heading03italicregular);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
@include ds-hover(true) {
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
overflow: hidden;
|
|
8
8
|
|
|
9
9
|
.ds-teaser__title {
|
|
10
|
-
@include ds-typography($ds-typography-
|
|
10
|
+
@include ds-typography($ds-typography-expressive-heading03bold);
|
|
11
11
|
|
|
12
12
|
&--italic {
|
|
13
|
-
@include ds-typography($ds-typography-
|
|
13
|
+
@include ds-typography($ds-typography-expressive-heading03italicregular);
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
- GitHub: [BonnierNews/dn-design-system/../web/src/components/tooltip](https://github.com/BonnierNews/dn-design-system/tree/main/web/src/components/tooltip)
|
|
2
|
+
- Storybook: [Tooltip](https://designsystem.dn.se/?path=/docs/basic-tooltip--docs)
|
|
3
|
+
- Storybook (Latest): [Tooltip](https://designsystem-latest.dn.se/?path=/docs/basic-tooltip--docs)
|
|
4
|
+
|
|
5
|
+
----
|
|
6
|
+
|
|
7
|
+
# Tooltip
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
## Parameters
|
|
11
|
+
|
|
12
|
+
|parameter | type | required | options | default | description |
|
|
13
|
+
|:--- | :--- | :--- | :--- | :--- | :--- |
|
|
14
|
+
| arrowPosition | String | yes | "top" or "bottom" | | Position of tooltip arrow |
|
|
15
|
+
| title | String | no | | | Title in tooltip |
|
|
16
|
+
| closeButton | bool | no | true, false | false | Render close button if true |
|
|
17
|
+
| closeOnClickOutside | bool | no | true, false | false | Set to true to be able to close tooltip when clicking outside of it |
|
|
18
|
+
| forceOpen | bool | no | true, false | false | Show tooltip on render |
|
|
19
|
+
| classNames | String | no | | | Ex. "my-special-class" |
|
|
20
|
+
| attributes | Object | no | | | Ex. { data-prop: value } |
|
|
21
|
+
| forcePx | bool | no | true, false | false | Fixed pixel value is used for typography to prevent scaling based on html font-size
|
|
22
|
+
|
|
23
|
+
## Minimum requirement example
|
|
24
|
+
|
|
25
|
+
These are copy paste friendly examples to quickliy get started using a component.
|
|
26
|
+
|
|
27
|
+
### Nunjucks
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
{% from '@bonniernews/dn-design-system-web/components/tooltip/tooltip.njk' import Tooltip %}
|
|
31
|
+
|
|
32
|
+
{% call Tooltip({closeButton: true, closeOnClickOutside: false, arrowPosition: "top"}) %}
|
|
33
|
+
<h2>Titel</h2>
|
|
34
|
+
<p>Text i vår tooltip</p>
|
|
35
|
+
{% endcall %}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Scss
|
|
39
|
+
|
|
40
|
+
```scss
|
|
41
|
+
@use "@bonniernews/dn-design-system-web/components/tooltip/tooltip";
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Javascript
|
|
45
|
+
|
|
46
|
+
```javascript
|
|
47
|
+
import { initTooltip, openTooltip } from '@bonniernews/dn-design-system-web/components/tooltip/tooltip.js'
|
|
48
|
+
const tooltipEl = document.querySelector(".ds-tooltip");
|
|
49
|
+
initTooltip(tooltipEl);
|
|
50
|
+
openTooltip(tooltipEl);
|
|
51
|
+
```
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export {
|
|
2
|
+
initTooltip,
|
|
3
|
+
openTooltip,
|
|
4
|
+
initTooltipStorybook
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
let setupTooltipClickListener = true;
|
|
8
|
+
|
|
9
|
+
function initTooltip(tooltipEl) {
|
|
10
|
+
const tooltipsClosingOnOutsideClick = document.getElementsByClassName("ds-tooltip--close-outside-click");
|
|
11
|
+
|
|
12
|
+
if (setupTooltipClickListener && tooltipsClosingOnOutsideClick.length > 0) {
|
|
13
|
+
setupTooltipClickListener = false;
|
|
14
|
+
|
|
15
|
+
document.addEventListener("click", (e) => {
|
|
16
|
+
const tooltipClick = e.target.closest(".ds-tooltip");
|
|
17
|
+
if (tooltipClick) return;
|
|
18
|
+
|
|
19
|
+
const tooltipsToClose = document.getElementsByClassName('ds-tooltip--close-outside-click');
|
|
20
|
+
for (const tooltip of tooltipsToClose) {
|
|
21
|
+
closeTooltip(tooltip)
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const closeButtons = Array.from(tooltipEl.getElementsByClassName("ds-tooltip__close"));
|
|
27
|
+
closeButtons.forEach((button) => {
|
|
28
|
+
button.addEventListener("click", () => {
|
|
29
|
+
closeTooltip(tooltipEl);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function openTooltip(tooltipEl) {
|
|
35
|
+
tooltipEl.classList.remove("ds-tooltip--hidden");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function closeTooltip(tooltipEl) {
|
|
39
|
+
tooltipEl.classList.add("ds-tooltip--hidden");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function initTooltipStorybook() {
|
|
43
|
+
const tooltips = Array.from(document.getElementsByClassName("ds-tooltip"));
|
|
44
|
+
tooltips.forEach((tooltipEl) => {
|
|
45
|
+
initTooltip(tooltipEl);
|
|
46
|
+
openTooltip(tooltipEl);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{% from '@bonniernews/dn-design-system-web/components/icon-sprite/icon-sprite.njk' import IconUse %}
|
|
2
|
+
{% from '@bonniernews/dn-design-system-web/components/button/button.njk' import Button %}
|
|
3
|
+
{% from '@bonniernews/dn-design-system-web/components/icon-button/icon-button.njk' import IconButton %}
|
|
4
|
+
{% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
|
|
5
|
+
|
|
6
|
+
{% macro Tooltip(params) %}
|
|
7
|
+
{% set componentClassName = "ds-tooltip" %}
|
|
8
|
+
|
|
9
|
+
{%- set classes = [
|
|
10
|
+
componentClassName,
|
|
11
|
+
"ds-force-px" if params.forcePx,
|
|
12
|
+
componentClassName + '--arrow-' + params.arrowPosition,
|
|
13
|
+
componentClassName + '--close-outside-click' if params.closeOnClickOutside,
|
|
14
|
+
componentClassName + '--hidden' if not params.forceOpen,
|
|
15
|
+
params.classNames if params.classNames
|
|
16
|
+
] | join(" ") %}
|
|
17
|
+
{% set attributes = getAttributes(params.attributes) %}
|
|
18
|
+
|
|
19
|
+
<div class="{{ classes }}" {{- attributes | safe }}>
|
|
20
|
+
<div class="{{ componentClassName + '__content' }}">
|
|
21
|
+
{% if params.title %}
|
|
22
|
+
<h2>{{ params.title }}</h2>
|
|
23
|
+
{% endif %}
|
|
24
|
+
|
|
25
|
+
{{ caller() if caller }}
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
{% if params.closeButton %}
|
|
29
|
+
{{ IconButton({
|
|
30
|
+
variant: "transparent",
|
|
31
|
+
size: "small",
|
|
32
|
+
iconName: "close",
|
|
33
|
+
classNames: "ds-tooltip__close",
|
|
34
|
+
attributes: { "aria-label": "Stäng" }
|
|
35
|
+
})}}
|
|
36
|
+
{% endif %}
|
|
37
|
+
</div>
|
|
38
|
+
{% endmacro %}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
@use "../../foundations/helpers/forward.helpers.scss" as *;
|
|
2
|
+
@use "../../foundations/variables/typographyFontWeight.scss";
|
|
3
|
+
@use "../../components/icon-sprite/icon-sprite.scss";
|
|
4
|
+
@use "../../components/button/button.scss";
|
|
5
|
+
@use "../../components/icon-button/icon-button.scss";
|
|
6
|
+
|
|
7
|
+
.ds-tooltip {
|
|
8
|
+
background-color: $ds-color-surface-raised;
|
|
9
|
+
color: $ds-color-text-primary;
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
position: relative;
|
|
12
|
+
padding: ds-spacing($ds-s-100);
|
|
13
|
+
display: flex;
|
|
14
|
+
|
|
15
|
+
.ds-tooltip__close {
|
|
16
|
+
color: $ds-color-icon-primary;
|
|
17
|
+
align-self: center;
|
|
18
|
+
margin-left: ds-spacing($ds-s-100);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
&--hidden {
|
|
22
|
+
display: none;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&.ds-tooltip--arrow-top::after,
|
|
26
|
+
&.ds-tooltip--arrow-bottom::after {
|
|
27
|
+
border-bottom-color: $ds-color-surface-raised;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
&--arrow-top::after {
|
|
31
|
+
content: "";
|
|
32
|
+
position: absolute;
|
|
33
|
+
top: ds-spacing($ds-s-100, "px", true);
|
|
34
|
+
right: ds-spacing($ds-s-100);
|
|
35
|
+
border: 8px solid transparent;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&--arrow-bottom::after {
|
|
39
|
+
content: "";
|
|
40
|
+
position: absolute;
|
|
41
|
+
bottom: ds-spacing($ds-s-100, "px", true);
|
|
42
|
+
left: ds-spacing($ds-s-100);
|
|
43
|
+
border: 8px solid transparent;
|
|
44
|
+
transform: rotate(180deg);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.ds-tooltip__content {
|
|
48
|
+
@include ds-typography($ds-typography-functionalbody01);
|
|
49
|
+
|
|
50
|
+
h2 {
|
|
51
|
+
@include ds-typography($ds-typography-functionalbody02, $fontWeight: $ds-fontweight-semibold);
|
|
52
|
+
margin: 0;
|
|
53
|
+
|
|
54
|
+
+ p {
|
|
55
|
+
margin-top: 0;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
> :last-child {
|
|
60
|
+
margin-bottom: 0;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
package/package.json
CHANGED