@bonniernews/dn-design-system-web 29.0.0 → 29.0.1

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,18 @@ All changes to @bonniernews/dn-design-system-web will be documented in this file
4
4
 
5
5
 
6
6
 
7
+ ## [29.0.1](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@29.0.0...@bonniernews/dn-design-system-web@29.0.1) (2025-02-17)
8
+
9
+
10
+ ### Bug Fixes
11
+
12
+ * **web:** button href aria-label fallback ([#1616](https://github.com/BonnierNews/dn-design-system/issues/1616)) ([0643b5e](https://github.com/BonnierNews/dn-design-system/commit/0643b5ebfbf5c802e2908808aa360698805d2824))
13
+
14
+
15
+ ### Maintenance
16
+
17
+ * **web:** update documentation about rerunning failed tests ([#1615](https://github.com/BonnierNews/dn-design-system/issues/1615)) ([9206d7f](https://github.com/BonnierNews/dn-design-system/commit/9206d7fe1e2a9d171c4472167e31a709bb4a7406))
18
+
7
19
  ## [29.0.0](https://github.com/BonnierNews/dn-design-system/compare/@bonniernews/dn-design-system-web@28.0.1...@bonniernews/dn-design-system-web@29.0.0) (2025-02-12)
8
20
 
9
21
 
@@ -31,7 +31,6 @@ export interface ButtonBaseProps extends ButtonSharedProps {
31
31
  type?: 'button' | 'submit'
32
32
  /** If href is set the button will be rendered as an a-tag */
33
33
  href?: string
34
- a11y?: AllyProps
35
34
  selected?: boolean
36
35
  isToggle?: boolean
37
36
  selectedIconName?: DsIcon
@@ -42,7 +41,6 @@ export interface InnerButtonProps {
42
41
  text?: string
43
42
  isIconButton?: boolean
44
43
  attributes?: object | any
45
- a11y?: AllyProps
46
44
  icon?: any
47
45
  loadingHtml?: any
48
46
  }
@@ -1,13 +1,12 @@
1
1
  {% from '@bonniernews/dn-design-system-web/components/icon-sprite/icon-sprite.njk' import IconUse %}
2
2
  {% from '@bonniernews/dn-design-system-web/components/spinner/spinner.njk' import Spinner %}
3
3
  {% from '@bonniernews/dn-design-system-web/njk-helpers/attributes.njk' import getAttributes %}
4
- {% from '@bonniernews/dn-design-system-web/foundations/a11y/visually-hidden.njk' import VisuallyHidden %}
5
4
 
6
5
  {% macro InnerButton(params) %}
7
- {% if not params.isIconButton %}
6
+ {% if not params.isIconButton and params.attributes["aria-label"] %}
8
7
  <span aria-hidden="true">{{ params.text }}</span>
9
- {% elif not params.attributes["aria-label"] and params.a11y and params.a11y.visuallyHidden %}
10
- {{- VisuallyHidden({ text: params.a11y.visuallyHidden }) | safe -}}
8
+ {% elif not params.isIconButton %}
9
+ <span>{{ params.text }}</span>
11
10
  {% endif %}
12
11
  {{- params.iconSvg | safe if params.iconSvg -}} {{ params.loadingHtml | safe }}
13
12
  {% endmacro %}
@@ -24,7 +23,7 @@
24
23
  {%- set classNamePrefix = componentClassName + "--" %}
25
24
  {%- set text = params.text %}
26
25
  {%- set attributes = getAttributes(params.attributes) %}
27
- {%- set ariaLabel = 'aria-label="' + text + '"' if params.text and not params.attributes["aria-label"] else "" %}
26
+ {%- set ariaLabel = 'aria-label="' + text + '"' if (params.isIconButton or params.isToggle) and params.text and not params.attributes["aria-label"] else "" %}
28
27
  {%- set buttonVariant = params.variant | default("primary") %}
29
28
 
30
29
  {% if params.variant == "staticWhite" or params.variant == "transparent" %}
@@ -75,7 +74,7 @@
75
74
  {% if params.href %}
76
75
  {% set loadingHtml = null %}
77
76
  {% endif %}
78
- {% set buttonParams = { isIconButton: params.isIconButton, a11y: params.a11y, text: text, iconSvg: iconSvg, loadingHtml: loadingHtml , attributes: params.attributes } %}
77
+ {% set buttonParams = { isIconButton: params.isIconButton, text: text, iconSvg: iconSvg, loadingHtml: loadingHtml , attributes: params.attributes } %}
79
78
  {%- if params.href %}
80
79
  <a href="{{ params.href | default('#', true) }}" {{ ariaLabel | safe }} class="{{ classes }}" {{- attributes | safe }}>
81
80
  {{ InnerButton(buttonParams) }}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonniernews/dn-design-system-web",
3
- "version": "29.0.0",
3
+ "version": "29.0.1",
4
4
  "description": "DN design system for web.",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/BonnierNews/dn-design-system/tree/main/web/src#readme",
@@ -34,20 +34,14 @@ var Spinner = ({ variant = "primary", size = "large", forcePx, classNames, attri
34
34
  return /* @__PURE__ */ jsx3("span", { className: classes, ...attributes, children: /* @__PURE__ */ jsx3("span", { className: `${componentClassName}__inner` }) });
35
35
  };
36
36
 
37
- // ../src/foundations/a11y/visually-hidden.tsx
38
- import { jsx as jsx4 } from "preact/jsx-runtime";
39
- var VisuallyHidden = ({ text }) => {
40
- return /* @__PURE__ */ jsx4("span", { className: "visually-hidden", dangerouslySetInnerHTML: { __html: text } });
41
- };
42
-
43
37
  // ../src/components/button/button-base.tsx
44
- import { Fragment, jsx as jsx5, jsxs as jsxs2 } from "preact/jsx-runtime";
45
- var InnerButton = ({ text, isIconButton = false, attributes, a11y, icon, loadingHtml }) => {
38
+ import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "preact/jsx-runtime";
39
+ var InnerButton = ({ text, isIconButton = false, attributes, icon, loadingHtml }) => {
46
40
  let optionalHtml;
47
- if (!isIconButton) {
48
- optionalHtml = /* @__PURE__ */ jsx5("span", { "aria-hidden": "true", children: text });
49
- } else if (!attributes["aria-label"] && a11y?.visuallyHidden) {
50
- optionalHtml = /* @__PURE__ */ jsx5(VisuallyHidden, { text: a11y.visuallyHidden });
41
+ if (!isIconButton && attributes["aria-label"]) {
42
+ optionalHtml = /* @__PURE__ */ jsx4("span", { "aria-hidden": "true", children: text });
43
+ } else if (!isIconButton) {
44
+ optionalHtml = /* @__PURE__ */ jsx4("span", { children: text });
51
45
  }
52
46
  return /* @__PURE__ */ jsxs2(Fragment, { children: [
53
47
  optionalHtml,
@@ -65,8 +59,8 @@ var ToggleWrapper = ({
65
59
  loadingHtml
66
60
  }) => {
67
61
  return /* @__PURE__ */ jsxs2("button", { type: "button", role: "switch", "aria-checked": selected, className: classes, ...attributes, disabled, children: [
68
- /* @__PURE__ */ jsx5("span", { className: "ds-btn__off", "aria-hidden": "true", children: onChild }),
69
- /* @__PURE__ */ jsx5("span", { className: "ds-btn__on", "aria-hidden": "true", children: offChild }),
62
+ /* @__PURE__ */ jsx4("span", { className: "ds-btn__off", "aria-hidden": "true", children: onChild }),
63
+ /* @__PURE__ */ jsx4("span", { className: "ds-btn__on", "aria-hidden": "true", children: offChild }),
70
64
  loadingHtml
71
65
  ] });
72
66
  };
@@ -86,13 +80,12 @@ var ButtonBase = ({
86
80
  attributes = {},
87
81
  forcePx = false,
88
82
  isIconButton = false,
89
- a11y = {},
90
83
  selected = false,
91
84
  isToggle = false,
92
85
  selectedIconName,
93
86
  selectedText
94
87
  }) => {
95
- if (text && !href && !attributes["aria-label"]) {
88
+ if (isIconButton && text && !attributes["aria-label"]) {
96
89
  attributes["aria-label"] = text;
97
90
  }
98
91
  let spinnerVariant = "secondary";
@@ -101,10 +94,10 @@ var ButtonBase = ({
101
94
  } else if (variant === "secondaryFilled" || variant === "secondaryOutline") {
102
95
  spinnerVariant = "primary";
103
96
  }
104
- const loadingHtml = /* @__PURE__ */ jsx5(Spinner, { ...{ size: "small", variant: spinnerVariant, forcePx, attributes: { "aria-hidden": "true" } } });
97
+ const loadingHtml = /* @__PURE__ */ jsx4(Spinner, { ...{ size: "small", variant: spinnerVariant, forcePx, attributes: { "aria-hidden": "true" } } });
105
98
  let icon;
106
99
  if (iconName && (iconPosition != "none" || isIconButton == true)) {
107
- icon = /* @__PURE__ */ jsx5(IconUse, { ...{ iconName, attributes: { "aria-hidden": "true" } } });
100
+ icon = /* @__PURE__ */ jsx4(IconUse, { ...{ iconName, attributes: { "aria-hidden": "true" } } });
108
101
  }
109
102
  const classNamePrefix = "ds-btn--";
110
103
  const classes = formatClassString([
@@ -125,30 +118,30 @@ var ButtonBase = ({
125
118
  if (isToggle) {
126
119
  let onChild, offChild;
127
120
  if (isIconButton && iconName && selectedIconName) {
128
- onChild = /* @__PURE__ */ jsx5(IconUse, { iconName });
129
- offChild = /* @__PURE__ */ jsx5(IconUse, { iconName: selectedIconName });
121
+ onChild = /* @__PURE__ */ jsx4(IconUse, { iconName });
122
+ offChild = /* @__PURE__ */ jsx4(IconUse, { iconName: selectedIconName });
130
123
  } else {
131
- onChild = /* @__PURE__ */ jsx5("span", { children: text });
124
+ onChild = /* @__PURE__ */ jsx4("span", { children: text });
132
125
  offChild = /* @__PURE__ */ jsxs2(Fragment, { children: [
133
- /* @__PURE__ */ jsx5(IconUse, { iconName: "check" }),
134
- /* @__PURE__ */ jsx5("span", { children: selectedText })
126
+ /* @__PURE__ */ jsx4(IconUse, { iconName: "check" }),
127
+ /* @__PURE__ */ jsx4("span", { children: selectedText })
135
128
  ] });
136
129
  }
137
- buttonToRender = /* @__PURE__ */ jsx5(ToggleWrapper, { ...{ selected, classes, attributes, disabled, onChild, offChild, loadingHtml } });
130
+ buttonToRender = /* @__PURE__ */ jsx4(ToggleWrapper, { ...{ selected, classes, attributes, disabled, onChild, offChild, loadingHtml } });
138
131
  } else {
139
- const buttonParams = { isIconButton, a11y, text, icon, loadingHtml, attributes };
132
+ const buttonParams = { isIconButton, text, icon, loadingHtml, attributes };
140
133
  if (href) {
141
134
  const params = { ...buttonParams, loadingHtml: null };
142
- buttonToRender = /* @__PURE__ */ jsx5("a", { href, className: classes, ...attributes, children: /* @__PURE__ */ jsx5(InnerButton, { ...params }) });
135
+ buttonToRender = /* @__PURE__ */ jsx4("a", { href, className: classes, ...attributes, children: /* @__PURE__ */ jsx4(InnerButton, { ...params }) });
143
136
  } else {
144
- buttonToRender = /* @__PURE__ */ jsx5("button", { type, className: classes, ...attributes, disabled, children: /* @__PURE__ */ jsx5(InnerButton, { ...buttonParams }) });
137
+ buttonToRender = /* @__PURE__ */ jsx4("button", { type, className: classes, ...attributes, disabled, children: /* @__PURE__ */ jsx4(InnerButton, { ...buttonParams }) });
145
138
  }
146
139
  }
147
- return /* @__PURE__ */ jsx5(Fragment, { children: buttonToRender });
140
+ return /* @__PURE__ */ jsx4(Fragment, { children: buttonToRender });
148
141
  };
149
142
 
150
143
  // ../src/components/button/button.tsx
151
- import { jsx as jsx6 } from "preact/jsx-runtime";
144
+ import { jsx as jsx5 } from "preact/jsx-runtime";
152
145
  var Button = ({
153
146
  text,
154
147
  disabled = false,
@@ -166,7 +159,7 @@ var Button = ({
166
159
  attributes,
167
160
  forcePx = false
168
161
  }) => {
169
- return /* @__PURE__ */ jsx6(ButtonBase, { ...{
162
+ return /* @__PURE__ */ jsx5(ButtonBase, { ...{
170
163
  text,
171
164
  disabled,
172
165
  variant,
@@ -186,7 +179,7 @@ var Button = ({
186
179
  };
187
180
 
188
181
  // ../src/components/buddy-menu/buddy-menu.tsx
189
- import { jsx as jsx7, jsxs as jsxs3 } from "preact/jsx-runtime";
182
+ import { jsx as jsx6, jsxs as jsxs3 } from "preact/jsx-runtime";
190
183
  var BuddyMenu = ({
191
184
  userName,
192
185
  links,
@@ -201,8 +194,8 @@ var BuddyMenu = ({
201
194
  }) => {
202
195
  const componentClassName = "ds-buddy-menu";
203
196
  const classes = formatClassString([componentClassName, forcePx && "ds-force-px", classNames]);
204
- return /* @__PURE__ */ jsx7("div", { class: `${classes} ${isDnSkola && "ds-buddy-menu--skola"}`, ...attributes, children: /* @__PURE__ */ jsx7("div", { class: `${componentClassName}__inner`, children: /* @__PURE__ */ jsx7("div", { class: "ds-buddy-menu__scrollable-container", children: /* @__PURE__ */ jsxs3("div", { class: "ds-buddy-menu__content", children: [
205
- /* @__PURE__ */ jsx7(
197
+ return /* @__PURE__ */ jsx6("div", { class: `${classes} ${isDnSkola && "ds-buddy-menu--skola"}`, ...attributes, children: /* @__PURE__ */ jsx6("div", { class: `${componentClassName}__inner`, children: /* @__PURE__ */ jsx6("div", { class: "ds-buddy-menu__scrollable-container", children: /* @__PURE__ */ jsxs3("div", { class: "ds-buddy-menu__content", children: [
198
+ /* @__PURE__ */ jsx6(
206
199
  Button,
207
200
  {
208
201
  ...{
@@ -219,17 +212,17 @@ var BuddyMenu = ({
219
212
  /* @__PURE__ */ jsxs3("span", { class: "ds-buddy-menu__greeting", children: [
220
213
  "Hej",
221
214
  " ",
222
- /* @__PURE__ */ jsx7("span", { class: "ds-buddy-menu__name js-buddy-menu-name", "data-name-type": "given", children: userName }),
215
+ /* @__PURE__ */ jsx6("span", { class: "ds-buddy-menu__name js-buddy-menu-name", "data-name-type": "given", children: userName }),
223
216
  "!"
224
217
  ] }),
225
218
  !isDnSkola && /* @__PURE__ */ jsxs3("div", { class: "ds-buddy-menu__account", children: [
226
- /* @__PURE__ */ jsx7("h2", { class: "ds-buddy-menu__account-title", children: "Min prenumeration" }),
227
- /* @__PURE__ */ jsx7("span", { class: "ds-buddy-menu__account-level js-buddy-menu__account-level", children: accountLevel }),
219
+ /* @__PURE__ */ jsx6("h2", { class: "ds-buddy-menu__account-title", children: "Min prenumeration" }),
220
+ /* @__PURE__ */ jsx6("span", { class: "ds-buddy-menu__account-level js-buddy-menu__account-level", children: accountLevel }),
228
221
  addons && /* @__PURE__ */ jsxs3("div", { class: `ds-buddy-menu__addons ${addonsClassNames}`, children: [
229
- /* @__PURE__ */ jsx7("h2", { class: "ds-buddy-menu__addons-title", children: "Mina till\xE4gg" }),
230
- /* @__PURE__ */ jsx7("ul", { class: "ds-buddy-menu__addons-list", children: addons.map((addon) => /* @__PURE__ */ jsx7("li", { class: addon.classNames, children: /* @__PURE__ */ jsx7("a", { href: addon.href, children: addon.title }) })) })
222
+ /* @__PURE__ */ jsx6("h2", { class: "ds-buddy-menu__addons-title", children: "Mina till\xE4gg" }),
223
+ /* @__PURE__ */ jsx6("ul", { class: "ds-buddy-menu__addons-list", children: addons.map((addon) => /* @__PURE__ */ jsx6("li", { class: addon.classNames, children: /* @__PURE__ */ jsx6("a", { href: addon.href, children: addon.title }) })) })
231
224
  ] }),
232
- /* @__PURE__ */ jsx7(
225
+ /* @__PURE__ */ jsx6(
233
226
  Button,
234
227
  {
235
228
  ...{
@@ -246,8 +239,8 @@ var BuddyMenu = ({
246
239
  ] })
247
240
  ] }),
248
241
  /* @__PURE__ */ jsxs3("div", { class: "ds-buddy-menu__links", children: [
249
- /* @__PURE__ */ jsx7("h2", { class: "ds-buddy-menu__links-title", children: "Mitt inneh\xE5ll" }),
250
- /* @__PURE__ */ jsx7("ul", { class: "ds-buddy-menu__links-list", children: links })
242
+ /* @__PURE__ */ jsx6("h2", { class: "ds-buddy-menu__links-title", children: "Mitt inneh\xE5ll" }),
243
+ /* @__PURE__ */ jsx6("ul", { class: "ds-buddy-menu__links-list", children: links })
251
244
  ] })
252
245
  ] }) }) }) });
253
246
  };