create-nersh 0.1.6 → 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 +187 -0
- package/dist/index.mjs +169 -40
- package/package.json +4 -3
- package/templates/default-site.json +668 -0
- package/templates/next/app/globals.css +25 -0
- package/templates/next/components.json +23 -0
- package/templates/next/package.json.tmpl +5 -3
- package/templates/next/postcss.config.mjs +8 -0
- package/templates/next/site.json +0 -121
- package/templates/next/src/components/site/SafeEmbed.tsx +0 -72
- package/templates/next/src/components/site/SiteButton.tsx +0 -65
- package/templates/next/src/components/site/SiteCard.tsx +0 -46
- package/templates/next/src/components/site/SiteCodeBlock.tsx +0 -56
- package/templates/next/src/components/site/SiteHeading.tsx +0 -50
- package/templates/next/src/components/site/SiteMobileSlider.tsx +0 -71
- package/templates/next/src/components/site/SiteSectionShell.tsx +0 -91
- package/templates/next/src/components/site/SiteStructuralContext.tsx +0 -52
- package/templates/next/src/lib/brandContext.ts +0 -65
- package/templates/next/src/lib/codeBlock.ts +0 -76
- package/templates/next/src/lib/componentLibrary/providers/shadcn/components.ts +0 -146
- package/templates/next/src/lib/componentLibrary/resolveComponent.ts +0 -35
- package/templates/next/src/lib/componentLibrary/schema.ts +0 -219
- package/templates/next/src/lib/embeds/index.ts +0 -232
- package/templates/next/src/lib/humanize.ts +0 -58
- package/templates/next/src/lib/sectionItems.ts +0 -48
- package/templates/next/src/lib/sectionSurface.ts +0 -70
- package/templates/next/src/lib/utils.ts +0 -6
- package/templates/next/src/registry.ts +0 -16
- package/templates/next/src/sections/about/Component.tsx +0 -51
- package/templates/next/src/sections/about/index.ts +0 -7
- package/templates/next/src/sections/about/meta.ts +0 -8
- package/templates/next/src/sections/about/schema.ts +0 -38
- package/templates/next/src/sections/about/writeCopy.ts +0 -10
- package/templates/next/src/sections/copyHelpers.ts +0 -59
- package/templates/next/src/sections/features/Component.tsx +0 -122
- package/templates/next/src/sections/features/index.ts +0 -7
- package/templates/next/src/sections/features/meta.ts +0 -14
- package/templates/next/src/sections/features/schema.ts +0 -23
- package/templates/next/src/sections/features/writeCopy.ts +0 -18
- package/templates/next/src/sections/footer/Component.tsx +0 -103
- package/templates/next/src/sections/footer/index.ts +0 -7
- package/templates/next/src/sections/footer/meta.ts +0 -8
- package/templates/next/src/sections/footer/schema.ts +0 -39
- package/templates/next/src/sections/footer/writeCopy.ts +0 -31
- package/templates/next/src/sections/marketing-hero/Component.tsx +0 -187
- package/templates/next/src/sections/marketing-hero/index.ts +0 -7
- package/templates/next/src/sections/marketing-hero/meta.ts +0 -13
- package/templates/next/src/sections/marketing-hero/schema.ts +0 -106
- package/templates/next/src/sections/marketing-hero/writeCopy.ts +0 -18
- package/templates/next/src/sections/navbar/Component.tsx +0 -53
- package/templates/next/src/sections/navbar/index.ts +0 -7
- package/templates/next/src/sections/navbar/meta.ts +0 -8
- package/templates/next/src/sections/navbar/schema.ts +0 -50
- package/templates/next/src/sections/navbar/writeCopy.ts +0 -16
- package/templates/next/src/sections/pricing/Component.tsx +0 -125
- package/templates/next/src/sections/pricing/index.ts +0 -7
- package/templates/next/src/sections/pricing/meta.ts +0 -12
- package/templates/next/src/sections/pricing/schema.ts +0 -25
- package/templates/next/src/sections/pricing/writeCopy.ts +0 -22
- package/templates/next/src/sections/siteLayoutClasses.ts +0 -9
- package/templates/next/src/sections/types.ts +0 -119
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { createContext, useContext, type ReactNode } from 'react';
|
|
4
|
-
import type { ComponentLibraryConfig, CompiledSkin } from '@/lib/componentLibrary/schema';
|
|
5
|
-
import {
|
|
6
|
-
resolveComponentFromStructuralId,
|
|
7
|
-
type ResolvedComponent,
|
|
8
|
-
} from '@/lib/componentLibrary/resolveComponent';
|
|
9
|
-
|
|
10
|
-
export type SiteStructuralContextValue = {
|
|
11
|
-
structuralStyleId: string | null;
|
|
12
|
-
libraryConfig: ComponentLibraryConfig | null;
|
|
13
|
-
compiledSkin: CompiledSkin | null;
|
|
14
|
-
buttonRecipe: ResolvedComponent | null;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const SiteStructuralContext = createContext<SiteStructuralContextValue>({
|
|
18
|
-
structuralStyleId: null,
|
|
19
|
-
libraryConfig: null,
|
|
20
|
-
compiledSkin: null,
|
|
21
|
-
buttonRecipe: null,
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
export function useSiteStructural(): SiteStructuralContextValue {
|
|
25
|
-
return useContext(SiteStructuralContext);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
type ProviderProps = {
|
|
29
|
-
compiledSkin?: CompiledSkin | null;
|
|
30
|
-
children: ReactNode;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export function SiteStructuralProvider({ compiledSkin, children }: ProviderProps) {
|
|
34
|
-
const structuralStyleId = compiledSkin?.structuralStyleId ?? null;
|
|
35
|
-
const libraryConfig = compiledSkin?.libraryConfig ?? null;
|
|
36
|
-
const buttonRecipe = structuralStyleId
|
|
37
|
-
? resolveComponentFromStructuralId('Button', structuralStyleId)
|
|
38
|
-
: null;
|
|
39
|
-
|
|
40
|
-
return (
|
|
41
|
-
<SiteStructuralContext.Provider
|
|
42
|
-
value={{
|
|
43
|
-
structuralStyleId,
|
|
44
|
-
libraryConfig,
|
|
45
|
-
compiledSkin: compiledSkin ?? null,
|
|
46
|
-
buttonRecipe,
|
|
47
|
-
}}
|
|
48
|
-
>
|
|
49
|
-
{children}
|
|
50
|
-
</SiteStructuralContext.Provider>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* BrandContext shape + tokenizer used by the intake + deterministic pickers.
|
|
3
|
-
*
|
|
4
|
-
* BrandContext is the rolling state of the intake conversation —
|
|
5
|
-
* purpose + brand color + social handles. No vibe chips; aesthetics
|
|
6
|
-
* cascade from nertia's globals.css, brand color is the only aesthetic
|
|
7
|
-
* knob the user turns.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export type Platform =
|
|
11
|
-
| "twitter"
|
|
12
|
-
| "instagram"
|
|
13
|
-
| "linkedin"
|
|
14
|
-
| "youtube"
|
|
15
|
-
| "tiktok"
|
|
16
|
-
| "bluesky"
|
|
17
|
-
| "github"
|
|
18
|
-
| "facebook"
|
|
19
|
-
| "threads"
|
|
20
|
-
| "substack"
|
|
21
|
-
| "mastodon"
|
|
22
|
-
| "site"
|
|
23
|
-
| "link";
|
|
24
|
-
|
|
25
|
-
export interface Handle {
|
|
26
|
-
platform: Platform;
|
|
27
|
-
handle: string;
|
|
28
|
-
url: string;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export interface BrandContext {
|
|
32
|
-
purpose?: string;
|
|
33
|
-
/** Hex like "#22c55e". Injected as --accent at the hosted site wrapper. */
|
|
34
|
-
brandColor?: string;
|
|
35
|
-
handles?: Handle[];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Tokenize a BrandContext into a lowercase set of keywords. Used by the
|
|
40
|
-
* deterministic composition picker to score library entries against the
|
|
41
|
-
* user's input. Hyphenated words stay intact ("link-in-bio" is one token).
|
|
42
|
-
*
|
|
43
|
-
* Excludes brandColor — that's a rendering input, not a semantic one.
|
|
44
|
-
*/
|
|
45
|
-
export function ctxTokens(ctx: BrandContext): Set<string> {
|
|
46
|
-
const parts: string[] = [
|
|
47
|
-
ctx.purpose ?? "",
|
|
48
|
-
...(ctx.handles ?? []).map((h) => h.platform),
|
|
49
|
-
];
|
|
50
|
-
const blob = parts.join(" ").toLowerCase();
|
|
51
|
-
const tokens = blob.match(/[a-z][a-z-]{1,}/g) ?? [];
|
|
52
|
-
return new Set(tokens);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Score a library entry's tags against a ctx token set. Simple overlap count.
|
|
57
|
-
* Ties broken by whichever entry appears first in the library.
|
|
58
|
-
*/
|
|
59
|
-
export function scoreTags(tags: string[], tokens: Set<string>): number {
|
|
60
|
-
let score = 0;
|
|
61
|
-
for (const t of tags) {
|
|
62
|
-
if (tokens.has(t.toLowerCase())) score += 1;
|
|
63
|
-
}
|
|
64
|
-
return score;
|
|
65
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
export const CODE_BLOCK_LANGUAGES = [
|
|
2
|
-
"plain",
|
|
3
|
-
"typescript",
|
|
4
|
-
"javascript",
|
|
5
|
-
"tsx",
|
|
6
|
-
"jsx",
|
|
7
|
-
"python",
|
|
8
|
-
"bash",
|
|
9
|
-
"html",
|
|
10
|
-
"css",
|
|
11
|
-
"json",
|
|
12
|
-
"sql",
|
|
13
|
-
] as const;
|
|
14
|
-
|
|
15
|
-
export type CodeBlockLanguage = (typeof CODE_BLOCK_LANGUAGES)[number];
|
|
16
|
-
|
|
17
|
-
export const CODE_BLOCK_MAX_BYTES = 8 * 1024;
|
|
18
|
-
|
|
19
|
-
export type CodeBlockValue = {
|
|
20
|
-
language: CodeBlockLanguage;
|
|
21
|
-
code: string;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export type CodeBlockValidation =
|
|
25
|
-
| { ok: true; value: CodeBlockValue }
|
|
26
|
-
| { ok: false; error: string };
|
|
27
|
-
|
|
28
|
-
export function serializeCodeBlock(value: CodeBlockValue): string {
|
|
29
|
-
return JSON.stringify(value);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function emptyCodeBlockRaw(): string {
|
|
33
|
-
return "";
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function parseCodeBlock(raw: string): CodeBlockValidation {
|
|
37
|
-
const trimmed = raw.trim();
|
|
38
|
-
if (!trimmed) {
|
|
39
|
-
return { ok: true, value: { language: "plain", code: "" } };
|
|
40
|
-
}
|
|
41
|
-
let parsed: unknown;
|
|
42
|
-
try {
|
|
43
|
-
parsed = JSON.parse(trimmed);
|
|
44
|
-
} catch {
|
|
45
|
-
return { ok: false, error: "Invalid JSON" };
|
|
46
|
-
}
|
|
47
|
-
return validateCodeBlockObject(parsed);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function validateCodeBlock(raw: string): CodeBlockValidation {
|
|
51
|
-
return parseCodeBlock(raw);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function validateCodeBlockObject(parsed: unknown): CodeBlockValidation {
|
|
55
|
-
if (!parsed || typeof parsed !== "object") {
|
|
56
|
-
return { ok: false, error: "Must be a JSON object" };
|
|
57
|
-
}
|
|
58
|
-
const obj = parsed as Record<string, unknown>;
|
|
59
|
-
const language = obj.language;
|
|
60
|
-
const code = obj.code;
|
|
61
|
-
if (typeof language !== "string" || !(CODE_BLOCK_LANGUAGES as readonly string[]).includes(language)) {
|
|
62
|
-
return { ok: false, error: "Unknown language" };
|
|
63
|
-
}
|
|
64
|
-
if (typeof code !== "string") {
|
|
65
|
-
return { ok: false, error: "Code must be a string" };
|
|
66
|
-
}
|
|
67
|
-
if (new TextEncoder().encode(code).byteLength > CODE_BLOCK_MAX_BYTES) {
|
|
68
|
-
return { ok: false, error: `Code exceeds ${CODE_BLOCK_MAX_BYTES / 1024} KB` };
|
|
69
|
-
}
|
|
70
|
-
return { ok: true, value: { language: language as CodeBlockLanguage, code } };
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function codeBlockHasContent(raw: string): boolean {
|
|
74
|
-
const result = parseCodeBlock(raw);
|
|
75
|
-
return result.ok && result.value.code.trim().length > 0;
|
|
76
|
-
}
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import type { ShadcnStyle } from '../../schema';
|
|
2
|
-
import type { SiteButtonVariant } from '@/components/site/SiteButton';
|
|
3
|
-
|
|
4
|
-
/** shadcn/create density profile — padding, radius, type scale per style axis. */
|
|
5
|
-
export type ShadcnButtonDensity = {
|
|
6
|
-
style: ShadcnStyle;
|
|
7
|
-
/** Modifier class on SiteButton — scoped by structuralStyleId in CSS. */
|
|
8
|
-
modifierClass: string;
|
|
9
|
-
/** data-density for tests / a11y tooling */
|
|
10
|
-
density: 'balanced' | 'compact' | 'soft' | 'sharp' | 'dense';
|
|
11
|
-
padding: string;
|
|
12
|
-
fontSize: string;
|
|
13
|
-
borderRadius: string;
|
|
14
|
-
letterSpacing: string;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const DENSITY_BY_STYLE: Record<ShadcnStyle, ShadcnButtonDensity> = {
|
|
18
|
-
vega: {
|
|
19
|
-
style: 'vega',
|
|
20
|
-
modifierClass: 'site-btn-struct-vega',
|
|
21
|
-
density: 'balanced',
|
|
22
|
-
padding: '0.5625rem 1.125rem',
|
|
23
|
-
fontSize: '0.8125rem',
|
|
24
|
-
borderRadius: 'var(--radius)',
|
|
25
|
-
letterSpacing: 'normal',
|
|
26
|
-
},
|
|
27
|
-
nova: {
|
|
28
|
-
style: 'nova',
|
|
29
|
-
modifierClass: 'site-btn-struct-nova',
|
|
30
|
-
density: 'compact',
|
|
31
|
-
padding: '0.4375rem 0.875rem',
|
|
32
|
-
fontSize: '0.75rem',
|
|
33
|
-
borderRadius: 'calc(var(--radius) * 0.75)',
|
|
34
|
-
letterSpacing: '0.01em',
|
|
35
|
-
},
|
|
36
|
-
maia: {
|
|
37
|
-
style: 'maia',
|
|
38
|
-
modifierClass: 'site-btn-struct-maia',
|
|
39
|
-
density: 'soft',
|
|
40
|
-
padding: '0.75rem 1.75rem',
|
|
41
|
-
fontSize: '0.875rem',
|
|
42
|
-
borderRadius: '9999px',
|
|
43
|
-
letterSpacing: '0.02em',
|
|
44
|
-
},
|
|
45
|
-
lyra: {
|
|
46
|
-
style: 'lyra',
|
|
47
|
-
modifierClass: 'site-btn-struct-lyra',
|
|
48
|
-
density: 'sharp',
|
|
49
|
-
padding: '0.5rem 1rem',
|
|
50
|
-
fontSize: '0.8125rem',
|
|
51
|
-
borderRadius: '0',
|
|
52
|
-
letterSpacing: '0.04em',
|
|
53
|
-
},
|
|
54
|
-
mira: {
|
|
55
|
-
style: 'mira',
|
|
56
|
-
modifierClass: 'site-btn-struct-mira',
|
|
57
|
-
density: 'dense',
|
|
58
|
-
padding: '0.3125rem 0.75rem',
|
|
59
|
-
fontSize: '0.6875rem',
|
|
60
|
-
borderRadius: 'calc(var(--radius) * 0.5)',
|
|
61
|
-
letterSpacing: '0.02em',
|
|
62
|
-
},
|
|
63
|
-
luma: {
|
|
64
|
-
style: 'luma',
|
|
65
|
-
modifierClass: 'site-btn-struct-luma',
|
|
66
|
-
density: 'balanced',
|
|
67
|
-
padding: '0.625rem 1.25rem',
|
|
68
|
-
fontSize: '0.8125rem',
|
|
69
|
-
borderRadius: 'var(--radius)',
|
|
70
|
-
letterSpacing: 'normal',
|
|
71
|
-
},
|
|
72
|
-
sera: {
|
|
73
|
-
style: 'sera',
|
|
74
|
-
modifierClass: 'site-btn-struct-sera',
|
|
75
|
-
density: 'soft',
|
|
76
|
-
padding: '0.6875rem 1.5rem',
|
|
77
|
-
fontSize: '0.8125rem',
|
|
78
|
-
borderRadius: 'calc(var(--radius) * 1.25)',
|
|
79
|
-
letterSpacing: '0.015em',
|
|
80
|
-
},
|
|
81
|
-
rhea: {
|
|
82
|
-
style: 'rhea',
|
|
83
|
-
modifierClass: 'site-btn-struct-rhea',
|
|
84
|
-
density: 'compact',
|
|
85
|
-
padding: '0.5rem 1rem',
|
|
86
|
-
fontSize: '0.75rem',
|
|
87
|
-
borderRadius: 'calc(var(--radius) * 0.85)',
|
|
88
|
-
letterSpacing: '0.01em',
|
|
89
|
-
},
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export type ShadcnButtonRecipe = {
|
|
93
|
-
structuralStyleId: string;
|
|
94
|
-
density: ShadcnButtonDensity;
|
|
95
|
-
variants: Record<
|
|
96
|
-
SiteButtonVariant,
|
|
97
|
-
{
|
|
98
|
-
baseClass: string;
|
|
99
|
-
modifierClass: string;
|
|
100
|
-
density: ShadcnButtonDensity['density'];
|
|
101
|
-
}
|
|
102
|
-
>;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
/** Parse `base-nova` / `radix-maia` → style axis. */
|
|
106
|
-
export function shadcnStyleFromStructuralId(structuralStyleId: string): ShadcnStyle {
|
|
107
|
-
const suffix = structuralStyleId.split('-').pop();
|
|
108
|
-
if (suffix && suffix in DENSITY_BY_STYLE) {
|
|
109
|
-
return suffix as ShadcnStyle;
|
|
110
|
-
}
|
|
111
|
-
return 'nova';
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export function resolveShadcnButton(
|
|
115
|
-
structuralStyleId: string,
|
|
116
|
-
): ShadcnButtonRecipe {
|
|
117
|
-
const style = shadcnStyleFromStructuralId(structuralStyleId);
|
|
118
|
-
const density = DENSITY_BY_STYLE[style];
|
|
119
|
-
|
|
120
|
-
const variantBase = (variant: SiteButtonVariant) => ({
|
|
121
|
-
baseClass: variant === 'primary' ? 'site-btn-primary' : 'site-btn-secondary',
|
|
122
|
-
modifierClass: density.modifierClass,
|
|
123
|
-
density: density.density,
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
return {
|
|
127
|
-
structuralStyleId,
|
|
128
|
-
density,
|
|
129
|
-
variants: {
|
|
130
|
-
primary: variantBase('primary'),
|
|
131
|
-
secondary: variantBase('secondary'),
|
|
132
|
-
},
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export type ShadcnComponentKind = 'Button';
|
|
137
|
-
|
|
138
|
-
export function resolveShadcnComponent(
|
|
139
|
-
kind: ShadcnComponentKind,
|
|
140
|
-
structuralStyleId: string,
|
|
141
|
-
): ShadcnButtonRecipe {
|
|
142
|
-
if (kind === 'Button') {
|
|
143
|
-
return resolveShadcnButton(structuralStyleId);
|
|
144
|
-
}
|
|
145
|
-
return resolveShadcnButton(structuralStyleId);
|
|
146
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { ComponentLibraryConfig } from './schema';
|
|
2
|
-
import {
|
|
3
|
-
resolveShadcnComponent,
|
|
4
|
-
type ShadcnButtonRecipe,
|
|
5
|
-
type ShadcnComponentKind,
|
|
6
|
-
} from './providers/shadcn/components';
|
|
7
|
-
import { shadcnStyleKey } from './schema';
|
|
8
|
-
|
|
9
|
-
export type ComponentKind = ShadcnComponentKind;
|
|
10
|
-
|
|
11
|
-
export type ResolvedComponent = ShadcnButtonRecipe;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Provider-agnostic component resolver — patterns call this, never shadcn field names.
|
|
15
|
-
* Returns variant recipes (classes + density) for the active structural style.
|
|
16
|
-
*/
|
|
17
|
-
export function resolveComponent(
|
|
18
|
-
kind: ComponentKind,
|
|
19
|
-
config: ComponentLibraryConfig,
|
|
20
|
-
): ResolvedComponent {
|
|
21
|
-
if (config.provider === 'shadcn') {
|
|
22
|
-
const structuralStyleId = shadcnStyleKey(config.shadcn);
|
|
23
|
-
return resolveShadcnComponent(kind, structuralStyleId);
|
|
24
|
-
}
|
|
25
|
-
// MUI stub — fall back to shadcn nova density until MUI adapter ships.
|
|
26
|
-
return resolveShadcnComponent(kind, 'base-nova');
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** Resolve from compiled structuralStyleId (layer 3). */
|
|
30
|
-
export function resolveComponentFromStructuralId(
|
|
31
|
-
kind: ComponentKind,
|
|
32
|
-
structuralStyleId: string,
|
|
33
|
-
): ResolvedComponent {
|
|
34
|
-
return resolveShadcnComponent(kind, structuralStyleId);
|
|
35
|
-
}
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Component library configuration — provider-agnostic skin source of truth.
|
|
3
|
-
*
|
|
4
|
-
* Layer 2 in the skins stack (see specs/2026-06-08-shadcn-create-skins.md):
|
|
5
|
-
* Provider → LibraryConfig → CompiledSkin (cssVars + structuralStyleId)
|
|
6
|
-
*
|
|
7
|
-
* shadcn is v1. MUI and other providers extend the discriminated union without
|
|
8
|
-
* changing site/content/pattern contracts downstream.
|
|
9
|
-
*/
|
|
10
|
-
import { z } from 'zod';
|
|
11
|
-
|
|
12
|
-
// ── shadcn provider (v1) ────────────────────────────────────────────────────
|
|
13
|
-
|
|
14
|
-
export const ShadcnBaseSchema = z.enum(['radix', 'base-ui']);
|
|
15
|
-
export type ShadcnBase = z.infer<typeof ShadcnBaseSchema>;
|
|
16
|
-
|
|
17
|
-
/** Visual density / component structure — affects markup, not just tokens. */
|
|
18
|
-
export const ShadcnStyleSchema = z.enum([
|
|
19
|
-
'vega',
|
|
20
|
-
'nova',
|
|
21
|
-
'maia',
|
|
22
|
-
'lyra',
|
|
23
|
-
'mira',
|
|
24
|
-
'luma',
|
|
25
|
-
'sera',
|
|
26
|
-
'rhea',
|
|
27
|
-
]);
|
|
28
|
-
export type ShadcnStyle = z.infer<typeof ShadcnStyleSchema>;
|
|
29
|
-
|
|
30
|
-
/** Neutral foundation — backgrounds, borders, muted tones. */
|
|
31
|
-
export const ShadcnBaseColorSchema = z.enum([
|
|
32
|
-
'neutral',
|
|
33
|
-
'stone',
|
|
34
|
-
'zinc',
|
|
35
|
-
'slate',
|
|
36
|
-
'gray',
|
|
37
|
-
'mauve',
|
|
38
|
-
'olive',
|
|
39
|
-
'mist',
|
|
40
|
-
'taupe',
|
|
41
|
-
]);
|
|
42
|
-
export type ShadcnBaseColor = z.infer<typeof ShadcnBaseColorSchema>;
|
|
43
|
-
|
|
44
|
-
/** Accent layer merged on top of baseColor. Includes neutrals + chromatic. */
|
|
45
|
-
export const ShadcnThemeColorSchema = z.enum([
|
|
46
|
-
'neutral',
|
|
47
|
-
'stone',
|
|
48
|
-
'zinc',
|
|
49
|
-
'slate',
|
|
50
|
-
'gray',
|
|
51
|
-
'mauve',
|
|
52
|
-
'olive',
|
|
53
|
-
'mist',
|
|
54
|
-
'taupe',
|
|
55
|
-
'red',
|
|
56
|
-
'rose',
|
|
57
|
-
'orange',
|
|
58
|
-
'amber',
|
|
59
|
-
'yellow',
|
|
60
|
-
'lime',
|
|
61
|
-
'green',
|
|
62
|
-
'emerald',
|
|
63
|
-
'teal',
|
|
64
|
-
'cyan',
|
|
65
|
-
'sky',
|
|
66
|
-
'blue',
|
|
67
|
-
'indigo',
|
|
68
|
-
'violet',
|
|
69
|
-
'purple',
|
|
70
|
-
'fuchsia',
|
|
71
|
-
'pink',
|
|
72
|
-
]);
|
|
73
|
-
export type ShadcnThemeColor = z.infer<typeof ShadcnThemeColorSchema>;
|
|
74
|
-
|
|
75
|
-
/** Chart Color axis — chromatic Tailwind colors (matches upstream PRESET_CHART_COLORS). */
|
|
76
|
-
export const ShadcnChartColorSchema = z.enum([
|
|
77
|
-
'neutral',
|
|
78
|
-
'stone',
|
|
79
|
-
'zinc',
|
|
80
|
-
'gray',
|
|
81
|
-
'mauve',
|
|
82
|
-
'olive',
|
|
83
|
-
'mist',
|
|
84
|
-
'taupe',
|
|
85
|
-
'amber',
|
|
86
|
-
'blue',
|
|
87
|
-
'cyan',
|
|
88
|
-
'emerald',
|
|
89
|
-
'fuchsia',
|
|
90
|
-
'green',
|
|
91
|
-
'indigo',
|
|
92
|
-
'lime',
|
|
93
|
-
'orange',
|
|
94
|
-
'pink',
|
|
95
|
-
'purple',
|
|
96
|
-
'red',
|
|
97
|
-
'rose',
|
|
98
|
-
'sky',
|
|
99
|
-
'teal',
|
|
100
|
-
'violet',
|
|
101
|
-
'yellow',
|
|
102
|
-
]);
|
|
103
|
-
export type ShadcnChartColor = z.infer<typeof ShadcnChartColorSchema>;
|
|
104
|
-
|
|
105
|
-
export const ShadcnRadiusSchema = z.enum(['default', 'none', 'sm', 'md', 'lg', 'xl']);
|
|
106
|
-
export type ShadcnRadius = z.infer<typeof ShadcnRadiusSchema>;
|
|
107
|
-
|
|
108
|
-
export const ShadcnIconLibrarySchema = z.enum([
|
|
109
|
-
'lucide',
|
|
110
|
-
'tabler',
|
|
111
|
-
'hugeicons',
|
|
112
|
-
'phosphor',
|
|
113
|
-
'remixicon',
|
|
114
|
-
]);
|
|
115
|
-
export type ShadcnIconLibrary = z.infer<typeof ShadcnIconLibrarySchema>;
|
|
116
|
-
|
|
117
|
-
export const ShadcnMenuColorSchema = z.enum([
|
|
118
|
-
'default',
|
|
119
|
-
'inverted',
|
|
120
|
-
'default-translucent',
|
|
121
|
-
'inverted-translucent',
|
|
122
|
-
]);
|
|
123
|
-
export type ShadcnMenuColor = z.infer<typeof ShadcnMenuColorSchema>;
|
|
124
|
-
|
|
125
|
-
export const ShadcnMenuAccentSchema = z.enum(['subtle', 'bold']);
|
|
126
|
-
export type ShadcnMenuAccent = z.infer<typeof ShadcnMenuAccentSchema>;
|
|
127
|
-
|
|
128
|
-
export const ShadcnFontHeadingSchema = z.union([z.literal('inherit'), z.string().min(1)]);
|
|
129
|
-
export type ShadcnFontHeading = z.infer<typeof ShadcnFontHeadingSchema>;
|
|
130
|
-
|
|
131
|
-
/** Full shadcn/create axis set — matches upstream presetSchema. */
|
|
132
|
-
export const ShadcnLibraryConfigSchema = z.object({
|
|
133
|
-
base: ShadcnBaseSchema.default('base-ui'),
|
|
134
|
-
style: ShadcnStyleSchema.default('nova'),
|
|
135
|
-
baseColor: ShadcnBaseColorSchema.default('neutral'),
|
|
136
|
-
theme: ShadcnThemeColorSchema.default('neutral'),
|
|
137
|
-
chartColor: ShadcnChartColorSchema.default('neutral'),
|
|
138
|
-
radius: ShadcnRadiusSchema.default('default'),
|
|
139
|
-
font: z.string().min(1).default('geist'),
|
|
140
|
-
fontHeading: ShadcnFontHeadingSchema.default('inherit'),
|
|
141
|
-
iconLibrary: ShadcnIconLibrarySchema.default('lucide'),
|
|
142
|
-
menuColor: ShadcnMenuColorSchema.default('default'),
|
|
143
|
-
menuAccent: ShadcnMenuAccentSchema.default('subtle'),
|
|
144
|
-
});
|
|
145
|
-
export type ShadcnLibraryConfig = z.infer<typeof ShadcnLibraryConfigSchema>;
|
|
146
|
-
|
|
147
|
-
/** shadcn/create preset b2fA — single source for workshop empty state. */
|
|
148
|
-
export const SHADCN_CREATE_DEFAULT_CONFIG: ShadcnLibraryConfig = {
|
|
149
|
-
base: 'base-ui',
|
|
150
|
-
style: 'nova',
|
|
151
|
-
baseColor: 'neutral',
|
|
152
|
-
theme: 'neutral',
|
|
153
|
-
chartColor: 'neutral',
|
|
154
|
-
font: 'geist',
|
|
155
|
-
fontHeading: 'inherit',
|
|
156
|
-
iconLibrary: 'lucide',
|
|
157
|
-
radius: 'default',
|
|
158
|
-
menuAccent: 'subtle',
|
|
159
|
-
menuColor: 'default',
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
/** Denormalized style key for components.json / CLI parity (`base-nova`). */
|
|
163
|
-
export function shadcnStyleKey(config: Pick<ShadcnLibraryConfig, 'base' | 'style'>): string {
|
|
164
|
-
const prefix = config.base === 'base-ui' ? 'base' : 'radix';
|
|
165
|
-
return `${prefix}-${config.style}`;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
// ── mui provider (future — schema only) ─────────────────────────────────────
|
|
169
|
-
|
|
170
|
-
export const MuiDensitySchema = z.enum(['comfortable', 'standard', 'compact']);
|
|
171
|
-
export type MuiDensity = z.infer<typeof MuiDensitySchema>;
|
|
172
|
-
|
|
173
|
-
/** Stub for future MUI support — not wired to compile or UI yet. */
|
|
174
|
-
export const MuiLibraryConfigSchema = z.object({
|
|
175
|
-
theme: z.string().min(1),
|
|
176
|
-
palette: z.enum(['light', 'dark']),
|
|
177
|
-
density: MuiDensitySchema.default('standard'),
|
|
178
|
-
primaryColor: z.string().optional(),
|
|
179
|
-
fontFamily: z.string().optional(),
|
|
180
|
-
});
|
|
181
|
-
export type MuiLibraryConfig = z.infer<typeof MuiLibraryConfigSchema>;
|
|
182
|
-
|
|
183
|
-
// ── provider union ────────────────────────────────────────────────────────────
|
|
184
|
-
|
|
185
|
-
export const ComponentLibraryProviderSchema = z.enum(['shadcn', 'mui']);
|
|
186
|
-
export type ComponentLibraryProvider = z.infer<typeof ComponentLibraryProviderSchema>;
|
|
187
|
-
|
|
188
|
-
export const ComponentLibraryConfigSchema = z.discriminatedUnion('provider', [
|
|
189
|
-
z.object({
|
|
190
|
-
provider: z.literal('shadcn'),
|
|
191
|
-
shadcn: ShadcnLibraryConfigSchema,
|
|
192
|
-
}),
|
|
193
|
-
z.object({
|
|
194
|
-
provider: z.literal('mui'),
|
|
195
|
-
mui: MuiLibraryConfigSchema,
|
|
196
|
-
}),
|
|
197
|
-
]);
|
|
198
|
-
export type ComponentLibraryConfig = z.infer<typeof ComponentLibraryConfigSchema>;
|
|
199
|
-
|
|
200
|
-
/** Default for new accounts — shadcn/create preset b2fA. */
|
|
201
|
-
export const DEFAULT_COMPONENT_LIBRARY_CONFIG: ComponentLibraryConfig = {
|
|
202
|
-
provider: 'shadcn',
|
|
203
|
-
shadcn: SHADCN_CREATE_DEFAULT_CONFIG,
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
// ── compiled output (layer 3 — provider-agnostic) ─────────────────────────────
|
|
207
|
-
|
|
208
|
-
export const CompiledSkinSchema = z.object({
|
|
209
|
-
provider: ComponentLibraryProviderSchema,
|
|
210
|
-
/** Provider-specific structural id — e.g. `base-nova` for shadcn. */
|
|
211
|
-
structuralStyleId: z.string().min(1),
|
|
212
|
-
cssVars: z.object({
|
|
213
|
-
light: z.record(z.string(), z.string()),
|
|
214
|
-
dark: z.record(z.string(), z.string()),
|
|
215
|
-
}),
|
|
216
|
-
/** Round-trip source config. */
|
|
217
|
-
libraryConfig: ComponentLibraryConfigSchema,
|
|
218
|
-
});
|
|
219
|
-
export type CompiledSkin = z.infer<typeof CompiledSkinSchema>;
|