@qld-gov-au/qgds-bootstrap5 1.0.13 → 1.0.14

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 (65) hide show
  1. package/.storybook/main.js +1 -1
  2. package/.storybook/preview.js +8 -0
  3. package/README.md +96 -46
  4. package/dist/assets/css/qld.bootstrap.css +1 -1
  5. package/dist/assets/css/qld.bootstrap.css.map +3 -3
  6. package/dist/assets/js/handlebars.helpers.bundle.js +1 -1
  7. package/dist/assets/js/handlebars.helpers.bundle.js.map +3 -3
  8. package/dist/assets/js/handlebars.helpers.js +4 -8
  9. package/dist/assets/js/qld.bootstrap.min.js +9 -9
  10. package/dist/assets/js/qld.bootstrap.min.js.map +4 -4
  11. package/dist/components/bs5/breadcrumbs/breadcrumbs.hbs +1 -1
  12. package/dist/components/bs5/button/button.hbs +30 -9
  13. package/dist/components/bs5/header/header.hbs +15 -17
  14. package/dist/components/bs5/navbar/navbar.hbs +1 -1
  15. package/dist/components/bs5/quickexit/quickexit.hbs +28 -20
  16. package/dist/components/bs5/searchInput/searchInput.hbs +9 -3
  17. package/dist/components/handlebars.helpers.js +4 -8
  18. package/dist/components/handlebars.init.bundle.js +1 -1
  19. package/dist/components/handlebars.init.bundle.js.map +3 -3
  20. package/dist/sample-data/button/button.data.json +2 -1
  21. package/dist/sample-data/header/header.data.json +134 -75
  22. package/dist/sample-data/navbar/navbar.data.json +8 -8
  23. package/dist/sample-data/quickexit/quickexit.data.json +8 -1
  24. package/dist/sample-data/searchInput/searchInput.data.json +10 -1
  25. package/package.json +20 -19
  26. package/src/components/bs5/breadcrumbs/breadcrumb.functions.js +71 -32
  27. package/src/components/bs5/breadcrumbs/breadcrumbs.hbs +1 -1
  28. package/src/components/bs5/button/button.data.json +2 -1
  29. package/src/components/bs5/button/button.hbs +30 -9
  30. package/src/components/bs5/button/button.scss +87 -44
  31. package/src/components/bs5/button/button.stories.js +121 -27
  32. package/src/components/bs5/callout/callout.scss +1 -1
  33. package/src/components/bs5/header/_colours.scss +0 -52
  34. package/src/components/bs5/header/header.data.json +134 -75
  35. package/src/components/bs5/header/header.functions.js +1 -180
  36. package/src/components/bs5/header/header.hbs +15 -17
  37. package/src/components/bs5/header/header.scss +7 -156
  38. package/src/components/bs5/header/header.stories.js +10 -50
  39. package/src/components/bs5/modal/modal.scss +54 -35
  40. package/src/components/bs5/modal/modal.stories.js +2 -2
  41. package/src/components/bs5/navbar/_colours.scss +46 -82
  42. package/src/components/bs5/navbar/navbar.data.json +8 -8
  43. package/src/components/bs5/navbar/navbar.hbs +1 -1
  44. package/src/components/bs5/navbar/navbar.scss +15 -6
  45. package/src/components/bs5/quickexit/_colours.scss +28 -0
  46. package/src/components/bs5/quickexit/quickexit.data.json +8 -1
  47. package/src/components/bs5/quickexit/quickexit.hbs +28 -20
  48. package/src/components/bs5/quickexit/quickexit.scss +236 -156
  49. package/src/components/bs5/quickexit/quickexit.stories.js +35 -13
  50. package/src/components/bs5/searchInput/_colours.scss +63 -0
  51. package/src/components/bs5/searchInput/search.functions.js +170 -0
  52. package/src/components/bs5/searchInput/searchInput.data.json +10 -1
  53. package/src/components/bs5/searchInput/searchInput.hbs +9 -3
  54. package/src/components/bs5/searchInput/searchInput.scss +122 -21
  55. package/src/components/bs5/searchInput/searchInput.stories.js +1 -1
  56. package/src/components/bs5/tag/tag.scss +4 -2
  57. package/src/js/handlebars.helpers.js +4 -8
  58. package/src/main.js +24 -7
  59. package/src/main.scss +6 -3
  60. package/src/scss/qld-print.scss +365 -0
  61. package/src/scss/qld-variables.scss +87 -101
  62. package/src/components/common/header/Header.js +0 -11
  63. package/src/components/common/header/header.html +0 -259
  64. package/src/components/common/header/header.scss +0 -118
  65. /package/src/components/bs5/{header/_search.json → searchInput/search.json} +0 -0
@@ -3,7 +3,8 @@
3
3
  "islink": true,
4
4
  "isdisabled": false,
5
5
  "iconClass": "fa-solid fa-arrow-up-right-from-square",
6
- "href": "https://google.com",
6
+ "iconPosition": "leading",
7
7
  "label": "Call to action",
8
+ "href": "https://google.com",
8
9
  "target": "_blank"
9
10
  }
@@ -4,7 +4,8 @@
4
4
  "icons": {
5
5
  "menu-icon": "qld__icon__mobile-menu",
6
6
  "search-icon": "qld__icon__search",
7
- "close-icon": "qld__icon__close"
7
+ "close-icon": "qld__icon__close",
8
+ "chevron_down": "qld__icon__chevron-down"
8
9
  },
9
10
  "sitePreHeader": {
10
11
  "url": {
@@ -19,9 +20,6 @@
19
20
  "url": {
20
21
  "value": "#"
21
22
  },
22
- "icon": {
23
- "value": "ctaIcon"
24
- },
25
23
  "text": {
26
24
  "value": "For Queenslanders"
27
25
  },
@@ -77,9 +75,6 @@
77
75
  "url": {
78
76
  "value": "#"
79
77
  },
80
- "icon": {
81
- "value": "ctaIcon"
82
- },
83
78
  "text": {
84
79
  "value": "Business and Industry"
85
80
  },
@@ -135,9 +130,6 @@
135
130
  "url": {
136
131
  "value": "#"
137
132
  },
138
- "icon": {
139
- "value": "ctaIcon"
140
- },
141
133
  "text": {
142
134
  "value": "Login"
143
135
  },
@@ -194,7 +186,8 @@
194
186
  "icons": {
195
187
  "menu-icon": "qld__icon__mobile-menu",
196
188
  "search-icon": "qld__icon__search",
197
- "close-icon": "qld__icon__close"
189
+ "close-icon": "qld__icon__close",
190
+ "chevron_down": "qld__icon__chevron-down"
198
191
  },
199
192
  "sitePreHeader": {
200
193
  "url": {
@@ -203,48 +196,134 @@
203
196
  "text": {
204
197
  "value": "Queensland Government websites"
205
198
  },
206
- "mainNavCtaOne": {
207
- "value": "#",
208
- "icon": {
209
- "value": "#"
210
- },
211
- "text": {
212
- "value": "List 1"
213
- },
214
- "dropdown_enabled": true,
215
- "dropdown_options": {
216
- "dropdown_type": "list"
217
- }
218
- },
219
- "mainNavCtaTwo": {
220
- "value": "#",
221
- "icon": {
222
- "value": "#"
223
- },
224
- "text": {
225
- "value": "List 2"
226
- },
227
- "dropdown_enabled": true,
228
- "dropdown_options": {
229
- "dropdown_type": "list"
230
- }
231
- },
232
- "mainNavCtaThree": {
233
- "value": "#",
234
- "icon": {
235
- "value": "ctaIcon"
199
+ "CTA": [
200
+ {
201
+ "id": "CTAone",
202
+ "url": {
203
+ "value": "#"
204
+ },
205
+ "text": {
206
+ "value": "For Queenslanders"
207
+ },
208
+ "dropdown_enabled": true,
209
+ "dropdown_options": {
210
+ "dropdown_type": "list",
211
+ "view_more_label": "Browse all information and services",
212
+ "view_more_url": "https://www.qld.gov.au/queenslanders",
213
+ "dropdown_config": {
214
+ "groups": [
215
+ {
216
+ "action": "_blank",
217
+ "url": "#",
218
+ "label": "Transport and motoring"
219
+ },
220
+ {
221
+ "action": "_blank",
222
+ "url": "#",
223
+ "label": "Employment and jobs"
224
+ },
225
+ {
226
+ "action": "_blank",
227
+ "url": "#",
228
+ "label": "Education and training"
229
+ },
230
+ {
231
+ "action": "_blank",
232
+ "url": "#",
233
+ "label": "Queensland and its government"
234
+ },
235
+ {
236
+ "action": "_blank",
237
+ "url": "#",
238
+ "label": "Health and wellbeing"
239
+ },
240
+ {
241
+ "action": "_blank",
242
+ "url": "#",
243
+ "label": "Community support"
244
+ }
245
+ ],
246
+ "view_more": true,
247
+ "view_more_options": {
248
+ "url": "#",
249
+ "label": "View more",
250
+ "target": "_blank"
251
+ }
252
+ }
253
+ }
236
254
  },
237
- "text": {
238
- "value": "Login"
255
+ {
256
+ "id": "CTAtwo",
257
+ "url": {
258
+ "value": "#"
259
+ },
260
+ "text": {
261
+ "value": "Business and Industry"
262
+ },
263
+ "dropdown_enabled": true,
264
+ "dropdown_options": {
265
+ "dropdown_type": "list",
266
+ "view_more_label": "All categories",
267
+ "view_more_url": "https://www.business.qld.gov.au/",
268
+ "dropdown_config": {
269
+ "groups": [
270
+ {
271
+ "action": "_blank",
272
+ "url": "#",
273
+ "label": "Starting a business"
274
+ },
275
+ {
276
+ "action": "_blank",
277
+ "url": "#",
278
+ "label": "Running a business"
279
+ },
280
+ {
281
+ "action": "_blank",
282
+ "url": "#",
283
+ "label": "Employing people"
284
+ },
285
+ {
286
+ "action": "_blank",
287
+ "url": "#",
288
+ "label": "Payroll tax"
289
+ },
290
+ {
291
+ "action": "_blank",
292
+ "url": "#",
293
+ "label": "Industries"
294
+ },
295
+ {
296
+ "action": "_blank",
297
+ "url": "#",
298
+ "label": "Investing in Queensland"
299
+ }
300
+ ],
301
+ "view_more": true,
302
+ "view_more_options": {
303
+ "url": "#",
304
+ "label": "View more",
305
+ "target": "_blank"
306
+ }
307
+ }
308
+ }
239
309
  },
240
- "dropdown_enabled": true,
241
- "dropdown_options": {
242
- "dropdown_type": "form",
243
- "dropdown_config": {
244
- "content": "<div></div>"
310
+ {
311
+ "id": "CTAthree",
312
+ "url": {
313
+ "value": "#"
314
+ },
315
+ "text": {
316
+ "value": "Login"
317
+ },
318
+ "dropdown_enabled": true,
319
+ "dropdown_options": {
320
+ "dropdown_type": "form",
321
+ "dropdown_config": {
322
+ "content": "<div></div>"
323
+ }
245
324
  }
246
325
  }
247
- }
326
+ ]
248
327
  },
249
328
  "siteHeader": {
250
329
  "config": {
@@ -274,9 +353,7 @@
274
353
  "placeholder": "Placeholder",
275
354
  "label": "Label",
276
355
  "formAction": {
277
- "url": "https://www.forgov.qld.gov.au/search",
278
- "suggestions": "https://discover.search.qld.gov.au/s/suggest.json",
279
- "results": "https://discover.search.qld.gov.au/s/search.json"
356
+ "url": "https://www.forgov.qld.gov.au/search"
280
357
  },
281
358
  "options": {
282
359
  "borderStyle": {
@@ -290,7 +367,8 @@
290
367
  "icons": {
291
368
  "menu-icon": "qld__icon__mobile-menu",
292
369
  "search-icon": "qld__icon__search",
293
- "close-icon": "qld__icon__close"
370
+ "close-icon": "qld__icon__close",
371
+ "chevron_down": "qld__icon__chevron-down"
294
372
  },
295
373
  "sitePreHeader": {
296
374
  "url": {
@@ -305,9 +383,6 @@
305
383
  "url": {
306
384
  "value": "#"
307
385
  },
308
- "icon": {
309
- "value": "ctaIcon"
310
- },
311
386
  "text": {
312
387
  "value": "For Queenslanders"
313
388
  },
@@ -363,9 +438,6 @@
363
438
  "url": {
364
439
  "value": "#"
365
440
  },
366
- "icon": {
367
- "value": "ctaIcon"
368
- },
369
441
  "text": {
370
442
  "value": "Business and Industry"
371
443
  },
@@ -421,9 +493,6 @@
421
493
  "url": {
422
494
  "value": "#"
423
495
  },
424
- "icon": {
425
- "value": "ctaIcon"
426
- },
427
496
  "text": {
428
497
  "value": "Login"
429
498
  },
@@ -464,9 +533,7 @@
464
533
  "placeholder": "",
465
534
  "label": "",
466
535
  "formAction": {
467
- "url": "https://www.forgov.qld.gov.au/search",
468
- "suggestions": "https://discover.search.qld.gov.au/s/suggest.json",
469
- "results": "https://discover.search.qld.gov.au/s/search.json"
536
+ "url": "https://www.forgov.qld.gov.au/search"
470
537
  },
471
538
  "options": {
472
539
  "borderStyle": {
@@ -480,7 +547,8 @@
480
547
  "icons": {
481
548
  "menu-icon": "qld__icon__mobile-menu",
482
549
  "search-icon": "qld__icon__search",
483
- "close-icon": "qld__icon__close"
550
+ "close-icon": "qld__icon__close",
551
+ "chevron_down": "qld__icon__chevron-down"
484
552
  },
485
553
  "sitePreHeader": {
486
554
  "url": {
@@ -495,9 +563,6 @@
495
563
  "url": {
496
564
  "value": "#"
497
565
  },
498
- "icon": {
499
- "value": "ctaIcon"
500
- },
501
566
  "text": {
502
567
  "value": "For Queenslanders"
503
568
  },
@@ -553,9 +618,6 @@
553
618
  "url": {
554
619
  "value": "#"
555
620
  },
556
- "icon": {
557
- "value": "ctaIcon"
558
- },
559
621
  "text": {
560
622
  "value": "Business and Industry"
561
623
  },
@@ -611,9 +673,6 @@
611
673
  "url": {
612
674
  "value": "#"
613
675
  },
614
- "icon": {
615
- "value": "ctaIcon"
616
- },
617
676
  "text": {
618
677
  "value": "Login"
619
678
  },
@@ -96,42 +96,42 @@
96
96
  "navigation_items": [
97
97
  {
98
98
  "title": "Visiting someone in hospital",
99
- "description1": "One of the best motivations for quitting is having a clear reason in mind so you know exactly why you’re doing it in the first place.",
99
+ "description": "One of the best motivations for quitting is having a clear reason in mind so you know exactly why you’re doing it in the first place.",
100
100
  "target_url": "index.html"
101
101
  },
102
102
  {
103
103
  "title": "Aboriginal and Torres Strait Islander support",
104
- "description1": "Be encouraged and motivated by listening to stories of others who've quit smoking for life.",
104
+ "description": "Be encouraged and motivated by listening to stories of others who've quit smoking for life.",
105
105
  "target_url": "index.html"
106
106
  },
107
107
  {
108
108
  "title": "Your healthcare rights and responsibilities",
109
- "description1": "Vaping products are also known as e-cigarettes, e-cigars, vape pens or personal vapourisers. Vapes are harmful. The safest option is to not vape at all.",
109
+ "description": "Vaping products are also known as e-cigarettes, e-cigars, vape pens or personal vapourisers. Vapes are harmful. The safest option is to not vape at all.",
110
110
  "target_url": "index.html"
111
111
  },
112
112
  {
113
113
  "title": "Going to hospital",
114
- "description1": "There are plenty of ways to quit smoking cigarettes and vapes. Find one that suits you best and commit to it.",
114
+ "description": "There are plenty of ways to quit smoking cigarettes and vapes. Find one that suits you best and commit to it.",
115
115
  "target_url": "index.html"
116
116
  },
117
117
  {
118
118
  "title": "Interpreter services",
119
- "description1": "Whether you’re thinking about getting pregnant, you're pregnant or have recently given birth, quitting smoking or vaping is the best thing you can do for the health of you and your baby.",
119
+ "description": "Whether you’re thinking about getting pregnant, you're pregnant or have recently given birth, quitting smoking or vaping is the best thing you can do for the health of you and your baby.",
120
120
  "target_url": "index.html"
121
121
  },
122
122
  {
123
123
  "title": "Health costs, insurance and financial support",
124
- "description1": "Sign up for My Quit Journey to support you to stop smoking.",
124
+ "description": "Sign up for My Quit Journey to support you to stop smoking.",
125
125
  "target_url": "index.html"
126
126
  },
127
127
  {
128
128
  "title": "Leaving hospital",
129
- "description1": "Congratulations on taking the first step in your journey and deciding to make one of the best choices of your life.",
129
+ "description": "Congratulations on taking the first step in your journey and deciding to make one of the best choices of your life.",
130
130
  "target_url": "index.html"
131
131
  },
132
132
  {
133
133
  "title": "Your health record",
134
- "description1": "Congratulations on taking the first step in your journey and deciding to make one of the best choices of your life.",
134
+ "description": "Congratulations on taking the first step in your journey and deciding to make one of the best choices of your life.",
135
135
  "target_url": "index.html"
136
136
  }
137
137
  ]
@@ -1,3 +1,10 @@
1
1
  {
2
-
2
+ "hasIconInfo": true,
3
+ "hasTooltip": true,
4
+ "exitMessage": "Select 'Close<span class='very-small-mobile'> this site</span>'<span class='not-mobile'> or press 'ESC' on your keyboard</span> to go to google.com.au.",
5
+ "exitMessageLinkText": "View more tips to browse safely online.",
6
+ "quickExitButtonText": "Close<span class='very-small-mobile'> this site</span>",
7
+ "qldTooltipPrompt": "What is this?",
8
+ "browseSafelyOnlineURL": "https://www.qld.gov.au/help/tips-to-browse-safely-online",
9
+ "qldTooltipContent": "To leave this site quickly, click the 'Close this site' button or press 'ESC' on your keyboard. You will be taken to google.com.au."
3
10
  }
@@ -7,5 +7,14 @@
7
7
  "buttonID": "search-button",
8
8
  "buttonType": "submit",
9
9
  "buttonLabel": "Search",
10
- "ariaLabel": "Search website"
10
+ "ariaLabel": "Search website",
11
+ "suggestions": true,
12
+ "tags": {
13
+ "collection": "qgov~sp-search",
14
+ "profile": "qld",
15
+ "numranks": "10",
16
+ "tiers": "off",
17
+ "suggestions": "https://discover.search.qld.gov.au/s/suggest.json",
18
+ "results-url": "https://discover.search.qld.gov.au/s/search.json"
19
+ }
11
20
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@qld-gov-au/qgds-bootstrap5",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
7
- "url": "https://github.com/qld-gov-au/qgds-qol-mvp"
7
+ "url": "https://github.com/qld-gov-au/qgds-bootstrap5"
8
8
  },
9
9
  "main": "index.js",
10
10
  "scripts": {
@@ -39,34 +39,35 @@
39
39
  "dependencies": {
40
40
  "@fortawesome/fontawesome-free": "^6.5.2",
41
41
  "bootstrap": "^5.3.1",
42
- "material-symbols": "^0.19.0"
42
+ "material-symbols": "^0.20.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@chromatic-com/storybook": "^1.5.0",
46
46
  "@qld-gov-au/qgds-tokens": "^1.2.0",
47
- "@storybook/addon-essentials": "^8.1.5",
48
- "@storybook/addon-interactions": "^8.1.5",
49
- "@storybook/addon-links": "^8.1.5",
50
- "@storybook/addon-mdx-gfm": "^8.1.5",
51
- "@storybook/addon-themes": "^8.1.5",
47
+ "@storybook/addon-a11y": "^8.1.6",
48
+ "@storybook/addon-essentials": "^8.1.6",
49
+ "@storybook/addon-interactions": "^8.1.6",
50
+ "@storybook/addon-links": "^8.1.6",
51
+ "@storybook/addon-mdx-gfm": "^8.1.6",
52
+ "@storybook/addon-themes": "^8.1.6",
52
53
  "@storybook/blocks": "^8.1.2",
53
- "@storybook/cli": "^8.1.5",
54
- "@storybook/html": "^8.1.5",
55
- "@storybook/html-vite": "^8.1.5",
56
- "@storybook/manager-api": "^8.1.5",
54
+ "@storybook/cli": "^8.1.6",
55
+ "@storybook/html": "^8.1.6",
56
+ "@storybook/html-vite": "^8.1.6",
57
+ "@storybook/manager-api": "^8.1.6",
57
58
  "@storybook/test": "^8.1.2",
58
59
  "@storybook/theming": "^8.1.5",
59
60
  "@stylistic/eslint-plugin-js": "2.1.0",
60
- "@vitejs/plugin-vue": "5.0.4",
61
+ "@vitejs/plugin-vue": "5.0.5",
61
62
  "@whitespace/storybook-addon-html": "^6.1.1",
62
63
  "autoprefixer": "^10.4.15",
63
64
  "chalk": "^5.3.0",
64
- "chromatic": "^11.4.1",
65
+ "chromatic": "^11.5.3",
65
66
  "esbuild": "0.21.4",
66
67
  "esbuild-plugin-copy": "^2.1.1",
67
68
  "esbuild-plugin-eslint": "^0.3.7",
68
69
  "esbuild-plugin-handlebars": "1.0.3",
69
- "esbuild-sass-plugin": "3.3.0",
70
+ "esbuild-sass-plugin": "3.3.1",
70
71
  "eslint": "8.57.0",
71
72
  "eslint-plugin-json": "^3.1.0",
72
73
  "eslint-plugin-storybook": "^0.8.0",
@@ -76,12 +77,12 @@
76
77
  "npm-run-all2": "^6.1.2",
77
78
  "onchange": "^7.1.0",
78
79
  "postcss": "^8.4.29",
79
- "prettier": "3.2.5",
80
+ "prettier": "3.3.1",
80
81
  "raw-loader": "^4.0.2",
81
82
  "rimraf": "^5.0.7",
82
- "sass": "^1.77.3",
83
- "storybook": "^8.1.5",
84
- "vite": "^5.2.12",
83
+ "sass": "^1.77.4",
84
+ "storybook": "^8.1.6",
85
+ "vite": "^5.2.13",
85
86
  "watch": "^1.0.2"
86
87
  },
87
88
  "peerDependencies": {
@@ -1,37 +1,66 @@
1
+ /**
2
+ * Initialise the Breadcrumb component.
3
+ * Shorten long breadcrumbs when required.
4
+ *
5
+ * @memberof module:Breadcrumb
6
+ *
7
+ * @returns {void} Returns early when breadcrumb does not exist or its length is within set maxLength.
8
+ */
9
+ export function initBreadcrumb() {
10
+ // Set the standard breadcrumb length.
11
+ const maxLength = 4;
12
+
13
+ // Get the breadcrumb DOM element.
14
+ const breadcrumb = document.querySelector('.breadcrumb');
15
+ if (!breadcrumb) {
16
+ return;
17
+ }
18
+ const breadcrumbList = breadcrumb.querySelectorAll('.breadcrumb-item');
19
+
20
+ // Return when breadcrumb does not exist.
21
+ if (!breadcrumbList || !breadcrumbList.length) {
22
+ return;
23
+ }
24
+ // Shorten breadcrumb.
25
+ breadcrumbShorten(breadcrumbList, maxLength);
26
+ }
27
+
1
28
  /**
2
29
  * Shorten long breadcrumb lists
3
30
  *
4
31
  * @memberof module:Breadcrumb
5
32
  *
6
- * @param {Object} event - The event that triggered this function.
7
- * @returns {void}
33
+ * @param {Element} breadcrumbList - Breadcrumb DOM element.
34
+ * @param {number} maxLength - Standard maximum length for breadcrumb.
35
+ * @returns {void} Returns early when breadcrumb does not exist or its length is within set maxLength.
8
36
  */
9
- export function breadcrumbShorten () {
10
- let breadcrumbList = document.querySelector('.breadcrumb').querySelectorAll('.breadcrumb-item')
11
-
12
- if (breadcrumbList.length > 4) {
13
- breadcrumbList.forEach((crumb, index) => {
14
- if (index > 1 && index < breadcrumbList.length - 2) {
15
- crumb.classList.add('shortened')
16
- crumb.querySelector('a').setAttribute('tabindex',-1)
17
- }
18
-
19
- if (index === 1) {
20
- let expandCrumb = document.createElement('li'),
21
- expandButton = document.createElement('a')
22
-
23
- expandCrumb.classList.add('breadcrumb-item','breadcrumb-toggle')
24
-
25
- expandButton.setAttribute('href', 'javascript:void(0)')
26
- expandButton.setAttribute('aria-label', 'Expand the breadcrumbs')
27
- expandButton.textContent = '[...]'
28
- expandButton.addEventListener('click', breadcrumbExpand)
29
-
30
- expandCrumb.appendChild(expandButton)
31
- crumb.after(expandCrumb)
32
- }
33
- })
37
+ export function breadcrumbShorten(breadcrumbList, maxLength = 4) {
38
+ // No shortening is required when breadcrumb does not exist or its length is within the maximum range.
39
+ if (!breadcrumbList || breadcrumbList.length <= maxLength) {
40
+ return;
34
41
  }
42
+
43
+ breadcrumbList.forEach((crumb, index) => {
44
+ if (index > 1 && index < breadcrumbList.length - 2) {
45
+ crumb.classList.add('shortened')
46
+ crumb.querySelector('a').setAttribute('tabindex',-1)
47
+ }
48
+
49
+ if (index === 1) {
50
+ let expandCrumb = document.createElement('li'),
51
+ expandButton = document.createElement('a')
52
+
53
+ expandCrumb.classList.add('breadcrumb-item','breadcrumb-toggle')
54
+
55
+ expandButton.setAttribute('href', 'javascript:void(0)')
56
+ expandButton.setAttribute('aria-label', 'Expand the breadcrumbs')
57
+ expandButton.textContent = '[...]'
58
+ expandButton.addEventListener('click', breadcrumbExpand)
59
+
60
+ expandCrumb.appendChild(expandButton)
61
+ crumb.after(expandCrumb)
62
+ }
63
+ })
35
64
  }
36
65
 
37
66
  /**
@@ -39,12 +68,22 @@ export function breadcrumbShorten () {
39
68
  *
40
69
  * @memberof module:Breadcrumb
41
70
  *
42
- * @param {Object} event - The event that triggered this function.
43
- * @returns {void}
71
+ * @param {Event} event - The event that triggered this function.
72
+ * @returns {void} Returns early when the breadcrumb does not exist or is empty.
44
73
  */
45
- export function breadcrumbExpand () {
46
- let breadcrumbList = document.querySelector('.breadcrumb').querySelectorAll('.breadcrumb-item')
74
+ export function breadcrumbExpand(event) {
75
+ const breadcrumb = event.target.closest('.breadcrumb');
76
+ if (!breadcrumb) {
77
+ console.log('breadcrumbExpand: Breadcrumb does not exist.');
78
+ return;
79
+ }
80
+ const breadcrumbList = breadcrumb.querySelectorAll('.breadcrumb-item');
47
81
 
82
+ if (!breadcrumbList || !breadcrumbList.length) {
83
+ console.log('breadcrumbExpand: Breadcrumb does not exist or is empty.');
84
+ return;
85
+ }
86
+
48
87
  breadcrumbList[0].parentElement.classList.add('expanded')
49
88
 
50
89
  breadcrumbList.forEach((crumb, index) => {
@@ -53,4 +92,4 @@ export function breadcrumbExpand () {
53
92
  crumb.querySelector('a').setAttribute('tabindex', 0)
54
93
  }
55
94
  })
56
- }
95
+ }
@@ -9,7 +9,7 @@
9
9
  {{/unless}}
10
10
  {{! print the current page as plain text}}
11
11
  {{#if @last}}
12
- <li class="breadcrumb-item active" aria-current="page">{{linktext}}</li>
12
+ <li class="breadcrumb-item active" aria-current="page" data-href="{{link}}">{{linktext}}</li>
13
13
  {{/if}}
14
14
  {{/each}}
15
15
  </ol>
@@ -3,7 +3,8 @@
3
3
  "islink": true,
4
4
  "isdisabled": false,
5
5
  "iconClass": "fa-solid fa-arrow-up-right-from-square",
6
- "href": "https://google.com",
6
+ "iconPosition": "leading",
7
7
  "label": "Call to action",
8
+ "href": "https://google.com",
8
9
  "target": "_blank"
9
10
  }