@pure-ds/core 0.5.19 → 0.5.20

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pure-ds/core",
3
3
  "shortname": "pds",
4
- "version": "0.5.19",
4
+ "version": "0.5.20",
5
5
  "description": "Pure Design System - Why develop a Design System when you can generate one?",
6
6
  "repository": {
7
7
  "type": "git",
@@ -303,32 +303,39 @@ customElements.define(
303
303
  }
304
304
 
305
305
  function buildAppJs() {
306
- return `import { PDS } from '@pure-ds/core';
307
- import { config } from '../../pds.config.js';
306
+ return `import { PDS } from "@pure-ds/core";
307
+ import { config } from "../../pds.config.js";
308
308
 
309
309
  await PDS.start(config);
310
- PDS.theme = 'light';
311
310
 
312
- const main = document.querySelector('main');
313
- if (main && !main.querySelector('my-home')) {
314
- main.innerHTML = '<my-home></my-home>';
311
+ const main = document.querySelector("main");
312
+ if (main && !main.querySelector("my-home")) {
313
+ main.innerHTML = "<my-home></my-home>";
315
314
  }
316
315
 
317
- const settingsBtn = document.createElement('button');
318
- settingsBtn.id = 'settings-btn';
319
- settingsBtn.className = 'icon-only btn-xs btn-outline';
320
- settingsBtn.setAttribute('aria-label', 'Settings');
321
- settingsBtn.innerHTML = '<pds-icon icon="gear"></pds-icon>';
316
+ /**
317
+ * Generates an HTML NodeList by parsing the given HTML string
318
+ * @param {String} html
319
+ * @returns {NodeListOf<ChildNode>} DOM element
320
+ */
321
+ const parseHTML = (html) => {
322
+ return new DOMParser().parseFromString(html, "text/html").body.childNodes;
323
+ };
324
+
325
+ const settingsBtn = parseHTML(
326
+ /*html*/
327
+ \`\n <button id="settings-btn" class="icon-only btn-xs btn-outline" aria-label="Settings">\n <pds-icon icon="gear"></pds-icon>\n </button>\`,
328
+ )[0];
329
+
322
330
  document.body.appendChild(settingsBtn);
323
331
 
324
- const drawer = document.createElement('pds-drawer');
325
- drawer.setAttribute('position', 'right');
326
- drawer.innerHTML =
327
- '<div slot="drawer-header">Settings</div>' +
328
- '<div slot="drawer-content"><my-theme></my-theme></div>';
332
+ const drawer = document.createElement("pds-drawer");
333
+ drawer.setAttribute("position", "right");
334
+
335
+ drawer.innerHTML = /*html*/ \`<div slot="drawer-header">Settings</div>\n <div slot="drawer-content"><my-theme></my-theme></div>\`;
329
336
  document.body.appendChild(drawer);
330
337
 
331
- settingsBtn.addEventListener('click', () => {
338
+ settingsBtn.addEventListener("click", () => {
332
339
  drawer.open = true;
333
340
  });
334
341
  `;