@qld-gov-au/qgds-bootstrap5 1.1.40 → 2.0.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/.eslintrc.cjs +27 -27
- package/.vscode/settings.json +5 -5
- package/dist/assets/components/bs5/button/button.hbs +48 -30
- package/dist/assets/components/bs5/card/card.hbs +3 -17
- package/dist/assets/components/bs5/containerLayout/containerLayout.hbs +100 -0
- package/dist/assets/components/bs5/footer/customLinks.hbs +7 -0
- package/dist/assets/components/bs5/footer/feedbackForm.hbs +25 -0
- package/dist/assets/components/bs5/footer/followLinks.hbs +14 -0
- package/dist/assets/components/bs5/footer/footer.hbs +229 -346
- package/dist/assets/components/bs5/formcheck/formcheck.hbs +1 -1
- package/dist/assets/components/bs5/head/head.hbs +4 -4
- package/dist/assets/components/bs5/header/header.hbs +124 -878
- package/dist/assets/components/bs5/header/headerBrand.hbs +35 -0
- package/dist/assets/components/bs5/link/link.hbs +41 -0
- package/dist/assets/components/bs5/logo/logoCOALandscape.hbs +110 -55
- package/dist/assets/components/bs5/logo/logoCOALandscape2Lines.hbs +2 -1
- package/dist/assets/components/bs5/navbar/navbar.hbs +65 -245
- package/dist/assets/components/bs5/pageLayout/templates/contentPageWithForm.hbs +53 -22
- package/dist/assets/components/bs5/pageLayout/templates/contentPageWithSideNavigation.hbs +79 -59
- package/dist/assets/components/bs5/pageLayout/templates/homePage.hbs +111 -0
- package/dist/assets/components/bs5/searchInput/searchInput.hbs +9 -11
- package/dist/assets/css/qld.bootstrap.css +1 -1
- package/dist/assets/css/qld.bootstrap.css.map +3 -3
- package/dist/assets/js/bootstrap.bundle.js +3 -6
- package/dist/assets/js/bootstrap.bundle.js.map +1 -1
- package/dist/assets/js/bootstrap.bundle.min.js +2 -2
- package/dist/assets/js/bootstrap.bundle.min.js.map +1 -1
- package/dist/assets/js/bootstrap.js +3 -6
- package/dist/assets/js/bootstrap.min.js +2 -2
- package/dist/assets/js/bootstrap.min.js.map +1 -1
- package/dist/assets/js/handlebars.helpers.bundle.js.map +2 -2
- package/dist/assets/js/handlebars.helpers.js +34 -34
- package/dist/assets/js/handlebars.init.min.js +1055 -2041
- package/dist/assets/js/handlebars.init.min.js.map +4 -4
- package/dist/assets/js/handlebars.partials.js +14 -6
- package/dist/assets/js/qld.bootstrap.min.js +9 -9
- package/dist/assets/js/qld.bootstrap.min.js.map +4 -4
- package/dist/assets/node/handlebars.init.min.js +538 -108
- package/dist/assets/node/handlebars.init.min.js.map +3 -3
- package/dist/components/bs5/button/button.hbs +48 -30
- package/dist/components/bs5/card/card.hbs +3 -17
- package/dist/components/bs5/containerLayout/containerLayout.hbs +100 -0
- package/dist/components/bs5/footer/customLinks.hbs +7 -0
- package/dist/components/bs5/footer/feedbackForm.hbs +25 -0
- package/dist/components/bs5/footer/followLinks.hbs +14 -0
- package/dist/components/bs5/footer/footer.hbs +229 -346
- package/dist/components/bs5/formcheck/formcheck.hbs +1 -1
- package/dist/components/bs5/head/head.hbs +4 -4
- package/dist/components/bs5/header/header.hbs +124 -878
- package/dist/components/bs5/header/headerBrand.hbs +35 -0
- package/dist/components/bs5/link/link.hbs +41 -0
- package/dist/components/bs5/logo/logoCOALandscape.hbs +110 -55
- package/dist/components/bs5/logo/logoCOALandscape2Lines.hbs +2 -1
- package/dist/components/bs5/navbar/navbar.hbs +65 -245
- package/dist/components/bs5/pageLayout/templates/contentPageWithForm.hbs +53 -22
- package/dist/components/bs5/pageLayout/templates/contentPageWithSideNavigation.hbs +79 -59
- package/dist/components/bs5/pageLayout/templates/homePage.hbs +111 -0
- package/dist/components/bs5/searchInput/searchInput.hbs +9 -11
- package/dist/components/handlebars.helpers.js +34 -34
- package/dist/components/handlebars.partials.js +14 -6
- package/dist/package.json +2 -2
- package/dist/sample-data/button/button.data.json +10 -8
- package/dist/sample-data/footer/footer.data.json +128 -84
- package/dist/sample-data/formcheck/stories/checkbox/checkbox.data.json +51 -46
- package/dist/sample-data/formcheck/stories/radio/radio.data.json +51 -46
- package/dist/sample-data/header/header.variant.coBrand.data.json +28 -40
- package/dist/sample-data/header/header.variant.endorsed.data.json +116 -150
- package/dist/sample-data/header/header.variant.masterBrand.data.json +116 -152
- package/dist/sample-data/header/header.variant.standAlone.data.json +118 -150
- package/dist/sample-data/header/header.variant.subBrand.data.json +32 -159
- package/dist/sample-data/inpageAlert/inpageAlert.data.json +6 -6
- package/dist/sample-data/link/link.data.json +77 -0
- package/dist/sample-data/logo/logo.data.json +1 -0
- package/dist/sample-data/navbar/navbar.data.json +191 -0
- package/dist/sample-data/searchInput/searchInput.data.json +2 -3
- package/dist/sample-data/tabs/tabs.data.json +45 -44
- package/package.json +2 -2
- package/src/components/bs5/accordion/Accordion.mdx +8 -2
- package/src/components/bs5/banner/Banner.mdx +6 -1
- package/src/components/bs5/banner/banner.scss +16 -9
- package/src/components/bs5/banner/banner.stories.js +17 -17
- package/src/components/bs5/breadcrumbs/Breadcrumbs.mdx +8 -2
- package/src/components/bs5/breadcrumbs/breadcrumbs.functions.js +2 -0
- package/src/components/bs5/breadcrumbs/breadcrumbs.scss +1 -1
- package/src/components/bs5/button/button.data.json +10 -8
- package/src/components/bs5/button/button.hbs +48 -30
- package/src/components/bs5/button/button.scss +61 -0
- package/src/components/bs5/button/button.stories.js +29 -10
- package/src/components/bs5/callToAction/callToAction.mdx +8 -3
- package/src/components/bs5/card/Card.mdx +8 -2
- package/src/components/bs5/card/card.hbs +3 -17
- package/src/components/bs5/card/card.scss +103 -103
- package/src/components/bs5/containerLayout/containerLayout.hbs +100 -0
- package/src/components/bs5/containerLayout/containerLayout.stories.js +83 -0
- package/src/components/bs5/footer/Footer.js +3 -3
- package/src/components/bs5/footer/Footer.mdx +8 -2
- package/src/components/bs5/footer/customLinks.hbs +7 -0
- package/src/components/bs5/footer/feedbackForm.hbs +25 -0
- package/src/components/bs5/footer/followLinks.hbs +14 -0
- package/src/components/bs5/footer/footer.data.json +128 -84
- package/src/components/bs5/footer/footer.functions.js +2 -1
- package/src/components/bs5/footer/footer.hbs +229 -346
- package/src/components/bs5/footer/footer.scss +262 -272
- package/src/components/bs5/footer/footer.stories.js +4 -92
- package/src/components/bs5/footer/footer_formio.scss +219 -0
- package/src/components/bs5/formcheck/formcheck.hbs +1 -1
- package/src/components/bs5/formcheck/formcheck.scss +161 -139
- package/src/components/bs5/formcheck/stories/checkbox/checkbox.data.json +51 -46
- package/src/components/bs5/formcheck/stories/radio/radio.data.json +51 -46
- package/src/components/bs5/globalAlert/GlobalAlert.mdx +8 -2
- package/src/components/bs5/globalAlert/globalAlert.test.js +3 -11
- package/src/components/bs5/header/_header-variables.scss +272 -0
- package/src/components/bs5/header/header.functions.js +9 -9
- package/src/components/bs5/header/header.hbs +124 -878
- package/src/components/bs5/header/header.scss +279 -411
- package/src/components/bs5/header/header.stories.js +8 -28
- package/src/components/bs5/header/header.variant.coBrand.data.json +28 -40
- package/src/components/bs5/header/header.variant.endorsed.data.json +116 -150
- package/src/components/bs5/header/header.variant.masterBrand.data.json +116 -152
- package/src/components/bs5/header/header.variant.standAlone.data.json +118 -150
- package/src/components/bs5/header/header.variant.subBrand.data.json +32 -159
- package/src/components/bs5/header/headerBrand.hbs +35 -0
- package/src/components/bs5/icons/icons.scss +79 -72
- package/src/components/bs5/inpageAlert/InpageAlert.mdx +8 -2
- package/src/components/bs5/inpageAlert/inpageAlert.data.json +6 -6
- package/src/components/bs5/inpagenav/inpagenav.scss +37 -37
- package/src/components/bs5/link/link.data.json +77 -0
- package/src/components/bs5/link/link.hbs +41 -0
- package/src/components/bs5/{pageLayout/pageLayout.js → link/link.js} +4 -5
- package/src/components/bs5/link/link.mdx +16 -0
- package/src/components/bs5/link/link.scss +81 -0
- package/src/components/bs5/link/link.stories.js +126 -0
- package/src/components/bs5/linkColumns/linkColumns.mdx +8 -3
- package/src/components/bs5/logo/logo.data.json +1 -0
- package/src/components/bs5/logo/logoCOALandscape.hbs +110 -55
- package/src/components/bs5/logo/logoCOALandscape2Lines.hbs +2 -1
- package/src/components/bs5/navbar/Navbar.js +2 -9
- package/src/components/bs5/navbar/navbar.data.json +191 -0
- package/src/components/bs5/navbar/navbar.functions.js +48 -196
- package/src/components/bs5/navbar/navbar.hbs +65 -245
- package/src/components/bs5/navbar/navbar.scss +684 -562
- package/src/components/bs5/navbar/navbar.stories.js +533 -0
- package/src/components/bs5/pageLayout/{FullWidthLandingPage.js → HomePage.js} +2 -2
- package/src/components/bs5/pageLayout/pageLayout.stories.js +242 -98
- package/src/components/bs5/pageLayout/templates/contentPageWithForm.hbs +53 -22
- package/src/components/bs5/pageLayout/templates/contentPageWithSideNavigation.hbs +79 -59
- package/src/components/bs5/pageLayout/templates/homePage.hbs +111 -0
- package/src/components/bs5/promotionalPanel/PromotionalPanel.mdx +8 -3
- package/src/components/bs5/searchInput/__snapshots__/searchInput.test.js.snap +10 -9
- package/src/components/bs5/searchInput/search.functions.js +94 -63
- package/src/components/bs5/searchInput/searchInput.data.json +2 -3
- package/src/components/bs5/searchInput/searchInput.hbs +9 -11
- package/src/components/bs5/searchInput/searchInput.scss +297 -255
- package/src/components/bs5/searchInput/searchInput.test.js +98 -90
- package/src/components/bs5/tabs/tabs.data.json +45 -44
- package/src/components/bs5/tabs/tabs.scss +544 -500
- package/src/components/bs5/tabs/tabs.stories.js +81 -51
- package/src/components/common/layout/container.scss +22 -0
- package/src/components/common/layout/content.scss +11 -4
- package/src/components/common/layout/grid.scss +26 -0
- package/src/css/main.scss +7 -2
- package/src/css/mixins/_index.scss +2 -1
- package/src/css/mixins/register-vars.scss +23 -0
- package/src/css/qld-variables.scss +106 -83
- package/src/css/utilities/_index.scss +1 -0
- package/src/css/utilities/responsive-visually-hidden.scss +10 -0
- package/src/js/handlebars.helpers.js +34 -34
- package/src/js/handlebars.partials.js +14 -6
- package/src/js/qld.bootstrap.js +10 -11
- package/dist/assets/components/bs5/footer/footerForgov.hbs +0 -279
- package/dist/assets/components/bs5/pageLayout/pageLayout.hbs +0 -34
- package/dist/assets/components/bs5/pageLayout/templates/fullWidthLandingPage.hbs +0 -61
- package/dist/components/bs5/footer/footerForgov.hbs +0 -279
- package/dist/components/bs5/pageLayout/pageLayout.hbs +0 -34
- package/dist/components/bs5/pageLayout/templates/fullWidthLandingPage.hbs +0 -61
- package/src/components/bs5/footer/_colours.scss +0 -149
- package/src/components/bs5/footer/_measurements.scss +0 -32
- package/src/components/bs5/footer/footerForgov.hbs +0 -279
- package/src/components/bs5/header/_colours.scss +0 -271
- package/src/components/bs5/header/_icons.scss +0 -10
- package/src/components/bs5/navbar/_colours.scss +0 -85
- package/src/components/bs5/navbar/_icons.scss +0 -64
- package/src/components/bs5/pageLayout/pageLayout.hbs +0 -34
- package/src/components/bs5/pageLayout/templates/fullWidthLandingPage.hbs +0 -61
|
@@ -0,0 +1,533 @@
|
|
|
1
|
+
import { Navbar } from "./Navbar.js";
|
|
2
|
+
import defaultdata from "./navbar.data.json";
|
|
3
|
+
|
|
4
|
+
//Default story
|
|
5
|
+
export default {
|
|
6
|
+
tags: ["autodocs"],
|
|
7
|
+
title: "3. Components/Navbar",
|
|
8
|
+
render: (args) => {
|
|
9
|
+
// Create a copy of default data
|
|
10
|
+
const data = JSON.parse(JSON.stringify(defaultdata));
|
|
11
|
+
const addCount = args["Add Navigation Item"] || 0;
|
|
12
|
+
const baseItemCount = defaultdata.navigation?.length || 0;
|
|
13
|
+
|
|
14
|
+
// Rebuild navigation completely
|
|
15
|
+
data.navigation = [];
|
|
16
|
+
|
|
17
|
+
// Add base items
|
|
18
|
+
for (let i = 0; i < baseItemCount; i++) {
|
|
19
|
+
const originalItem = defaultdata.navigation[i];
|
|
20
|
+
const itemName = originalItem.text;
|
|
21
|
+
|
|
22
|
+
data.navigation.push({
|
|
23
|
+
...originalItem,
|
|
24
|
+
text: args[`${itemName.replace(/\s+/g, "")}_text`] || originalItem.text,
|
|
25
|
+
hideLabel:
|
|
26
|
+
args[`${itemName.replace(/\s+/g, "")}_hideLabel`] !== undefined
|
|
27
|
+
? args[`${itemName.replace(/\s+/g, "")}_hideLabel`]
|
|
28
|
+
: originalItem.hideLabel,
|
|
29
|
+
mobileOnly:
|
|
30
|
+
args[`${itemName.replace(/\s+/g, "")}_mobileOnly`] !== undefined
|
|
31
|
+
? args[`${itemName.replace(/\s+/g, "")}_mobileOnly`]
|
|
32
|
+
: originalItem.mobileOnly,
|
|
33
|
+
alternativeColor:
|
|
34
|
+
args[`${itemName.replace(/\s+/g, "")}_alternativeColor`] !== undefined
|
|
35
|
+
? args[`${itemName.replace(/\s+/g, "")}_alternativeColor`]
|
|
36
|
+
: originalItem.alternativeColor,
|
|
37
|
+
iconName:
|
|
38
|
+
args[`${itemName.replace(/\s+/g, "")}_iconName`] ||
|
|
39
|
+
originalItem.iconName ||
|
|
40
|
+
"",
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Add new items
|
|
45
|
+
for (let i = 0; i < addCount; i++) {
|
|
46
|
+
const newItem = {
|
|
47
|
+
text: args[`newItem${i}_text`] || `New Item ${i + 1}`,
|
|
48
|
+
hideLabel: args[`newItem${i}_hideLabel`] || false,
|
|
49
|
+
mobileOnly: args[`newItem${i}_mobileOnly`] || false,
|
|
50
|
+
alternativeColor: args[`newItem${i}_alternativeColor`] || false,
|
|
51
|
+
iconName: args[`newItem${i}_iconName`] || "",
|
|
52
|
+
url: "#",
|
|
53
|
+
cssClass: "",
|
|
54
|
+
target_url: "#",
|
|
55
|
+
dropdown_enabled: false,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
data.navigation.push(newItem);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Apply metadata
|
|
62
|
+
data.metadata = data.metadata || {};
|
|
63
|
+
data.metadata.alternativeColor = args["Nav alternativeColor"] || false;
|
|
64
|
+
data.metadata.verticalOrientation =
|
|
65
|
+
args["Nav verticalOrientation"] || false;
|
|
66
|
+
data.metadata.navbarBrandName = args["Nav navbarBrandName"] || "";
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
const navbarInstance = new Navbar(data);
|
|
70
|
+
let html = navbarInstance.html;
|
|
71
|
+
|
|
72
|
+
// Apply modifications with UNIQUE class names
|
|
73
|
+
data.navigation.forEach((item) => {
|
|
74
|
+
if (!item.text) return;
|
|
75
|
+
|
|
76
|
+
const escapedText = item.text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
77
|
+
|
|
78
|
+
if (item.hideLabel) {
|
|
79
|
+
html = html.replace(
|
|
80
|
+
new RegExp(`(<a[^>]*>)(${escapedText})(</a>)`, "gi"),
|
|
81
|
+
`$1<span class="sr-only">$2</span>$3`,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (item.mobileOnly) {
|
|
86
|
+
// Use unique class names to avoid conflicts
|
|
87
|
+
const textPos = html.indexOf(item.text);
|
|
88
|
+
if (textPos !== -1) {
|
|
89
|
+
let liStart = html.lastIndexOf("<li", textPos);
|
|
90
|
+
if (liStart !== -1) {
|
|
91
|
+
let liEnd = html.indexOf(">", liStart);
|
|
92
|
+
if (liEnd !== -1) {
|
|
93
|
+
const originalLiTag = html.substring(liStart, liEnd + 1);
|
|
94
|
+
let newLiTag;
|
|
95
|
+
|
|
96
|
+
if (originalLiTag.includes('class="')) {
|
|
97
|
+
// Add to existing class with unique names
|
|
98
|
+
newLiTag = originalLiTag.replace(
|
|
99
|
+
'class="',
|
|
100
|
+
'class="qgds-mobile-only qgds-hide-desktop ',
|
|
101
|
+
);
|
|
102
|
+
} else {
|
|
103
|
+
// Add new class attribute with unique names
|
|
104
|
+
newLiTag = originalLiTag.replace(
|
|
105
|
+
"<li",
|
|
106
|
+
'<li class="qgds-mobile-only qgds-hide-desktop"',
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
html =
|
|
111
|
+
html.substring(0, liStart) +
|
|
112
|
+
newLiTag +
|
|
113
|
+
html.substring(liEnd + 1);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (item.alternativeColor) {
|
|
120
|
+
const textPos = html.indexOf(item.text);
|
|
121
|
+
if (textPos !== -1) {
|
|
122
|
+
let liStart = html.lastIndexOf("<li", textPos);
|
|
123
|
+
if (liStart !== -1) {
|
|
124
|
+
let liEnd = html.indexOf(">", liStart);
|
|
125
|
+
if (liEnd !== -1) {
|
|
126
|
+
const originalLiTag = html.substring(liStart, liEnd + 1);
|
|
127
|
+
let newLiTag;
|
|
128
|
+
|
|
129
|
+
if (originalLiTag.includes('class="')) {
|
|
130
|
+
newLiTag = originalLiTag.replace(
|
|
131
|
+
'class="',
|
|
132
|
+
'class="qgds-alt-color ',
|
|
133
|
+
);
|
|
134
|
+
} else {
|
|
135
|
+
newLiTag = originalLiTag.replace(
|
|
136
|
+
"<li",
|
|
137
|
+
'<li class="qgds-alt-color"',
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
html =
|
|
142
|
+
html.substring(0, liStart) +
|
|
143
|
+
newLiTag +
|
|
144
|
+
html.substring(liEnd + 1);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// Add CSS with UNIQUE class names and higher specificity
|
|
152
|
+
const styles = `
|
|
153
|
+
<style>
|
|
154
|
+
.sr-only {
|
|
155
|
+
position: absolute !important;
|
|
156
|
+
width: 1px !important;
|
|
157
|
+
height: 1px !important;
|
|
158
|
+
padding: 0 !important;
|
|
159
|
+
margin: -1px !important;
|
|
160
|
+
overflow: hidden !important;
|
|
161
|
+
clip: rect(0, 0, 0, 0) !important;
|
|
162
|
+
white-space: nowrap !important;
|
|
163
|
+
border: 0 !important;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/* Mobile-only items - hide on desktop with unique class names */
|
|
167
|
+
@media (min-width: 992px) {
|
|
168
|
+
.qgds-mobile-only,
|
|
169
|
+
.qgds-hide-desktop,
|
|
170
|
+
.navbar-nav .qgds-mobile-only,
|
|
171
|
+
.navbar-nav .qgds-hide-desktop {
|
|
172
|
+
display: none !important;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/* CSS for hiding/showing Storybook controls */
|
|
177
|
+
.hide {
|
|
178
|
+
display: none !important;
|
|
179
|
+
}
|
|
180
|
+
</style>
|
|
181
|
+
`;
|
|
182
|
+
|
|
183
|
+
return styles + html + `<!-- Render: ${Date.now()} -->`;
|
|
184
|
+
} catch (error) {
|
|
185
|
+
console.error("Error:", error);
|
|
186
|
+
return `<div style="color: red; padding: 20px;"><h3>Error</h3><p>${error.message}</p></div>`;
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
|
|
190
|
+
// Replace the entire argTypes section with this reordered version:
|
|
191
|
+
|
|
192
|
+
argTypes: {
|
|
193
|
+
// 1. Navbar Body (first)
|
|
194
|
+
"Nav alternativeColor": {
|
|
195
|
+
control: "boolean",
|
|
196
|
+
table: { category: "Navbar Body" },
|
|
197
|
+
},
|
|
198
|
+
"Nav verticalOrientation": {
|
|
199
|
+
control: "boolean",
|
|
200
|
+
table: { category: "Navbar Body" },
|
|
201
|
+
},
|
|
202
|
+
"Nav navbarBrandName": {
|
|
203
|
+
control: "text",
|
|
204
|
+
table: { category: "Navbar Body" },
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
// 2. Base Items (second) - move this BEFORE Navigation
|
|
208
|
+
...(() => {
|
|
209
|
+
const argTypes = {};
|
|
210
|
+
if (defaultdata.navigation) {
|
|
211
|
+
defaultdata.navigation.forEach((item) => {
|
|
212
|
+
const baseName = item.text.replace(/\s+/g, "");
|
|
213
|
+
argTypes[`${baseName}_iconName`] = {
|
|
214
|
+
name: `${item.text} - Icon Name`,
|
|
215
|
+
control: "text",
|
|
216
|
+
table: { category: "Base Items" },
|
|
217
|
+
};
|
|
218
|
+
argTypes[`${baseName}_text`] = {
|
|
219
|
+
name: `${item.text} - Text`,
|
|
220
|
+
control: "text",
|
|
221
|
+
table: { category: "Base Items" },
|
|
222
|
+
};
|
|
223
|
+
argTypes[`${baseName}_hideLabel`] = {
|
|
224
|
+
name: `${item.text} - Hide Label`,
|
|
225
|
+
control: "boolean",
|
|
226
|
+
table: { category: "Base Items" },
|
|
227
|
+
};
|
|
228
|
+
argTypes[`${baseName}_mobileOnly`] = {
|
|
229
|
+
name: `${item.text} - Mobile Only`,
|
|
230
|
+
control: "boolean",
|
|
231
|
+
table: { category: "Base Items" },
|
|
232
|
+
};
|
|
233
|
+
argTypes[`${baseName}_alternativeColor`] = {
|
|
234
|
+
name: `${item.text} - Alternative Color`,
|
|
235
|
+
control: "boolean",
|
|
236
|
+
table: { category: "Base Items" },
|
|
237
|
+
};
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
return argTypes;
|
|
241
|
+
})(),
|
|
242
|
+
|
|
243
|
+
// 3. Navigation (third) - move this AFTER Base Items
|
|
244
|
+
"Add Navigation Item": {
|
|
245
|
+
control: { type: "range", min: 0, max: 3, step: 1 },
|
|
246
|
+
table: { category: "Navigation" },
|
|
247
|
+
},
|
|
248
|
+
|
|
249
|
+
// 4. New Items (fourth) - keep this last
|
|
250
|
+
...(() => {
|
|
251
|
+
const argTypes = {};
|
|
252
|
+
for (let i = 0; i < 3; i++) {
|
|
253
|
+
const itemNumber = i + 1;
|
|
254
|
+
|
|
255
|
+
argTypes[`newItem${i}_iconName`] = {
|
|
256
|
+
name: `New Item ${itemNumber} - Icon Name`,
|
|
257
|
+
control: "text",
|
|
258
|
+
table: {
|
|
259
|
+
category: "New Items",
|
|
260
|
+
className: (args) =>
|
|
261
|
+
args && args["Add Navigation Item"] >= itemNumber ? "" : "hide",
|
|
262
|
+
},
|
|
263
|
+
};
|
|
264
|
+
argTypes[`newItem${i}_text`] = {
|
|
265
|
+
name: `New Item ${itemNumber} - Text`,
|
|
266
|
+
control: "text",
|
|
267
|
+
table: {
|
|
268
|
+
category: "New Items",
|
|
269
|
+
className: (args) =>
|
|
270
|
+
args && args["Add Navigation Item"] >= itemNumber ? "" : "hide",
|
|
271
|
+
},
|
|
272
|
+
};
|
|
273
|
+
argTypes[`newItem${i}_hideLabel`] = {
|
|
274
|
+
name: `New Item ${itemNumber} - Hide Label`,
|
|
275
|
+
control: "boolean",
|
|
276
|
+
table: {
|
|
277
|
+
category: "New Items",
|
|
278
|
+
className: (args) =>
|
|
279
|
+
args && args["Add Navigation Item"] >= itemNumber ? "" : "hide",
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
argTypes[`newItem${i}_mobileOnly`] = {
|
|
283
|
+
name: `New Item ${itemNumber} - Mobile Only`,
|
|
284
|
+
control: "boolean",
|
|
285
|
+
table: {
|
|
286
|
+
category: "New Items",
|
|
287
|
+
className: (args) =>
|
|
288
|
+
args && args["Add Navigation Item"] >= itemNumber ? "" : "hide",
|
|
289
|
+
},
|
|
290
|
+
};
|
|
291
|
+
argTypes[`newItem${i}_alternativeColor`] = {
|
|
292
|
+
name: `New Item ${itemNumber} - Alternative Color`,
|
|
293
|
+
control: "boolean",
|
|
294
|
+
table: {
|
|
295
|
+
category: "New Items",
|
|
296
|
+
className: (args) =>
|
|
297
|
+
args && args["Add Navigation Item"] >= itemNumber ? "" : "hide",
|
|
298
|
+
},
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
return argTypes;
|
|
302
|
+
})(),
|
|
303
|
+
},
|
|
304
|
+
|
|
305
|
+
parameters: {
|
|
306
|
+
design: {
|
|
307
|
+
name: "QGDS Figma Reference",
|
|
308
|
+
type: "figma",
|
|
309
|
+
url: "https://www.figma.com/design/qKsxl3ogIlBp7dafgxXuCA/QGDS-UI-kit?node-id=5990-97604&p=f&t=LpEqEay1h4fgTRLl-0",
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
export const Default = {
|
|
315
|
+
args: {
|
|
316
|
+
"Nav alternativeColor": false,
|
|
317
|
+
"Nav verticalOrientation": false,
|
|
318
|
+
"Nav navbarBrandName": "",
|
|
319
|
+
"Add Navigation Item": 0,
|
|
320
|
+
// Initialize base items with iconName
|
|
321
|
+
...(() => {
|
|
322
|
+
const args = {};
|
|
323
|
+
if (defaultdata.navigation) {
|
|
324
|
+
defaultdata.navigation.forEach((item) => {
|
|
325
|
+
const baseName = item.text.replace(/\s+/g, "");
|
|
326
|
+
args[`${baseName}_iconName`] = item.iconName || "";
|
|
327
|
+
args[`${baseName}_text`] = item.text;
|
|
328
|
+
args[`${baseName}_hideLabel`] = item.hideLabel || false;
|
|
329
|
+
args[`${baseName}_mobileOnly`] = item.mobileOnly || false;
|
|
330
|
+
args[`${baseName}_alternativeColor`] = item.alternativeColor || false;
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Initialize new items with iconName
|
|
335
|
+
for (let i = 0; i < 3; i++) {
|
|
336
|
+
args[`newItem${i}_iconName`] = "";
|
|
337
|
+
args[`newItem${i}_text`] = `New Item ${i + 1}`;
|
|
338
|
+
args[`newItem${i}_hideLabel`] = false;
|
|
339
|
+
args[`newItem${i}_mobileOnly`] = false;
|
|
340
|
+
args[`newItem${i}_alternativeColor`] = false;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
return args;
|
|
344
|
+
})(),
|
|
345
|
+
},
|
|
346
|
+
|
|
347
|
+
// Add custom render function for this story only
|
|
348
|
+
render: (args) => {
|
|
349
|
+
// Create a copy of default data
|
|
350
|
+
const data = JSON.parse(JSON.stringify(defaultdata));
|
|
351
|
+
const addCount = args["Add Navigation Item"] || 0;
|
|
352
|
+
const baseItemCount = defaultdata.navigation?.length || 0;
|
|
353
|
+
|
|
354
|
+
// Rebuild navigation completely
|
|
355
|
+
data.navigation = [];
|
|
356
|
+
|
|
357
|
+
// Add base items
|
|
358
|
+
for (let i = 0; i < baseItemCount; i++) {
|
|
359
|
+
const originalItem = defaultdata.navigation[i];
|
|
360
|
+
const itemName = originalItem.text;
|
|
361
|
+
|
|
362
|
+
data.navigation.push({
|
|
363
|
+
...originalItem,
|
|
364
|
+
text: args[`${itemName.replace(/\s+/g, "")}_text`] || originalItem.text,
|
|
365
|
+
hideLabel:
|
|
366
|
+
args[`${itemName.replace(/\s+/g, "")}_hideLabel`] !== undefined
|
|
367
|
+
? args[`${itemName.replace(/\s+/g, "")}_hideLabel`]
|
|
368
|
+
: originalItem.hideLabel,
|
|
369
|
+
mobileOnly:
|
|
370
|
+
args[`${itemName.replace(/\s+/g, "")}_mobileOnly`] !== undefined
|
|
371
|
+
? args[`${itemName.replace(/\s+/g, "")}_mobileOnly`]
|
|
372
|
+
: originalItem.mobileOnly,
|
|
373
|
+
alternativeColor:
|
|
374
|
+
args[`${itemName.replace(/\s+/g, "")}_alternativeColor`] !== undefined
|
|
375
|
+
? args[`${itemName.replace(/\s+/g, "")}_alternativeColor`]
|
|
376
|
+
: originalItem.alternativeColor,
|
|
377
|
+
iconName:
|
|
378
|
+
args[`${itemName.replace(/\s+/g, "")}_iconName`] ||
|
|
379
|
+
originalItem.iconName ||
|
|
380
|
+
"",
|
|
381
|
+
});
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// Add new items
|
|
385
|
+
for (let i = 0; i < addCount; i++) {
|
|
386
|
+
const newItem = {
|
|
387
|
+
text: args[`newItem${i}_text`] || `New Item ${i + 1}`,
|
|
388
|
+
hideLabel: args[`newItem${i}_hideLabel`] || false,
|
|
389
|
+
mobileOnly: args[`newItem${i}_mobileOnly`] || false,
|
|
390
|
+
alternativeColor: args[`newItem${i}_alternativeColor`] || false,
|
|
391
|
+
iconName: args[`newItem${i}_iconName`] || "",
|
|
392
|
+
url: "#",
|
|
393
|
+
cssClass: "",
|
|
394
|
+
target_url: "#",
|
|
395
|
+
dropdown_enabled: false,
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
data.navigation.push(newItem);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// Apply metadata
|
|
402
|
+
data.metadata = data.metadata || {};
|
|
403
|
+
data.metadata.alternativeColor = args["Nav alternativeColor"] || false;
|
|
404
|
+
data.metadata.verticalOrientation =
|
|
405
|
+
args["Nav verticalOrientation"] || false;
|
|
406
|
+
data.metadata.navbarBrandName = args["Nav navbarBrandName"] || "";
|
|
407
|
+
|
|
408
|
+
try {
|
|
409
|
+
const navbarInstance = new Navbar(data);
|
|
410
|
+
let html = navbarInstance.html;
|
|
411
|
+
|
|
412
|
+
// Apply modifications with UNIQUE class names
|
|
413
|
+
data.navigation.forEach((item) => {
|
|
414
|
+
if (!item.text) return;
|
|
415
|
+
|
|
416
|
+
const escapedText = item.text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
417
|
+
|
|
418
|
+
if (item.hideLabel) {
|
|
419
|
+
html = html.replace(
|
|
420
|
+
new RegExp(`(<a[^>]*>)(${escapedText})(</a>)`, "gi"),
|
|
421
|
+
`$1<span class="sr-only">$2</span>$3`,
|
|
422
|
+
);
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
if (item.mobileOnly) {
|
|
426
|
+
const textPos = html.indexOf(item.text);
|
|
427
|
+
if (textPos !== -1) {
|
|
428
|
+
let liStart = html.lastIndexOf("<li", textPos);
|
|
429
|
+
if (liStart !== -1) {
|
|
430
|
+
let liEnd = html.indexOf(">", liStart);
|
|
431
|
+
if (liEnd !== -1) {
|
|
432
|
+
const originalLiTag = html.substring(liStart, liEnd + 1);
|
|
433
|
+
let newLiTag;
|
|
434
|
+
|
|
435
|
+
if (originalLiTag.includes('class="')) {
|
|
436
|
+
newLiTag = originalLiTag.replace(
|
|
437
|
+
'class="',
|
|
438
|
+
'class="qgds-mobile-only qgds-hide-desktop ',
|
|
439
|
+
);
|
|
440
|
+
} else {
|
|
441
|
+
newLiTag = originalLiTag.replace(
|
|
442
|
+
"<li",
|
|
443
|
+
'<li class="qgds-mobile-only qgds-hide-desktop"',
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
html =
|
|
448
|
+
html.substring(0, liStart) +
|
|
449
|
+
newLiTag +
|
|
450
|
+
html.substring(liEnd + 1);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
if (item.alternativeColor) {
|
|
457
|
+
const textPos = html.indexOf(item.text);
|
|
458
|
+
if (textPos !== -1) {
|
|
459
|
+
let liStart = html.lastIndexOf("<li", textPos);
|
|
460
|
+
if (liStart !== -1) {
|
|
461
|
+
let liEnd = html.indexOf(">", liStart);
|
|
462
|
+
if (liEnd !== -1) {
|
|
463
|
+
const originalLiTag = html.substring(liStart, liEnd + 1);
|
|
464
|
+
let newLiTag;
|
|
465
|
+
|
|
466
|
+
if (originalLiTag.includes('class="')) {
|
|
467
|
+
newLiTag = originalLiTag.replace(
|
|
468
|
+
'class="',
|
|
469
|
+
'class="qgds-alt-color ',
|
|
470
|
+
);
|
|
471
|
+
} else {
|
|
472
|
+
newLiTag = originalLiTag.replace(
|
|
473
|
+
"<li",
|
|
474
|
+
'<li class="qgds-alt-color"',
|
|
475
|
+
);
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
html =
|
|
479
|
+
html.substring(0, liStart) +
|
|
480
|
+
newLiTag +
|
|
481
|
+
html.substring(liEnd + 1);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
|
|
488
|
+
// Add CSS with UNIQUE class names and higher specificity
|
|
489
|
+
const styles = `
|
|
490
|
+
<style>
|
|
491
|
+
.css-sx1422 { height: auto !important; }
|
|
492
|
+
.sb-show-main.sb-main-padded { padding: 0 !important; }
|
|
493
|
+
#storybook-only-header {
|
|
494
|
+
position: relative;
|
|
495
|
+
z-index: 11;
|
|
496
|
+
background: #f8f9fa;
|
|
497
|
+
border-bottom: 1px solid #ddd;
|
|
498
|
+
display: flex;
|
|
499
|
+
justify-content: flex-end;
|
|
500
|
+
align-items: center;
|
|
501
|
+
}
|
|
502
|
+
@media (width <= 992px) {
|
|
503
|
+
#burgerBtn {
|
|
504
|
+
display: flex !important;
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
@media (width >= 992px) {
|
|
508
|
+
#burgerBtn, #storybook-only-header {
|
|
509
|
+
display: none !important;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
</style>
|
|
513
|
+
`;
|
|
514
|
+
|
|
515
|
+
const navbarHTML = styles + html + `<!-- Render: ${Date.now()} -->`;
|
|
516
|
+
|
|
517
|
+
// HTML that appears before the navbar (Storybook only)
|
|
518
|
+
const beforeHTML = `
|
|
519
|
+
<div id="storybook-only-header">
|
|
520
|
+
<button id="burgerBtn" class="btn btn-primary" type="button" data-bs-toggle="collapse" data-bs-target="#main-nav" aria-expanded="false" aria-controls="collapseExample">
|
|
521
|
+
<span class="qld-icon qld-icon-xl qld-icon-menu"></span>
|
|
522
|
+
Menu
|
|
523
|
+
</button>
|
|
524
|
+
</div>
|
|
525
|
+
`;
|
|
526
|
+
|
|
527
|
+
return beforeHTML + navbarHTML;
|
|
528
|
+
} catch (error) {
|
|
529
|
+
console.error("Error:", error);
|
|
530
|
+
return `<div style="color: red; padding: 20px;"><h3>Error</h3><p>${error.message}</p></div>`;
|
|
531
|
+
}
|
|
532
|
+
},
|
|
533
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Component from "../../../js/QGDSComponent.js";
|
|
2
|
-
import template from "./templates/
|
|
2
|
+
import template from "./templates/homePage.hbs?raw";
|
|
3
3
|
|
|
4
|
-
export class
|
|
4
|
+
export class HomePage {
|
|
5
5
|
constructor(data = {}) {
|
|
6
6
|
return new Component(template, data);
|
|
7
7
|
}
|