@sarj/docs-ui 0.1.1 → 0.2.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
@@ -8,6 +8,15 @@ Shared Astro and Starlight reference UI for Sarj standards sites
8
8
  npm install --save-dev @sarj/docs-ui
9
9
  ```
10
10
 
11
- Rules and configuration are documented in the generated rule directory.
11
+ Import `@sarj/docs-ui/styles.css` once, then compose the typed Astro components. The live component and theme contract is published at [code-standards.sarj.ai/design-system/](https://code-standards.sarj.ai/design-system/).
12
+
13
+ Public exports:
14
+
15
+ - `@sarj/docs-ui/Breadcrumbs.astro`
16
+ - `@sarj/docs-ui/PageAnchor.astro`
17
+ - `@sarj/docs-ui/ReferencePage.astro`
18
+ - `@sarj/docs-ui/catalog`
19
+ - `@sarj/docs-ui/contracts`
20
+ - `@sarj/docs-ui/styles.css`
12
21
 
13
22
  [Documentation](https://code-standards.sarj.ai/) · [Source](https://github.com/sarj-ai/code-standards)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sarj/docs-ui",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "packageManager": "npm@12.0.2",
5
5
  "description": "Shared Astro and Starlight reference UI for Sarj standards sites",
6
6
  "type": "module",
@@ -9,6 +9,8 @@
9
9
  },
10
10
  "exports": {
11
11
  "./styles.css": "./src/styles/theme.css",
12
+ "./catalog": "./src/catalog.ts",
13
+ "./contracts": "./src/contracts.ts",
12
14
  "./PageAnchor.astro": "./src/components/PageAnchor.astro",
13
15
  "./ReferencePage.astro": "./src/components/ReferencePage.astro",
14
16
  "./Breadcrumbs.astro": "./src/components/Breadcrumbs.astro"
package/src/catalog.ts ADDED
@@ -0,0 +1,51 @@
1
+ import type { BreadcrumbsProps, ReferencePageProps } from './contracts';
2
+
3
+ export interface ComponentDefinition<Props extends object = object> {
4
+ exportPath: string;
5
+ purpose: string;
6
+ properties: Readonly<Record<keyof Props, string>>;
7
+ }
8
+
9
+ export interface ThemeTokenDefinition {
10
+ cssName: `--sarj-${string}`;
11
+ purpose: string;
12
+ }
13
+
14
+ export const componentCatalog = Object.freeze({
15
+ Breadcrumbs: {
16
+ exportPath: '@sarj/docs-ui/Breadcrumbs.astro',
17
+ purpose: 'Show a compact, accessible path to the current reference page.',
18
+ properties: {
19
+ ancestors: 'Ordered links from the reference root to the current page.',
20
+ current: 'Current page label, announced with aria-current="page".',
21
+ },
22
+ } satisfies ComponentDefinition<BreadcrumbsProps>,
23
+ PageAnchor: {
24
+ exportPath: '@sarj/docs-ui/PageAnchor.astro',
25
+ purpose: 'Provide the focusable top anchor used by Starlight reference pages.',
26
+ properties: {},
27
+ } satisfies ComponentDefinition,
28
+ ReferencePage: {
29
+ exportPath: '@sarj/docs-ui/ReferencePage.astro',
30
+ purpose: 'Render a Starlight reference shell with explicit search and robots behavior.',
31
+ properties: {
32
+ title: 'Document title and primary accessible page identity.',
33
+ description: 'Concise page description used by document metadata.',
34
+ sidebar: 'Starlight sidebar definition for this reference surface.',
35
+ searchable: 'Whether Pagefind indexes the page body; defaults to true.',
36
+ indexable: 'Whether robots may index the public page; defaults to true.',
37
+ discovery: 'Deprecated shorthand retained for compatibility; never access control.',
38
+ hasSidebar: 'Whether the Starlight sidebar is rendered; defaults to true.',
39
+ template: 'Starlight document or splash template; defaults to doc.',
40
+ },
41
+ } satisfies ComponentDefinition<ReferencePageProps>,
42
+ });
43
+
44
+ export const themeTokenCatalog = Object.freeze([
45
+ { cssName: '--sarj-color-report', purpose: 'Diagnostic and rejection emphasis.' },
46
+ { cssName: '--sarj-color-pass', purpose: 'Accepted example and success emphasis.' },
47
+ { cssName: '--sarj-color-warning', purpose: 'Warning-level diagnostic emphasis with AA text contrast.' },
48
+ { cssName: '--sarj-color-rule', purpose: 'Structural borders and separators.' },
49
+ { cssName: '--sarj-color-paper', purpose: 'Reference surface background.' },
50
+ { cssName: '--sarj-color-ink', purpose: 'Primary reference text.' },
51
+ ] satisfies readonly ThemeTokenDefinition[]);
@@ -1,13 +1,5 @@
1
1
  ---
2
- interface Ancestor {
3
- label: string;
4
- href: string;
5
- }
6
-
7
- interface Props {
8
- ancestors: readonly Ancestor[];
9
- current: string;
10
- }
2
+ import type { BreadcrumbsProps as Props } from '../contracts';
11
3
 
12
4
  const { ancestors, current } = Astro.props;
13
5
  ---
@@ -1,29 +1,19 @@
1
1
  ---
2
2
  import StarlightPage from '@astrojs/starlight/components/StarlightPage.astro';
3
- import type { StarlightUserConfig } from '@astrojs/starlight/types';
4
-
5
- type Sidebar = NonNullable<StarlightUserConfig['sidebar']>;
6
- type Discovery = 'searchable' | 'navigation-only' | 'unlisted';
7
-
8
- interface Props {
9
- title: string;
10
- description: string;
11
- sidebar: Sidebar;
12
- discovery?: Discovery;
13
- hasSidebar?: boolean;
14
- template?: 'doc' | 'splash';
15
- }
3
+ import type { ReferencePageProps as Props } from '../contracts';
16
4
 
17
5
  const {
18
6
  title,
19
7
  description,
20
8
  sidebar,
21
- discovery = 'searchable',
9
+ searchable: searchableProp,
10
+ indexable: indexableProp,
11
+ discovery,
22
12
  hasSidebar = true,
23
13
  template = 'doc',
24
14
  } = Astro.props;
25
- const pagefind = discovery === 'searchable';
26
- const noindex = discovery === 'unlisted';
15
+ const searchable = searchableProp ?? (discovery === undefined || discovery === 'searchable');
16
+ const indexable = indexableProp ?? discovery !== 'unlisted';
27
17
  ---
28
18
 
29
19
  <StarlightPage
@@ -31,15 +21,15 @@ const noindex = discovery === 'unlisted';
31
21
  title,
32
22
  description,
33
23
  template,
34
- pagefind,
24
+ pagefind: searchable,
35
25
  prev: false,
36
26
  next: false,
37
- head: noindex ? [{ tag: 'meta', attrs: { name: 'robots', content: 'noindex, nofollow' } }] : [],
27
+ head: indexable ? [] : [{ tag: 'meta', attrs: { name: 'robots', content: 'noindex, nofollow' } }],
38
28
  }}
39
29
  sidebar={sidebar}
40
30
  hasSidebar={hasSidebar}
41
31
  >
42
- <div data-pagefind-body={pagefind ? true : undefined} data-pagefind-ignore={pagefind ? undefined : true}>
32
+ <div data-pagefind-body={searchable ? true : undefined} data-pagefind-ignore={searchable ? undefined : true}>
43
33
  <slot />
44
34
  </div>
45
35
  </StarlightPage>
@@ -0,0 +1,36 @@
1
+ import type { StarlightUserConfig } from '@astrojs/starlight/types';
2
+
3
+ /** One navigable ancestor rendered before the current page. */
4
+ export interface BreadcrumbAncestor {
5
+ label: string;
6
+ href: string;
7
+ }
8
+
9
+ /** Public properties accepted by {@link Breadcrumbs}. */
10
+ export interface BreadcrumbsProps {
11
+ ancestors: readonly BreadcrumbAncestor[];
12
+ current: string;
13
+ }
14
+
15
+ export type ReferenceSidebar = NonNullable<StarlightUserConfig['sidebar']>;
16
+
17
+ /**
18
+ * Legacy discovery shorthand. `unlisted` affects search and robots metadata;
19
+ * it is not access control and the rendered page remains public.
20
+ */
21
+ export type ReferenceDiscovery = 'searchable' | 'navigation-only' | 'unlisted';
22
+
23
+ /** Public properties accepted by {@link ReferencePage}. */
24
+ export interface ReferencePageProps {
25
+ title: string;
26
+ description: string;
27
+ sidebar: ReferenceSidebar;
28
+ /** Include the page body in Pagefind. Defaults to true. */
29
+ searchable?: boolean;
30
+ /** Allow search engines to index the page. Defaults to true. */
31
+ indexable?: boolean;
32
+ /** @deprecated Prefer the explicit `searchable` and `indexable` properties. */
33
+ discovery?: ReferenceDiscovery;
34
+ hasSidebar?: boolean;
35
+ template?: 'doc' | 'splash';
36
+ }
@@ -15,11 +15,18 @@
15
15
  --sl-color-gray-5: #dfe2e8;
16
16
  --sl-color-gray-6: #f1f2f5;
17
17
  --sl-color-black: #ffffff;
18
- --report: #c34453;
19
- --pass: #16806d;
20
- --rule: #e4e6eb;
21
- --paper: #ffffff;
22
- --ink: #12141a;
18
+ --sarj-color-report: #c34453;
19
+ --sarj-color-pass: #16806d;
20
+ --sarj-color-warning: #986a00;
21
+ --sarj-color-rule: #e4e6eb;
22
+ --sarj-color-paper: #ffffff;
23
+ --sarj-color-ink: #12141a;
24
+ /* Compatibility aliases. Prefer the namespaced public tokens above. */
25
+ --report: var(--sarj-color-report);
26
+ --pass: var(--sarj-color-pass);
27
+ --rule: var(--sarj-color-rule);
28
+ --paper: var(--sarj-color-paper);
29
+ --ink: var(--sarj-color-ink);
23
30
  }
24
31
 
25
32
  :root[data-theme='dark'] {
@@ -34,9 +41,10 @@
34
41
  --sl-color-gray-5: #272b34;
35
42
  --sl-color-gray-6: #15171d;
36
43
  --sl-color-black: #0b0c10;
37
- --report: #ff8794;
38
- --pass: #62d5bd;
39
- --rule: #272a32;
40
- --paper: #0b0c10;
41
- --ink: #f4f5f8;
44
+ --sarj-color-report: #ff8794;
45
+ --sarj-color-pass: #62d5bd;
46
+ --sarj-color-warning: #a97708;
47
+ --sarj-color-rule: #272a32;
48
+ --sarj-color-paper: #0b0c10;
49
+ --sarj-color-ink: #f4f5f8;
42
50
  }