diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..40838c2 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,20 @@ +# Shared whitespace rules for every uxfront-com repository. +# The canonical copy is .editorconfig in uxfront-com/.github. Change it there, then copy it. +# It matches @uxfront/oxfmt-config: tabs, with no fixed width, so each reader picks their own. +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = tab +insert_final_newline = true +trim_trailing_whitespace = true + +# YAML forbids tabs for indentation. +[*.{yml,yaml}] +indent_style = space +indent_size = 2 + +# Two trailing spaces are a line break in Markdown, so keep them. +[*.md] +trim_trailing_whitespace = false diff --git a/app/app.config.ts b/app/app.config.ts index 43008bc..6e86231 100644 --- a/app/app.config.ts +++ b/app/app.config.ts @@ -2,55 +2,55 @@ import { FRAMEWORKS } from "./data/frameworks"; import { BLOG_URL, CHANGELOG_URL, GITHUB_URL } from "./data/site"; export default defineAppConfig({ - // The docs' GitHub, "Edit this page" and "Report an issue" links. Docus reads - // them from the git remote otherwise, which not every checkout has. - github: { - url: GITHUB_URL, - branch: "main", - }, - docsTheme: { - // The frameworks the docs' examples come in (see app/data/frameworks.ts). - frameworks: FRAMEWORKS, - // The docs header's site name, set and signed "by UXFront" the way the - // homepage header does. - wordmark: { bold: "Open", regular: "Components" }, - byline: true, - // The docs header's links, beside its buttons from 768px up and at the top of - // its menu below that, each highlighted on its page and the pages below it. - headerLinks: [ - { label: "Blog", to: BLOG_URL, activeFor: BLOG_URL }, - { label: "Changelog", to: CHANGELOG_URL, activeFor: CHANGELOG_URL }, - // The introduction, rather than /docs, which only redirects to it. - { label: "Documentation", to: "/docs/getting-started/introduction", activeFor: "/docs" }, - ], - }, - ui: { - colors: { - // The periwinkle of the homepage's glow (see app/app.css for its shades). - primary: "indigo", - neutral: "zinc", - }, - prose: { - // Tabs in the docs, like the MCP Server page's clients, scroll sideways on - // small screens rather than cut their labels short, as code groups do. The - // underline under the active tab moves up a pixel, onto the list's border, - // where scrolling doesn't clip it. - tabs: { - slots: { - list: "overflow-x-auto", - trigger: "shrink-0", - indicator: "bottom-0", - }, - }, - // Link cards, like the ones the Button's Overview has for its layers' pages, - // lead with a large icon. A hovered card's tint takes the muted description - // below 4.5:1 in light mode, so it darkens on hover. - card: { - slots: { - description: "group-hover:text-toned", - icon: "size-12 mb-4", - }, - }, - }, - }, + // The docs' GitHub, "Edit this page" and "Report an issue" links. Docus reads + // them from the git remote otherwise, which not every checkout has. + github: { + url: GITHUB_URL, + branch: "main", + }, + docsTheme: { + // The frameworks the docs' examples come in (see app/data/frameworks.ts). + frameworks: FRAMEWORKS, + // The docs header's site name, set and signed "by UXFront" the way the + // homepage header does. + wordmark: { bold: "Open", regular: "Components" }, + byline: true, + // The docs header's links, beside its buttons from 768px up and at the top of + // its menu below that, each highlighted on its page and the pages below it. + headerLinks: [ + { label: "Blog", to: BLOG_URL, activeFor: BLOG_URL }, + { label: "Changelog", to: CHANGELOG_URL, activeFor: CHANGELOG_URL }, + // The introduction, rather than /docs, which only redirects to it. + { label: "Documentation", to: "/docs/getting-started/introduction", activeFor: "/docs" }, + ], + }, + ui: { + colors: { + // The periwinkle of the homepage's glow (see app/app.css for its shades). + primary: "indigo", + neutral: "zinc", + }, + prose: { + // Tabs in the docs, like the MCP Server page's clients, scroll sideways on + // small screens rather than cut their labels short, as code groups do. The + // underline under the active tab moves up a pixel, onto the list's border, + // where scrolling doesn't clip it. + tabs: { + slots: { + list: "overflow-x-auto", + trigger: "shrink-0", + indicator: "bottom-0", + }, + }, + // Link cards, like the ones the Button's Overview has for its layers' pages, + // lead with a large icon. A hovered card's tint takes the muted description + // below 4.5:1 in light mode, so it darkens on hover. + card: { + slots: { + description: "group-hover:text-toned", + icon: "size-12 mb-4", + }, + }, + }, + }, }); diff --git a/app/app.css b/app/app.css index 0b069a0..2ce314d 100644 --- a/app/app.css +++ b/app/app.css @@ -18,18 +18,18 @@ /* Identifiers in a table's first column, like prop names and rule IDs, read as one word: don't break them at their hyphens. */ table td:first-child > code { - white-space: nowrap; + white-space: nowrap; } @layer theme { - /* Nuxt UI draws light-mode links in the 500 shade, below WCAG AA contrast on + /* Nuxt UI draws light-mode links in the 500 shade, below WCAG AA contrast on white. The rules below replace both of its defaults, so dark mode is restated. */ - :root, - .light { - --ui-primary: var(--ui-color-primary-600); - } + :root, + .light { + --ui-primary: var(--ui-color-primary-600); + } - .dark { - --ui-primary: var(--ui-color-primary-400); - } + .dark { + --ui-primary: var(--ui-color-primary-400); + } } diff --git a/app/app.vue b/app/app.vue index e98a4ae..a2c4ccd 100644 --- a/app/app.vue +++ b/app/app.vue @@ -6,16 +6,18 @@ const DocusApp = defineAsyncComponent(() => import("docus/app/app.vue")); const route = useRoute(); const usesDocus = computed(() => - ["/docs", "/changelog", "/blog"].some((base) => route.path === base || route.path.startsWith(`${base}/`)), + ["/docs", "/changelog", "/blog"].some( + (base) => route.path === base || route.path.startsWith(`${base}/`), + ), ); useHead({ - titleTemplate: (title) => (title ? `${title} - Open Components` : "Open Components"), + titleTemplate: (title) => (title ? `${title} - Open Components` : "Open Components"), }); diff --git a/app/components/UContentSurround.vue b/app/components/UContentSurround.vue index 50a84ba..9f19d5b 100644 --- a/app/components/UContentSurround.vue +++ b/app/components/UContentSurround.vue @@ -8,6 +8,7 @@ * It renders Nuxt UI's own with them: keep it in step with how Docus uses it. */ import type { ContentNavigationItem } from "@nuxt/content"; + import ContentSurround from "#ui/components/content/ContentSurround.vue"; import { findSurround, sortNavigation } from "~/lib/navigation"; @@ -18,12 +19,12 @@ const route = useRoute(); // The tree Nuxt Content builds the surround from, with each page's description, // which the links show under their titles, as Docus asks for. const { data: navigation } = await useAsyncData("docs-surround", () => - queryCollectionNavigation("docs", ["description"]), + queryCollectionNavigation("docs", ["description"]), ); // A null where there's no page, which Nuxt UI's leaves a gap for, as Docus's has. const pages = computed(() => findSurround(sortNavigation(navigation.value ?? []), route.path)); diff --git a/app/components/app/AppHeaderBody.vue b/app/components/app/AppHeaderBody.vue index 7b1b063..c3bdfb8 100644 --- a/app/components/app/AppHeaderBody.vue +++ b/app/components/app/AppHeaderBody.vue @@ -11,19 +11,19 @@ import { getFirstPagePath } from "docus/app/composables/useSubNavigation"; const navigation = inject>>("navigation"); const { subNavigationMode } = useSubNavigation(); const items = computed>(() => { - const nav = navigation?.value || []; - if (!subNavigationMode.value) { - return nav; - } - return nav.map(({ children, ...item }) => ({ - ...item, - path: children?.length ? getFirstPagePath({ ...item, children }) : item.path, - })); + const nav = navigation?.value || []; + if (!subNavigationMode.value) { + return nav; + } + return nav.map(({ children, ...item }) => ({ + ...item, + path: children?.length ? getFirstPagePath({ ...item, children }) : item.path, + })); }); diff --git a/app/components/blog/BlogByline.vue b/app/components/blog/BlogByline.vue index eb47599..29ef838 100644 --- a/app/components/blog/BlogByline.vue +++ b/app/components/blog/BlogByline.vue @@ -1,5 +1,6 @@ diff --git a/app/components/blog/BlogDate.vue b/app/components/blog/BlogDate.vue index 3c083b4..1b9a6d7 100644 --- a/app/components/blog/BlogDate.vue +++ b/app/components/blog/BlogDate.vue @@ -8,10 +8,10 @@ const props = defineProps<{ date: string }>(); // Posts are dated like 2026-11-18, which Date reads as midnight UTC: formatted in // UTC, it's the same day in every time zone, on the server and in the browser. const formatted = new Intl.DateTimeFormat("en-GB", { dateStyle: "long", timeZone: "UTC" }).format( - new Date(props.date), + new Date(props.date), ); diff --git a/app/components/changelog/ChangelogEntry.vue b/app/components/changelog/ChangelogEntry.vue index 86e4a38..f65c490 100644 --- a/app/components/changelog/ChangelogEntry.vue +++ b/app/components/changelog/ChangelogEntry.vue @@ -1,6 +1,7 @@ diff --git a/app/components/content/InklineExample.test.ts b/app/components/content/InklineExample.test.ts index b5ed6b9..10a01e3 100644 --- a/app/components/content/InklineExample.test.ts +++ b/app/components/content/InklineExample.test.ts @@ -1,15 +1,17 @@ import { render, screen } from "@testing-library/vue"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { h, nextTick, reactive, ref } from "vue"; + import { INKLINE_PREVIEW_ORIGIN } from "~/lib/inkline-embed"; + import InklineExample from "./InklineExample.vue"; // Nuxt auto-imports these. The reader picked Vue, in light mode. const colorMode = reactive({ value: "light" }); beforeEach(() => { - colorMode.value = "light"; - vi.stubGlobal("useFramework", () => ({ current: ref({ value: "vue", label: "Vue" }) })); - vi.stubGlobal("useColorMode", () => colorMode); + colorMode.value = "light"; + vi.stubGlobal("useFramework", () => ({ current: ref({ value: "vue", label: "Vue" }) })); + vi.stubGlobal("useColorMode", () => colorMode); }); afterEach(() => vi.unstubAllGlobals()); @@ -18,44 +20,51 @@ afterEach(() => vi.unstubAllGlobals()); const code = () => h("pre", { "data-testid": "code" }, ""); describe("InklineExample", () => { - it("shows the example in a lazy frame named for what it shows and the framework it shows it in", async () => { - render(InklineExample, { props: { example: "button/ButtonVariants", title: "Button variants" } }); - - const frame = await screen.findByTitle("Button variants, in Vue"); - expect(frame).toHaveAttribute("loading", "lazy"); - const src = new URL(frame.getAttribute("src")!); - expect(src.searchParams.get("target")).toBe("vue"); - expect(src.searchParams.get("theme")).toBe("light"); - }); - - it("shows the page's code under the frame", async () => { - render(InklineExample, { - props: { example: "button/ButtonVariants", title: "Button variants" }, - slots: { default: code }, - }); - - const frame = await screen.findByTitle("Button variants, in Vue"); - const shown = screen.getByTestId("code"); - expect(frame.compareDocumentPosition(shown) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy(); - }); - - it("sends the mode to a frame that became ready after the mode changed", async () => { - render(InklineExample, { props: { example: "button/ButtonVariants", title: "Button variants" } }); - const frame = (await screen.findByTitle("Button variants, in Vue")) as HTMLIFrameElement; - const post = vi.spyOn(frame.contentWindow!, "postMessage").mockImplementation(() => {}); - - colorMode.value = "dark"; - await nextTick(); - expect(post).not.toHaveBeenCalled(); - - window.dispatchEvent( - new MessageEvent("message", { - origin: INKLINE_PREVIEW_ORIGIN, - source: frame.contentWindow, - data: { type: "unframework:embed", kind: "resize", height: 240 }, - }), - ); - await nextTick(); - expect(post).toHaveBeenCalledWith({ type: "unframework:embed", kind: "theme", theme: "dark" }, INKLINE_PREVIEW_ORIGIN); - }); + it("shows the example in a lazy frame named for what it shows and the framework it shows it in", async () => { + render(InklineExample, { + props: { example: "button/ButtonVariants", title: "Button variants" }, + }); + + const frame = await screen.findByTitle("Button variants, in Vue"); + expect(frame).toHaveAttribute("loading", "lazy"); + const src = new URL(frame.getAttribute("src")!); + expect(src.searchParams.get("target")).toBe("vue"); + expect(src.searchParams.get("theme")).toBe("light"); + }); + + it("shows the page's code under the frame", async () => { + render(InklineExample, { + props: { example: "button/ButtonVariants", title: "Button variants" }, + slots: { default: code }, + }); + + const frame = await screen.findByTitle("Button variants, in Vue"); + const shown = screen.getByTestId("code"); + expect(frame.compareDocumentPosition(shown) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy(); + }); + + it("sends the mode to a frame that became ready after the mode changed", async () => { + render(InklineExample, { + props: { example: "button/ButtonVariants", title: "Button variants" }, + }); + const frame = (await screen.findByTitle("Button variants, in Vue")) as HTMLIFrameElement; + const post = vi.spyOn(frame.contentWindow!, "postMessage").mockImplementation(() => {}); + + colorMode.value = "dark"; + await nextTick(); + expect(post).not.toHaveBeenCalled(); + + window.dispatchEvent( + new MessageEvent("message", { + origin: INKLINE_PREVIEW_ORIGIN, + source: frame.contentWindow, + data: { type: "unframework:embed", kind: "resize", height: 240 }, + }), + ); + await nextTick(); + expect(post).toHaveBeenCalledWith( + { type: "unframework:embed", kind: "theme", theme: "dark" }, + INKLINE_PREVIEW_ORIGIN, + ); + }); }); diff --git a/app/components/content/InklineExample.vue b/app/components/content/InklineExample.vue index c209f57..a4b6cee 100644 --- a/app/components/content/InklineExample.vue +++ b/app/components/content/InklineExample.vue @@ -1,16 +1,17 @@