diff --git a/dprint.json b/dprint.json index 7c796fe..6dec128 100644 --- a/dprint.json +++ b/dprint.json @@ -1,15 +1,9 @@ { - "typescript": { - }, - "json": { - }, - "markdown": { - }, - "excludes": [ - "**/node_modules", - "**/*-lock.json", - "/.yarn/**/*" - ], + "lineWidth": 80, + "typescript": {}, + "json": {}, + "markdown": {}, + "excludes": ["**/node_modules", "**/*-lock.json", "/.yarn/**/*"], "plugins": [ "https://plugins.dprint.dev/typescript-0.88.3.wasm", "https://plugins.dprint.dev/json-0.19.0.wasm", diff --git a/scripts/build-service-workers.cjs b/scripts/build-service-workers.cjs index 54887f8..1eeae0a 100644 --- a/scripts/build-service-workers.cjs +++ b/scripts/build-service-workers.cjs @@ -43,8 +43,8 @@ async function buildServiceWorkers(outDir) { sourcemap: IS_DEV ? "inline" : false, platform: "browser", define: { - __DEV__: String(IS_DEV), - } + __DEV__: String(IS_DEV), + }, }); })); } diff --git a/scripts/build.cjs b/scripts/build.cjs index 17cf42d..075c712 100644 --- a/scripts/build.cjs +++ b/scripts/build.cjs @@ -104,9 +104,9 @@ build() if (ev === "addDir") return; if ( - fPath.includes("src/assets") && - !fPath.includes("src/assets/js") && - !fPath.includes("src/assets/css") + fPath.includes("src/assets") + && !fPath.includes("src/assets/js") + && !fPath.includes("src/assets/css") ) { console.log( `Asset changed, copying (${path.relative(p("."), fPath)})`, diff --git a/scripts/tmpl-builder.cjs b/scripts/tmpl-builder.cjs index a589372..df51b14 100644 --- a/scripts/tmpl-builder.cjs +++ b/scripts/tmpl-builder.cjs @@ -9,7 +9,8 @@ const { ExtFilesCtx } = require("./external-files-context.cjs"); const crypto = require("crypto"); function createHash(data, len) { - return crypto.createHash("shake256", { outputLength: len }).update(data).digest("hex"); + return crypto.createHash("shake256", { outputLength: len }).update(data) + .digest("hex"); } const IS_DEV = process.argv.includes("--dev"); @@ -53,7 +54,9 @@ module.exports.buildTemplate = async function buildTemplate(template, outDir) { const Component = modExports.default; if (typeof Component !== "function") { - throw new Error(`Template ${tsxFilename} does not export a default function.`); + throw new Error( + `Template ${tsxFilename} does not export a default function.`, + ); } /** @type {{ contents: string; outFile: string }[]} */ @@ -63,12 +66,18 @@ module.exports.buildTemplate = async function buildTemplate(template, outDir) { switch (type) { case "css": { const fPath = `/assets/css/${hashedName}.css`; - registeredExtFiles.push({ contents, outFile: path.join(outDir, fPath) }); + registeredExtFiles.push({ + contents, + outFile: path.join(outDir, fPath), + }); return fPath; } case "js": { const fPath = `/assets/js/${hashedName}.js`; - registeredExtFiles.push({ contents, outFile: path.join(outDir, fPath) }); + registeredExtFiles.push({ + contents, + outFile: path.join(outDir, fPath), + }); return fPath; } } @@ -77,7 +86,11 @@ module.exports.buildTemplate = async function buildTemplate(template, outDir) { let html; try { html = await renderToHtmlAsync( - jsx(ExtFilesCtx.Provider, { value: { register: registerExternalFile } }, jsx(Component, {})), + jsx( + ExtFilesCtx.Provider, + { value: { register: registerExternalFile } }, + jsx(Component, {}), + ), { pretty: true }, ); } catch (e) { diff --git a/src/components/code-sample.tsx b/src/components/code-sample.tsx index 2a9cd95..19ee29c 100644 --- a/src/components/code-sample.tsx +++ b/src/components/code-sample.tsx @@ -12,7 +12,10 @@ declare global { } } -export async function CodeSample(props: JSXTE.PropsWithChildren<{}>, componentApi: ComponentApi) { +export async function CodeSample( + props: JSXTE.PropsWithChildren<{}>, + componentApi: ComponentApi, +) { const asString = componentApi.render(<>{props.children}, { pretty: true }); const formatted = (await prettier.format(asString, { parser: "html", diff --git a/src/components/example.tsx b/src/components/example.tsx index b90db34..3b09f58 100644 --- a/src/components/example.tsx +++ b/src/components/example.tsx @@ -1,7 +1,7 @@ import { Button, Typography } from "adwavecss"; import { cls } from "../utils/cls"; -import { url } from "../utils/url"; import { escapeHtml } from "../utils/escape-html"; +import { url } from "../utils/url"; export function Example( props: JSXTE.PropsWithChildren<{ @@ -38,13 +38,11 @@ export function ExampleSection( Button.flat, Button.square, )} - onclick={ - /* js */ ` + onclick={/* js */ ` const href = new window.URL(window.location.href); href.hash = this.dataset.anchor; navigator.clipboard.writeText(href.toString()); - ` - } + `} > diff --git a/src/components/font-size-selector.client.ts b/src/components/font-size-selector.client.ts index 31bf9b8..39dcfc0 100644 --- a/src/components/font-size-selector.client.ts +++ b/src/components/font-size-selector.client.ts @@ -3,12 +3,15 @@ class FontSizeSelector extends HTMLDivElement { previewElement!: HTMLButtonElement; connectedCallback() { - const browserDefault = this.currentFontSize = this.getBrowserDefaultFontSize(); + const browserDefault = this.currentFontSize = this + .getBrowserDefaultFontSize(); this.loadFromLocalStorage(); const btnDecrease = this.querySelector("#btn-decrease")!; const btnIncrease = this.querySelector("#btn-increase")!; - this.previewElement = this.querySelector(".font-size-preview") as HTMLButtonElement; + this.previewElement = this.querySelector( + ".font-size-preview", + ) as HTMLButtonElement; btnDecrease.addEventListener("click", this.handleDecrease); btnIncrease.addEventListener("click", this.handleIncrease); @@ -58,4 +61,6 @@ class FontSizeSelector extends HTMLDivElement { }; } -window.customElements.define("font-size-selector", FontSizeSelector, { extends: "div" }); +window.customElements.define("font-size-selector", FontSizeSelector, { + extends: "div", +}); diff --git a/src/components/theme-switcher.client.ts b/src/components/theme-switcher.client.ts index f8973ef..bf4de44 100644 --- a/src/components/theme-switcher.client.ts +++ b/src/components/theme-switcher.client.ts @@ -12,7 +12,9 @@ class PersistentStorage { private static THEME_KEY = "theme"; public static getTheme() { - const localStorageTheme = localStorage.getItem(this.THEME_KEY) as Theme | null; + const localStorageTheme = localStorage.getItem(this.THEME_KEY) as + | Theme + | null; if (localStorageTheme) { return localStorageTheme; } @@ -24,7 +26,9 @@ class PersistentStorage { } function getCurrentTheme(): Theme { - const theme = Array.from(document.body.classList.values()).find(c => c.endsWith("theme")); + const theme = Array.from(document.body.classList.values()).find(c => + c.endsWith("theme") + ); if (theme) { return theme as Theme; } diff --git a/src/layout.tsx b/src/layout.tsx index 31fe384..555a788 100644 --- a/src/layout.tsx +++ b/src/layout.tsx @@ -25,52 +25,25 @@ export function Layout( - - {props.title ? `ADWave Docs - ${props.title}` : "ADWave Docs"} - - ; } const extFiles = componentApi.ctx.getOrFail(EFC.ExtFilesCtx); - const src = extFiles.register(contents, props.package ?? path.basename(props.path), "css"); + const src = extFiles.register( + contents, + props.package ?? path.basename(props.path), + "css", + ); return ( - +
-
+
+
diff --git a/src/templates/example-page/checkbox.tsx b/src/templates/example-page/checkbox.tsx index 7c50745..032dfb8 100644 --- a/src/templates/example-page/checkbox.tsx +++ b/src/templates/example-page/checkbox.tsx @@ -16,8 +16,17 @@ export default function CheckboxExample() {
- - + +
diff --git a/src/templates/example-page/dialog.tsx b/src/templates/example-page/dialog.tsx index 46594f2..ad9abd8 100644 --- a/src/templates/example-page/dialog.tsx +++ b/src/templates/example-page/dialog.tsx @@ -32,7 +32,7 @@ export default function DialogExample() { + diff --git a/src/templates/example-page/skeleton.tsx b/src/templates/example-page/skeleton.tsx index 789f940..da08752 100644 --- a/src/templates/example-page/skeleton.tsx +++ b/src/templates/example-page/skeleton.tsx @@ -17,7 +17,10 @@ export default function SkeletonExample() { description="Skeleton is a simple container element that alters how other Adwave elements within it are displayed and adds an animated mask over the content." > -
+