Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QOLOE-515 - refactor: Cleaner dev structure #6

Merged
merged 3 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 25 additions & 54 deletions src/breadcrumbs/main.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,31 @@
* Common js module to support DXP Component Service.
*/
module.exports = async function (input, info) {
const getBreadcrumbData = function () {
let breadcrumbHtml = "";
const navData = [
{
link: "#",
linktext: "Home",
},
{
link: "#",
linktext: "Topic 01",
},
{
link: "#",
linktext: "Topic 02",
},
{
link: "#",
linktext: "Topic 03",
},
{
link: "#",
linktext: "Current page",
},
];
const breadcrumbLength = Number(navData.length);

for (const navItems in navData) {
if (Number(navItems) + 1 < breadcrumbLength) {
breadcrumbHtml += `<li class="breadcrumb-item">
<a href="${navData[navItems].link}">
${navData[navItems].linktext}
</a>
</li>`;
} else {
breadcrumbHtml += `<li class="breadcrumb-item active" aria-current="page" data-href="${navData[navItems].link}">
${navData[navItems].linktext}
</li>`;
}
}

return breadcrumbHtml;
};
const itemLength = input.breadcrumbs.length;
const items = input.breadcrumbs
.map(
(item, i) => `
<li class="breadcrumb-item">
${i + 1 < itemLength ? `<a href="${item.link}">` : ""}
${item.linktext}
${i + 1 < itemLength ? `</a>` : ""}
</li>
`
)
.join("");
return `
<div class="container-fluid ${input.colour}">
<div class="container">
<div class="row">
<div class="container-xl">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
${getBreadcrumbData()}
</ol>
</nav>
</div>
</div>
<div class="container-fluid ${input.brandOverride ? input.brandOverride : ""}">
<div class="container">
<div class="row">
<div class="container-xl">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
${items}
</ol>
</nav>
</div>
</div>`;
</div>
</div>
</div>
`;
};
26 changes: 22 additions & 4 deletions src/breadcrumbs/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "http://localhost:3000/schemas/v1.json#",
"version": "1.0.1",
"version": "1.0.17",
"name": "breadcrumbs",
"displayName": "Breadcrumbs Component",
"description": "QGDS Bootstrap 5 - Breadcrumbs Component",
Expand All @@ -16,11 +16,29 @@
"input": {
"type": "object",
"properties": {
"colour": {
"type": "string"
"brandOverride": {
"title": "brand override",
"type": "string",
"enum": ["", "light", "dark", "alt", "dark-alt"]
},
"breadcrumbs": {
"title": "Breadchrumb items array",
"type": "array",
"items": {
"type": "object",
"properties": {
"link": {
"type": "string"
},
"linktext": {
"type": "string"
}
},
"required": ["link", "linktext"]
}
}
},
"required": []
"required": ["breadcrumbs"]
},
"output": {
"responseType": "html",
Expand Down
28 changes: 27 additions & 1 deletion src/breadcrumbs/previews/example.data.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
{
"colour": " alt"
"brandOverride": "alt",
"breadcrumbs": [
{
"link": "#",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could update to have the real data that's on forgov for a more lifelike example.

"linktext": "For government"
},
{
"link": "#",
"linktext": "Information and communication technology"
},
{
"link": "#",
"linktext": "Communication and publishing"
},
{
"link": "#",
"linktext": "Website and digital publishing"
},
{
"link": "#",
"linktext": "Website standards, guidelines and templates"
},
{
"link": "#",
"linktext": "Single Website Experience"
}
]
}
5 changes: 0 additions & 5 deletions src/breadcrumbs/previews/preview.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

<head>
[component://static-header]
<!-- <link rel="stylesheet"
href="https://www.forgov.qld.gov.au/__data/assets/git_bridge/0030/498603/assets/css/qld.bootstrap.css">
<link rel="stylesheet"
href="https://www.forgov.qld.gov.au/__data/assets/css_file_folder/0029/499142/QGDS-forgov-shim.css"> -->

</head>

<body>
Expand Down