diff --git a/README.md b/README.md index 4ac3059..e8d7a7c 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ The library includes functions for rendering common ACCESS user interface compon ## Example +### ES6 ```html
@@ -124,3 +125,94 @@ The library includes functions for rendering common ACCESS user interface compon footer({ target: document.getElementById("footer") }); ``` + +### Plain Javascript + +The components will be created for those defined in window.ACCESS_CI_UI_CONFIG. As long as each component +has at least {} or true as its value, the components will be generated successfully. + +```html +
+ + +
+
+

Page Title

+

First Section

+

Second Section

+

Third Section

+
+
+
+ + + + +``` diff --git a/package.json b/package.json index 1a785e2..c007ae6 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,10 @@ "scripts": { "dev": "vite", "build": "vite build", - "preview": "vite preview" + "preview": "vite preview", + "preversion": "", + "version": "npm run build && esbuild ./dist/access-ci-ui.js --bundle --outfile=./dist/access-ci-ui.esbuild.js && git add -f -A dist", + "postversion": "git push && git push --tags" }, "dependencies": { "preact": "^10.24.1" diff --git a/src/index.jsx b/src/index.jsx index 385b3c8..e70a008 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -5,6 +5,52 @@ import { loginMenuItem, myAccessMenuItem, universalMenuItems } from "./items"; import { TableOfContents } from "./table-of-contents"; import { renderShadow } from "./utils"; +const windowParamConfig = {...window.ACCESS_CI_UI_CONFIG}; +console.log("windowParamConfig", windowParamConfig) + +const paramConfig = { + universalMenus: { + loginUrl: "/login", + logoutUrl: "/logout", + siteName: "Allocations", + targetId: "universal-menus", + ...windowParamConfig.universalMenus + }, + header: { + siteName: "Allocations", + targetId: "header", + ...windowParamConfig.header + }, + siteMenus: { + items: [], + siteName: "Allocations", + targetId: "site-menus", + ...windowParamConfig.siteMenus + }, + tableOfContents: { + headings: document.querySelectorAll("#body h1, #body h2"), + targetId: "table-of-contents", + ...windowParamConfig.tableOfContents + }, + footerMenus: { + items: [], + targetId: "footer-menus", + ...windowParamConfig.footerMenus + }, + footer: { + targetId: "footer", + ...windowParamConfig.footer + } +}; + +console.log("paramConfig", paramConfig) + +for (let key in paramConfig) { + if (!paramConfig[key].target) { + paramConfig[key].target = document.getElementById(paramConfig[key].targetId) + } +} + const footer = (params = {}) => { renderShadow(