@pure-ds/core 0.5.24 → 0.5.26

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.
@@ -0,0 +1,59 @@
1
+ const defaultEnhancers = Array.isArray(globalThis.PDS?.defaultEnhancers)
2
+ ? globalThis.PDS.defaultEnhancers
3
+ : [];
4
+
5
+ export const config = {
6
+ mode: "static",
7
+ preset: "social-feed",
8
+
9
+ autoDefine: {
10
+ predefine: ["pds-icon", "pds-drawer", "pds-toaster"],
11
+
12
+ // Custom component paths
13
+ mapper: (tag) => {
14
+ if (tag.startsWith("my-")) return `/assets/my/${tag}.js`;
15
+
16
+ // Return nothing to use PDS default mapping
17
+ },
18
+
19
+ enhancers: [
20
+ ...defaultEnhancers,
21
+ {
22
+ selector: ".hero",
23
+ description: "Make PDS border-gradient rotate slowly",
24
+ run: (element) => {
25
+ let angle = 135;
26
+ const speed = 0.5; // degrees per frame (~30 degrees/second at 60fps)
27
+
28
+ function animate() {
29
+ angle = (angle + speed) % 360;
30
+ element.style.setProperty("--gradient-angle", `${angle}deg`);
31
+ requestAnimationFrame(animate);
32
+ }
33
+
34
+ animate();
35
+ },
36
+ },
37
+ ],
38
+ },
39
+
40
+ // Uncomment to override preset design tokens:
41
+ // design: {
42
+ // colors: {
43
+ // primary: '#007acc',
44
+ // secondary: '#5c2d91',
45
+ // accent: '#ec4899'
46
+ // },
47
+ // typography: {
48
+ // fontFamilyHeadings: 'Inter, sans-serif',
49
+ // fontFamilyBody: 'Inter, sans-serif',
50
+ // baseFontSize: 16,
51
+ // fontScale: 1.25
52
+ // },
53
+ // spatialRhythm: {
54
+ // baseUnit: 8,
55
+ // scaleRatio: 1.5
56
+ // }
57
+ // }
58
+
59
+ };
@@ -0,0 +1,59 @@
1
+ html:not(.pds-ready) {
2
+ opacity: 0;
3
+ }
4
+
5
+ main {
6
+ margin: auto;
7
+ }
8
+
9
+ h1 {
10
+ background: linear-gradient(var(--gradient-angle, 135deg),
11
+ var(--color-primary-400),
12
+ var(--color-accent-400)
13
+ );
14
+ background-clip: text;
15
+ -webkit-background-clip: text;
16
+ color: transparent;
17
+ }
18
+
19
+ .container {
20
+ display: grid;
21
+ grid-template-rows: auto 1fr auto;
22
+ height: 100dvh;
23
+ padding: 0;
24
+ }
25
+
26
+ header, footer {
27
+ padding: var(--spacing-4);
28
+ }
29
+
30
+ footer {
31
+ text-align: center;
32
+ }
33
+
34
+ .auto-gen {
35
+ color: var(--color-text-muted);
36
+ font-size: var(--font-size-xs);
37
+ }
38
+
39
+ #settings-btn {
40
+ position: fixed;
41
+ top: var(--spacing-4);
42
+ right: var(--spacing-4);
43
+ }
44
+
45
+ .hero {
46
+ padding: var(--spacing-8);
47
+ zoom: 1.15;
48
+ text-align: center;
49
+ border: var(--border-width-medium) solid transparent;
50
+ background: linear-gradient(var(--color-surface-base), var(--color-surface-base)) padding-box,
51
+ linear-gradient(var(--gradient-angle, 135deg), var(--color-primary-400), var(--color-accent-400)) border-box;
52
+ max-width: var(--max-w-lg);
53
+ border-radius: var(--radius-lg);
54
+ border-width: 3px;
55
+ }
56
+
57
+ .hero > div {
58
+ margin: var(--spacing-10) 0;
59
+ }
@@ -0,0 +1,18 @@
1
+ const shouldConnect =
2
+ location.hostname === "localhost" || location.hostname === "127.0.0.1";
3
+
4
+ if (shouldConnect) {
5
+ const reloadPort = 4174;
6
+ const endpoint = "http://localhost:" + reloadPort + "/events";
7
+ const source = new EventSource(endpoint);
8
+
9
+ source.onmessage = (event) => {
10
+ if (event.data === "reload") {
11
+ location.reload();
12
+ }
13
+ };
14
+
15
+ source.onerror = () => {
16
+ source.close();
17
+ };
18
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * @file my-home.js
3
+ * @description A simple home component for the app.
4
+ */
5
+ customElements.define(
6
+ "my-home",
7
+ class extends HTMLElement {
8
+ connectedCallback() {
9
+ this.innerHTML = /*html*/ `
10
+ <article class="hero">
11
+ <h1>Welcome to your new App</h1>
12
+ <div>
13
+ <p>
14
+ This <code>&lt;my-home&gt;</code> Web Component is lazy-loaded and styled with Pure Design System.
15
+ </p>
16
+ <p>
17
+ You can start building your app by editing the files in <code>public/assets/my/</code> and <code>src/js/</code>.
18
+ </p>
19
+ </div>
20
+ <nav>
21
+ <a target="_blank" href="https://github.com/Pure-Web-Foundation/pure-ds/blob/main/getting-started.md" class="btn btn-primary btn-lg">
22
+ <pds-icon icon="rocket"></pds-icon> Get Started
23
+ </a>
24
+ <a target="_blank" href="https://puredesignsystem.z6.web.core.windows.net/storybook/" class="btn btn-secondary btn-lg">
25
+ <pds-icon icon="book-open"></pds-icon> Storybook
26
+ </a>
27
+ </nav>
28
+ </article>
29
+ `;
30
+ }
31
+ },
32
+ );
@@ -0,0 +1,74 @@
1
+ /**
2
+ * my-theme Web Component - allows users to select the app theme (light, dark, system)
3
+ *
4
+ * Uses Pure Design System (PDS) for styling and theming.
5
+ */
6
+ customElements.define(
7
+ "my-theme",
8
+ class extends HTMLElement {
9
+ constructor() {
10
+ super();
11
+ this.attachShadow({ mode: "open" });
12
+ }
13
+
14
+ async connectedCallback() {
15
+ const componentStyles = PDS.createStylesheet(`
16
+ :host {
17
+ display: block;
18
+ }
19
+ `);
20
+
21
+ await PDS.adoptLayers(
22
+ this.shadowRoot,
23
+ ["tokens", "primitives", "components", "utilities"],
24
+ [componentStyles],
25
+ );
26
+
27
+ this.shadowRoot.innerHTML = /*html*/ `<form>
28
+ <fieldset role="radiogroup" aria-label="Theme" class="buttons">
29
+ <legend>Theme</legend>
30
+ <label>
31
+ <input type="radio" name="theme" value="system" />
32
+ <span><pds-icon icon="moon-stars"></pds-icon>System</span>
33
+ </label>
34
+ <label>
35
+ <input type="radio" name="theme" value="light" />
36
+ <span>
37
+ <pds-icon icon="sun"></pds-icon> Light </span>
38
+ </label>
39
+ <label>
40
+ <input type="radio" name="theme" value="dark" />
41
+ <span><pds-icon icon="moon"></pds-icon> Dark </span>
42
+ </label>
43
+ </fieldset>
44
+ </form>
45
+ `;
46
+
47
+ this.updateCheckedState();
48
+
49
+ this.shadowRoot.addEventListener("change", (e) => {
50
+ if (e.target.type === "radio" && e.target.name === "theme") {
51
+ PDS.theme = e.target.value;
52
+ PDS.toast("Theme changed to " + e.target.value, { duration: 2000 });
53
+ }
54
+ });
55
+
56
+ const observer = new MutationObserver(() => {
57
+ this.updateCheckedState();
58
+ });
59
+
60
+ observer.observe(document.documentElement, {
61
+ attributes: true,
62
+ attributeFilter: ["data-theme"],
63
+ });
64
+ }
65
+
66
+ updateCheckedState() {
67
+ const currentTheme = PDS.theme || "system";
68
+ const radios = this.shadowRoot.querySelectorAll('input[type="radio"]');
69
+ radios.forEach((radio) => {
70
+ radio.checked = radio.value === currentTheme;
71
+ });
72
+ }
73
+ },
74
+ );
@@ -0,0 +1,38 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Pure Design System</title>
7
+
8
+ <!-- PDS Styles -->
9
+ <link rel="stylesheet" href="/assets/css/app.css" />
10
+
11
+ <!-- Import Map for Lit components -->
12
+ <script type="importmap">
13
+ {
14
+ "imports": {
15
+ "#pds/lit": "/assets/js/lit.js"
16
+ }
17
+ }
18
+ </script>
19
+
20
+ <!-- Dev live-reload (safe in production, no-op without server) -->
21
+ <script type="module" src="/assets/js/dev-reload.js" defer></script>
22
+
23
+ <!-- App Script -->
24
+ <script type="module" src="/assets/js/app.js" defer></script>
25
+ </head>
26
+
27
+ <body class="container">
28
+ <header class="stack-sm">
29
+ <p class="auto-gen">Auto-generated by PDS {{PDS_VERSION}} at {{PDS_GENERATED_AT}}</p>
30
+ </header>
31
+
32
+ <main></main>
33
+
34
+ <footer class="text-sm text-muted">
35
+ <small>&copy; 2026 Pure Design System</small>
36
+ </footer>
37
+ </body>
38
+ </html>
@@ -0,0 +1,38 @@
1
+ import { PDS } from "@pure-ds/core";
2
+ import { config } from "../../pds.config.js";
3
+
4
+ await PDS.start(config);
5
+
6
+ const main = document.querySelector("main");
7
+ if (main && !main.querySelector("my-home")) {
8
+ main.innerHTML = "<my-home></my-home>";
9
+ }
10
+
11
+ /**
12
+ * Generates an HTML NodeList by parsing the given HTML string
13
+ * @param {String} html
14
+ * @returns {NodeListOf<ChildNode>} DOM element
15
+ */
16
+ const parseHTML = (html) => {
17
+ return new DOMParser().parseFromString(html, "text/html").body.childNodes;
18
+ };
19
+
20
+ const settingsBtn = parseHTML(
21
+ /*html*/ `<button id="settings-btn" class="icon-only btn-xs btn-outline" aria-label="Settings">
22
+ <pds-icon icon="gear"></pds-icon>
23
+ </button>`,
24
+ )[0];
25
+
26
+ document.body.appendChild(settingsBtn);
27
+
28
+ const drawer = document.createElement("pds-drawer");
29
+ drawer.setAttribute("position", "right");
30
+
31
+ drawer.innerHTML = /*html*/ `<div slot="drawer-header">Settings</div>
32
+ <div slot="drawer-content"><my-theme></my-theme></div>`;
33
+
34
+ document.body.appendChild(drawer);
35
+
36
+ settingsBtn.addEventListener("click", () => {
37
+ drawer.open = true;
38
+ });