create-forte-ui 1.0.0-alpha.8 → 1.0.0-beta.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/dist/overlay.js +7 -2
- package/dist/templates.js +10 -4
- package/dist/theme.d.ts +14 -1
- package/dist/theme.js +17 -5
- package/package.json +1 -1
package/dist/overlay.js
CHANGED
|
@@ -40,9 +40,14 @@ function applyVite({ name, dir, tailwind, answers }) {
|
|
|
40
40
|
* report it, never guess. */
|
|
41
41
|
const htmlPath = path.join(dir, "index.html");
|
|
42
42
|
let html = fs.readFileSync(htmlPath, "utf8");
|
|
43
|
-
|
|
43
|
+
/* `forte-reset` is unconditional — it switches on the reset stylesheet
|
|
44
|
+
* index.css imports, so the two must not drift. That makes the anchor
|
|
45
|
+
* always load-bearing here, unlike the theme attributes, which are empty on
|
|
46
|
+
* an all-defaults run: the guard below therefore checks the replacement
|
|
47
|
+
* outright rather than only when `attrs` is non-empty. */
|
|
48
|
+
const attrs = `${htmlAttrs(answers)} class="forte-reset"`;
|
|
44
49
|
const anchored = html.replace(/<html lang="en">/, `<html lang="en"${attrs}>`);
|
|
45
|
-
if (
|
|
50
|
+
if (anchored === html) {
|
|
46
51
|
throw new Error(`could not find '<html lang="en">' in index.html to add${attrs} — ` +
|
|
47
52
|
`the create-vite template may have changed; add the attribute(s) by hand.`);
|
|
48
53
|
}
|
package/dist/templates.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* diff a scaffolded app against the walkthrough and see only their own
|
|
5
5
|
* answers. When a guide step changes, change the builder with it.
|
|
6
6
|
*/
|
|
7
|
-
import { rootBlock, fontImports, htmlAttrs, nextFontSetup } from "./theme.js";
|
|
7
|
+
import { rootBlock, fontImports, htmlAttrs, htmlClassAttr, nextFontSetup, } from "./theme.js";
|
|
8
8
|
/* The body rule from the guides' "Replace the scaffold CSS" step. Present on
|
|
9
9
|
* the non-Tailwind paths only — the Tailwind starter page carries the same
|
|
10
10
|
* three declarations as utilities on `<main>`. */
|
|
@@ -56,6 +56,7 @@ export function viteIndexCss(a, tailwind) {
|
|
|
56
56
|
return joinBlocks(fontBlock, `@import "@forte-ui/react/tailwind.css";
|
|
57
57
|
@import "tailwindcss";
|
|
58
58
|
@import "@forte-ui/react/theme.css";
|
|
59
|
+
@import "@forte-ui/react/styles/reset.css";
|
|
59
60
|
`, rootBlock(a, "import"));
|
|
60
61
|
}
|
|
61
62
|
return joinBlocks(fontBlock, rootBlock(a, "import"), BODY_RULE);
|
|
@@ -65,7 +66,9 @@ export function viteMainTsx(tailwind) {
|
|
|
65
66
|
* bridge — importing it here would pin the `forte` layer first and hand
|
|
66
67
|
* Preflight the win. Without Tailwind there is no ordering hazard and the
|
|
67
68
|
* guide imports it at the entry point. */
|
|
68
|
-
const themeImport = tailwind
|
|
69
|
+
const themeImport = tailwind
|
|
70
|
+
? ""
|
|
71
|
+
: `import "@forte-ui/react/theme.css";\nimport "@forte-ui/react/styles/reset.css";\n`;
|
|
69
72
|
return `import { StrictMode } from "react";
|
|
70
73
|
import { createRoot } from "react-dom/client";
|
|
71
74
|
${themeImport}import "./index.css";
|
|
@@ -130,6 +133,7 @@ export function nextGlobalsCss(a, tailwind) {
|
|
|
130
133
|
return joinBlocks(`@import "@forte-ui/react/tailwind.css";
|
|
131
134
|
@import "tailwindcss";
|
|
132
135
|
@import "@forte-ui/react/theme.css";
|
|
136
|
+
@import "@forte-ui/react/styles/reset.css";
|
|
133
137
|
`, rootBlock(a, "next-font"));
|
|
134
138
|
}
|
|
135
139
|
return joinBlocks(rootBlock(a, "next-font"), BODY_RULE);
|
|
@@ -140,7 +144,9 @@ export function nextLayoutTsx(name, a, tailwind) {
|
|
|
140
144
|
* because nothing else declares layers. With Tailwind it must NOT be:
|
|
141
145
|
* globals.css imports it after the bridge (see the guide's ordering note),
|
|
142
146
|
* and a second import here would pin the `forte` layer before `base`. */
|
|
143
|
-
const themeImport = tailwind
|
|
147
|
+
const themeImport = tailwind
|
|
148
|
+
? ""
|
|
149
|
+
: `import "@forte-ui/react/theme.css";\nimport "@forte-ui/react/styles/reset.css";\n`;
|
|
144
150
|
/* ThemeScript + suppressHydrationWarning are the guides' "Light and dark"
|
|
145
151
|
* step: the script replays a stored light/dark choice onto <html> before
|
|
146
152
|
* first paint, and the suppression covers the attribute it legitimately
|
|
@@ -175,7 +181,7 @@ export default function RootLayout({
|
|
|
175
181
|
children: React.ReactNode;
|
|
176
182
|
}>) {
|
|
177
183
|
return (
|
|
178
|
-
<html lang="en"${htmlAttrs(a)}${font.
|
|
184
|
+
<html lang="en"${htmlAttrs(a)}${htmlClassAttr(font.fontVars)}${pinned ? "" : " suppressHydrationWarning"}>
|
|
179
185
|
${head} <body>
|
|
180
186
|
${toggleLine} {children}
|
|
181
187
|
</body>
|
package/dist/theme.d.ts
CHANGED
|
@@ -46,6 +46,19 @@ export type NextFontSetup = {
|
|
|
46
46
|
/** The `const fontSans = Inter({...});` declarations, or "". */
|
|
47
47
|
consts: string;
|
|
48
48
|
/** ` className={...}` for the `<html>` element, or "". */
|
|
49
|
-
|
|
49
|
+
/** The `next/font` CSS-variable idents, e.g. ["fontSans.variable"]. The
|
|
50
|
+
* `<html>` class list is composed from these plus `forte-reset`, which is
|
|
51
|
+
* why this is the parts rather than a finished attribute. */
|
|
52
|
+
fontVars: string[];
|
|
50
53
|
};
|
|
51
54
|
export declare function nextFontSetup(a: ThemeAnswers): NextFontSetup;
|
|
55
|
+
/** ` className="forte-reset"` — or a template literal when next/font variables
|
|
56
|
+
* have to ride along on the same element.
|
|
57
|
+
*
|
|
58
|
+
* `forte-reset` is unconditional: it is what switches on
|
|
59
|
+
* `@forte-ui/react/styles/reset.css`, which the starter imports. A scaffolded
|
|
60
|
+
* app is the one place the blanket reset is unambiguously right — there is no
|
|
61
|
+
* existing markup for it to change behaviour under, and it becomes the
|
|
62
|
+
* baseline everything the author writes next is built against. The library
|
|
63
|
+
* itself stays scoped to `[data-forte]` for exactly the opposite reason. */
|
|
64
|
+
export declare function htmlClassAttr(fontVars: string[]): string;
|
package/dist/theme.js
CHANGED
|
@@ -113,7 +113,7 @@ export function nextFontSetup(a) {
|
|
|
113
113
|
{ font: findFont(MONO_FONTS, a.fontMono), variable: "--font-mono", ident: "fontMono" },
|
|
114
114
|
].filter((p) => p.font.css);
|
|
115
115
|
if (picks.length === 0)
|
|
116
|
-
return { importLine: "", consts: "",
|
|
116
|
+
return { importLine: "", consts: "", fontVars: [] };
|
|
117
117
|
const names = picks.map((p) => p.font.name.replaceAll(" ", "_"));
|
|
118
118
|
const consts = picks
|
|
119
119
|
.map((p, i) => {
|
|
@@ -122,12 +122,24 @@ export function nextFontSetup(a) {
|
|
|
122
122
|
return `const ${p.ident} = ${names[i]}({ subsets: ["latin"], variable: "${p.variable}"${weightOpt} });`;
|
|
123
123
|
})
|
|
124
124
|
.join("\n");
|
|
125
|
-
const classExpr = picks.length === 1
|
|
126
|
-
? `{${picks[0].ident}.variable}`
|
|
127
|
-
: `{\`\${fontSans.variable} \${fontMono.variable}\`}`;
|
|
128
125
|
return {
|
|
129
126
|
importLine: `import { ${names.join(", ")} } from "next/font/google";`,
|
|
130
127
|
consts,
|
|
131
|
-
|
|
128
|
+
fontVars: picks.map((p) => `${p.ident}.variable`),
|
|
132
129
|
};
|
|
133
130
|
}
|
|
131
|
+
/** ` className="forte-reset"` — or a template literal when next/font variables
|
|
132
|
+
* have to ride along on the same element.
|
|
133
|
+
*
|
|
134
|
+
* `forte-reset` is unconditional: it is what switches on
|
|
135
|
+
* `@forte-ui/react/styles/reset.css`, which the starter imports. A scaffolded
|
|
136
|
+
* app is the one place the blanket reset is unambiguously right — there is no
|
|
137
|
+
* existing markup for it to change behaviour under, and it becomes the
|
|
138
|
+
* baseline everything the author writes next is built against. The library
|
|
139
|
+
* itself stays scoped to `[data-forte]` for exactly the opposite reason. */
|
|
140
|
+
export function htmlClassAttr(fontVars) {
|
|
141
|
+
if (fontVars.length === 0)
|
|
142
|
+
return ` className="forte-reset"`;
|
|
143
|
+
const vars = fontVars.map((v) => `\${${v}}`).join(" ");
|
|
144
|
+
return ` className={\`forte-reset ${vars}\`}`;
|
|
145
|
+
}
|
package/package.json
CHANGED