-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into QOLOE-294-seatchInput-items-styling
- Loading branch information
Showing
99 changed files
with
2,248 additions
and
349 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// updateHandlebarsPartialsPlugin.js | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
import { fileURLToPath } from 'url'; | ||
import { build } from 'esbuild'; | ||
|
||
const __filename = fileURLToPath(import.meta.url); | ||
const __dirname = path.dirname(__filename); | ||
|
||
const COMPONENTS_DIR = path.resolve(__dirname, './../../src/components'); | ||
const PARTIALS_JS_FILE = path.resolve(__dirname, '../../src/js/handlebars.partials.js'); | ||
|
||
|
||
function getAllFiles(dirPath, arrayOfFiles) { | ||
const files = fs.readdirSync(dirPath, { withFileTypes: true }); | ||
|
||
arrayOfFiles = arrayOfFiles || []; | ||
|
||
files.forEach((file) => { | ||
//console.log(file); | ||
if (file.isDirectory()) { | ||
arrayOfFiles = getAllFiles(path.join(dirPath, file.name), arrayOfFiles); | ||
} else if (file.isFile() && (file.name.endsWith('.hbs') && !file.name.endsWith('.test.hbs'))) { | ||
arrayOfFiles.push(path.join(dirPath, file.name)); | ||
} | ||
}); | ||
|
||
return arrayOfFiles; | ||
} | ||
|
||
export default function QGDSupdateHandlebarsPartialsPlugin() { | ||
return { | ||
name: 'update-handlebars-partials', | ||
setup(build) { | ||
build.onStart(async () => { | ||
|
||
const files = getAllFiles(COMPONENTS_DIR); | ||
//console.log(files); | ||
const fileNames = new Map(); | ||
let duplicateFound = false; | ||
|
||
let importLines = ''; | ||
let registerLines = ''; | ||
|
||
for (const file of files) { | ||
//console.log(file); | ||
const componentName = path.basename(file, '.hbs') | ||
//console.log(componentName); | ||
// Duplicate check | ||
if (fileNames.has(componentName)) { | ||
console.error(`Error: Duplicate component name found: "${componentName}" second partial located at ${file} and ${fileNames.get(componentName)}`); | ||
duplicateFound = true; | ||
continue; | ||
} | ||
fileNames.set(componentName, file); | ||
|
||
const importName = componentName.replace(/-/g, ''); | ||
const componentPath = path.relative(path.dirname(PARTIALS_JS_FILE), file).replace(/\\/g, '/'); | ||
|
||
importLines += `import ${importName} from "${componentPath}?raw";\n`; | ||
registerLines += ` handlebars.registerPartial("${componentName}", ${importName});\n`; | ||
} | ||
|
||
if (duplicateFound) { | ||
process.exit(1); | ||
} | ||
|
||
const newContent = `/** THIS IS A GENERATED FILE **/ | ||
${importLines} | ||
/** | ||
* Registers Handlebars Partials | ||
* @param {Handlebars} handlebars Templating engine | ||
* @returns {void} Result of the helper operation | ||
*/ | ||
export default function handlebarsPartials(handlebars) { | ||
${registerLines} | ||
} | ||
`; | ||
|
||
fs.writeFileSync(PARTIALS_JS_FILE, newContent); | ||
console.log('handlebar.partials.js has been updated.'); | ||
}); | ||
}, | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,7 +96,7 @@ const preview = { | |
}, | ||
], | ||
|
||
tags: ["autodocs", "autodocs"] | ||
tags: ["autodocs"] | ||
}; | ||
|
||
export default preview; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -92,4 +92,4 @@ export function breadcrumbExpand(event) { | |
crumb.querySelector('a').setAttribute('tabindex', 0) | ||
} | ||
}) | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
src/components/bs5/breadcumbsWrapper/breadcrumbsWrapper.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!-- breadcrumbs--> | ||
<div class="container-fluid alt"> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="container-xl"> | ||
|
||
{{> @partial-block }} | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
38 changes: 38 additions & 0 deletions
38
src/components/bs5/breadcumbsWrapper/breadcrumbsWrapper.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { forGov } from "../breadcrumbs/breadcrumbs.data.json"; | ||
import { BreadcrumbsWrapperTest } from "./breadcrumbsWrapper.test.js"; | ||
// eslint-disable-next-line no-unused-vars | ||
import init from "../../../js/handlebars.init.js"; //self init's when loaded | ||
|
||
const defaultData = { breadcrumbs: forGov }; | ||
|
||
export default { | ||
title: "!Layout/Components/Breadcrumbs Wrapper", | ||
render: (args) => { | ||
|
||
return new BreadcrumbsWrapperTest(args).html; | ||
}, | ||
args: defaultData, | ||
argTypes: { | ||
}, | ||
parameters: { | ||
docs: { | ||
controls: { | ||
|
||
}, | ||
}, | ||
}, | ||
decorators: [ | ||
(Story) => { | ||
return ` | ||
${Story()} | ||
`; | ||
}, | ||
], | ||
}; | ||
|
||
/** | ||
* Default head metadata | ||
* | ||
*/ | ||
export const Default = {}; | ||
|
7 changes: 7 additions & 0 deletions
7
src/components/bs5/breadcumbsWrapper/breadcrumbsWrapper.test.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
header before | ||
<main> | ||
{{#>breadcrumbsWrapper}} | ||
{{> breadcrumbs breadcrumbs }} | ||
{{/breadcrumbsWrapper}} | ||
content after | ||
</main> |
13 changes: 13 additions & 0 deletions
13
src/components/bs5/breadcumbsWrapper/breadcrumbsWrapper.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Component from '../../../js/QGDSComponent.js' | ||
import template from "./breadcrumbsWrapper.test.hbs?raw"; | ||
|
||
export class BreadcrumbsWrapperTest { | ||
|
||
// Use the global Component class to create a new instance of the Sidenav component. | ||
// A data object, containing the Handlebars placeholder replacement strings, should be provided as an argument. | ||
|
||
constructor( data = {} ) { | ||
return new Component(template, data); | ||
} | ||
|
||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"lastUpdated": "1900-01-31" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<dl class="qld-content-dates"> | ||
<dt>Last updated:</dt> | ||
<dd>{{formatDateOrToday lastUpdated }}</dd> | ||
</dl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Component from '../../../js/QGDSComponent.js' | ||
import template from "./contentFooter.hbs?raw"; | ||
|
||
export class ContentFooter { | ||
|
||
// A data object, containing the Handlebars placeholder replacement strings, should be provided as an argument. | ||
constructor(data = {}) { | ||
return new Component(template, data); | ||
} | ||
} |
Oops, something went wrong.