@uxfront/layer-docs 0.5.0 → 0.6.0

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @uxfront/layer-docs
2
2
 
3
- The Nuxt layer for UXFront's documentation sites. It extends [Docus](https://docus.dev), which renders the markdown in `content/docs/` with a header, sidebar, search and table of contents, and adds a framework switcher: every reader sees the examples for their framework, on every page.
3
+ The Nuxt layer for UXFront's documentation sites. It extends [Docus](https://docus.dev), which renders the markdown in `content/docs/` with a header, sidebar, search and table of contents, and adds a framework switcher: every reader sees the examples for their framework, on every page. It can also set the header's site name the way the UXFront homepages do, signed "by UXFront".
4
4
 
5
5
  ## Install
6
6
 
@@ -32,6 +32,23 @@ export default defineAppConfig({
32
32
 
33
33
  `value` is the slot name pages write each framework's examples in, and `icon` any [Iconify](https://icones.js.org) icon. The layer ships no default list, so with none, the switcher and the select render nothing.
34
34
 
35
+ ## The header wordmark
36
+
37
+ Docus prints the site name in the header as plain text. Set `docsTheme.wordmark` to write it the way the UXFront homepages do, one part bold, and `docsTheme.byline` to sign it "by UXFront", linked to uxfront.com:
38
+
39
+ ```ts
40
+ // app/app.config.ts
41
+ export default defineAppConfig({
42
+ docsTheme: {
43
+ // **Open**Components
44
+ wordmark: { bold: "Open", regular: "Components" },
45
+ byline: true,
46
+ },
47
+ });
48
+ ```
49
+
50
+ The wordmark links home, and its accessible name is Docus's `header.title`, or the site name. The byline sits beside the link, not inside it, and phones leave it out so the header's buttons keep their room. With neither set, the header shows Docus's own title or logo.
51
+
35
52
  ## Writing examples
36
53
 
37
54
  Put one slot per framework in a `::framework-switcher`:
@@ -57,6 +74,7 @@ export const Button = () => <button>Save</button>;
57
74
 
58
75
  - **`FrameworkSwitcher`.** One tab per framework, on Nuxt UI's tabs, so it follows the WAI-ARIA tabs pattern (arrow keys between tabs, panels labelled by their tab). A page doesn't have to cover every framework: a missing one shows the first one the page has, with a note saying so. When the tabs outgrow the width, the list scrolls.
59
76
  - **A Framework select above the sidebar.** It replaces Docus's `DocsAsideLeftTop` and renders Docus's below it.
77
+ - **A header wordmark and byline.** It replaces Docus's `AppHeaderLeft`, and renders Docus's unless the app sets a wordmark.
60
78
  - **`useFramework()`.** The reader's pick, shared by every switcher and the select, and kept in `localStorage` across visits. It's read once the page is mounted, so the prerendered HTML shows the default framework and hydrates cleanly.
61
79
  - **Bundled icons.** Nuxt Icon bundles the icons named in app config too, so the select's icons don't come from the Iconify API.
62
80
 
@@ -0,0 +1,84 @@
1
+ <script setup lang="ts">
2
+ // Replaces Docus's, which prints the site name as plain text, to set the app's
3
+ // wordmark (`docsTheme.wordmark`) and sign it "by UXFront" (`docsTheme.byline`),
4
+ // the way the UXFront homepage headers do. With neither, it renders Docus's own.
5
+ import UxFrontMark from "@uxfront/ui/components/icons/UxFrontMark.vue";
6
+ import DocusAppHeaderLeft from "docus/app/components/app/AppHeaderLeft.vue";
7
+
8
+ const appConfig = useAppConfig();
9
+ const site = useSiteConfig();
10
+ const { localePath } = useDocusI18n();
11
+
12
+ const wordmark = computed(() => appConfig.docsTheme.wordmark);
13
+ const ariaLabel = computed(() => appConfig.header?.title || site.name);
14
+ </script>
15
+
16
+ <template>
17
+ <div class="docs-header-left">
18
+ <NuxtLink v-if="wordmark" :to="localePath('/')" :aria-label="ariaLabel" class="docs-wordmark">
19
+ <strong>{{ wordmark.bold }}</strong
20
+ >{{ wordmark.regular }}
21
+ </NuxtLink>
22
+ <DocusAppHeaderLeft v-else />
23
+ <!-- Beside the home link, not inside it, since it holds a link of its own. -->
24
+ <span v-if="appConfig.docsTheme.byline" class="docs-byline">
25
+ by
26
+ <a href="https://uxfront.com">
27
+ <UxFrontMark />
28
+ <span><strong>UX</strong>Front</span>
29
+ </a>
30
+ </span>
31
+ </div>
32
+ </template>
33
+
34
+ <style scoped>
35
+ /* Styled here rather than with Tailwind utilities: Docus's stylesheet doesn't
36
+ list this layer among Tailwind's sources, so only utilities Docus happens to
37
+ use itself would be generated. */
38
+ .docs-header-left {
39
+ display: flex;
40
+ align-items: center;
41
+ gap: 0.75rem;
42
+ min-width: 0;
43
+ }
44
+
45
+ .docs-wordmark {
46
+ flex-shrink: 0;
47
+ }
48
+
49
+ /* Phones leave the byline out: beside the header's buttons, it pushes the menu
50
+ toggle off-screen. */
51
+ .docs-byline {
52
+ display: none;
53
+ align-items: center;
54
+ gap: 0.375rem;
55
+ font-size: 0.75rem;
56
+ line-height: 1rem;
57
+ white-space: nowrap;
58
+ color: var(--ui-text-muted);
59
+ }
60
+
61
+ .docs-byline a {
62
+ display: inline-flex;
63
+ align-items: center;
64
+ gap: 0.25rem;
65
+ font-weight: 500;
66
+ color: var(--ui-text-toned);
67
+ transition: color 0.15s;
68
+ }
69
+
70
+ .docs-byline a:hover {
71
+ color: var(--ui-text-highlighted);
72
+ }
73
+
74
+ .docs-byline svg {
75
+ width: 0.875rem;
76
+ height: 0.875rem;
77
+ }
78
+
79
+ @media (min-width: 40rem) {
80
+ .docs-byline {
81
+ display: inline-flex;
82
+ }
83
+ }
84
+ </style>
@@ -12,11 +12,24 @@ export interface FrameworkOption {
12
12
  icon: string;
13
13
  }
14
14
 
15
+ /**
16
+ * The site name in the docs header, as the UXFront homepages set it: one part
17
+ * bold, then the rest, as in **Open**Components.
18
+ */
19
+ export interface DocsWordmark {
20
+ bold: string;
21
+ regular: string;
22
+ }
23
+
15
24
  declare module "nuxt/schema" {
16
25
  interface AppConfigInput {
17
26
  docsTheme?: {
18
27
  /** The frameworks the docs' examples come in, in display order. The first is the default. */
19
28
  frameworks?: FrameworkOption[];
29
+ /** The header's site name, in place of Docus's plain-text title. */
30
+ wordmark?: DocsWordmark;
31
+ /** Signs the header's site name "by UXFront", linked to uxfront.com. */
32
+ byline?: boolean;
20
33
  };
21
34
  }
22
35
  }
package/nuxt.config.ts CHANGED
@@ -5,7 +5,9 @@
5
5
  * search and table of contents, and adds a framework switcher on top: a
6
6
  * `::framework-switcher` content component with one slot per framework, and a
7
7
  * Framework select above the sidebar. The app lists its frameworks in
8
- * `docsTheme.frameworks` in its `app.config.ts`.
8
+ * `docsTheme.frameworks` in its `app.config.ts`. It can also set the header's
9
+ * site name as a wordmark, signed "by UXFront" (`docsTheme.wordmark` and
10
+ * `docsTheme.byline`).
9
11
  *
10
12
  * https://nuxt.com/docs/getting-started/layers
11
13
  */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uxfront/layer-docs",
3
- "version": "0.5.0",
4
- "description": "Nuxt layer for UXFront documentation sites: Docus, plus a framework switcher that shows every reader the examples for their framework.",
3
+ "version": "0.6.0",
4
+ "description": "Nuxt layer for UXFront documentation sites: Docus, plus a framework switcher that shows every reader the examples for their framework, and the UXFront header wordmark.",
5
5
  "keywords": [
6
6
  "docs",
7
7
  "documentation",
@@ -36,6 +36,7 @@
36
36
  "access": "public"
37
37
  },
38
38
  "dependencies": {
39
+ "@uxfront/ui": "^0.4.1",
39
40
  "@vueuse/core": "^14.4.0",
40
41
  "docus": "^5.13.0"
41
42
  },