Skip to content

refactor: unify theme css imports#336

Open
Kinfe123 wants to merge 4 commits into
mainfrom
refactor/unify-theme-css-imports
Open

refactor: unify theme css imports#336
Kinfe123 wants to merge 4 commits into
mainfrom
refactor/unify-theme-css-imports

Conversation

@Kinfe123

@Kinfe123 Kinfe123 commented Jul 6, 2026

Copy link
Copy Markdown
Member

Summary

  • Add a shared framework CSS bundle to @farming-labs/theme so every built-in theme can be imported through @farming-labs/theme/<theme>/css across Next.js, TanStack Start, SvelteKit, Astro, and Nuxt.
  • Mark non-React docs layout roots with data-fd-framework and scope the shared structural CSS to those adapters.
  • Update CLI templates, install/upgrade package lists, examples, docs, website snippets, and agent skill guidance to use the unified theme CSS package.

Validation

  • pnpm install --lockfile-only --frozen-lockfile
  • pnpm run format:check
  • pnpm test
  • pnpm typecheck
  • pnpm --filter @farming-labs/theme run build
  • pnpm --dir examples/sveltekit build
  • pnpm --dir examples/astro build
  • pnpm --dir examples/nuxt build
  • pnpm --dir examples/next build
  • pnpm --dir examples/tanstack-start build
  • Browser checks for SvelteKit, Astro, Nuxt, Next, and TanStack docs pages
  • pnpm run lint passes with 0 errors and 10 existing warnings

Notes

  • The repo does not currently have a refactor GitHub label, so this uses the requested refactor: prefix in the commit and PR title.
  • No baseline screenshot suite exists for literal pixel-diff verification; browser checks covered page load, layout visibility, overflow, and console issues.

Summary by cubic

Unifies theme CSS imports across frameworks using a shared bundle in @farming-labs/theme, so all themes load from @farming-labs/theme/<theme>/css. Also aligns Hardline heading/page‑nav styles across adapters and fixes dev configs.

  • Refactors

    • Added shared CSS bundle and build script in @farming-labs/theme; themes import styles/bundles/shared-framework.css.
    • Standardized @farming-labs/theme/<theme>/css imports for Next.js, TanStack Start, SvelteKit, Astro, and Nuxt.
    • Scoped structural CSS by marking layout roots with id="nd-docs-layout" + data-fd-framework (Astro, SvelteKit, Nuxt).
    • Hardline updates: consistent boxed headings across adapters, cleaned page‑nav styles, removed forced uppercase, tuned dark‑mode shadows.
    • CLI/templates/upgrade now add @farming-labs/theme; updated examples, docs, and website.
    • Dev fixes: Astro dev toolbar disabled; SvelteKit Vite target/optimizeDeps set to es2022 and base body styles moved into layout; Nuxt optimizeDeps includes @farming-labs/theme; safer Svelte tag injection to avoid preprocessor issues.
  • Migration

    • Replace imports:
      • SvelteKit: @farming-labs/svelte-theme/<theme>/css@farming-labs/theme/<theme>/css
      • Astro: @farming-labs/astro-theme/<theme>/css@farming-labs/theme/<theme>/css
      • Nuxt: css: ["@farming-labs/nuxt-theme/<theme>/css"]css: ["@farming-labs/theme/<theme>/css"]
    • Add @farming-labs/theme to deps for Astro, SvelteKit, and Nuxt.
    • Theme factory imports are unchanged.

Written for commit af70678. Summary will update on new commits.

Review in cubic

@vercel

vercel Bot commented Jul 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs-website Ready Ready Preview, Comment Jul 6, 2026 2:10pm
farming-labs-docs-docs-cloud Building Building Preview, Comment Jul 6, 2026 2:10pm

Request Review

@Kinfe123 Kinfe123 marked this pull request as ready for review July 6, 2026 07:02

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your trial has ended. Reactivate Greptile to resume code reviews.

@pkg-pr-new

pkg-pr-new Bot commented Jul 6, 2026

Copy link
Copy Markdown

Open in StackBlitz

@farming-labs/astro

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/astro@336

@farming-labs/astro-theme

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/astro-theme@336

@farming-labs/docs

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/docs@336

@farming-labs/theme

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/theme@336

@farming-labs/next

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/next@336

@farming-labs/nuxt

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/nuxt@336

@farming-labs/nuxt-theme

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/nuxt-theme@336

@farming-labs/svelte

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/svelte@336

@farming-labs/svelte-theme

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/svelte-theme@336

@farming-labs/tanstack-start

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/tanstack-start@336

commit: af70678

@Kinfe123 Kinfe123 changed the title [codex] refactor: unify theme css imports refactor: unify theme css imports Jul 6, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 45 files

Not reviewed (too large): packages/fumadocs/styles/bundles/shared-framework.css (~10,457 lines) - if these are generated or fixture files, add them to ignored paths to exclude them from future reviews.

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="website/app/docs/installation/page.mdx">

<violation number="1" location="website/app/docs/installation/page.mdx:539">
P2: The docs tell users to pick a CSS import that "matches the theme in your config," but the config snippet uses `fumadocs()` while the CSS example uses `default/css`. There is no documented mapping between the `fumadocs()` theme factory and the `default/css` path, so a user could reasonably derive a non-existent path like `@farming-labs/theme/fumadocs/css`. Consider explicitly documenting that the default `fumadocs()` theme maps to `default/css` — or rephrasing the guidance so it doesn't imply the theme function name and CSS path are the same.</violation>
</file>

<file name="packages/docs/src/cli/templates.ts">

<violation number="1" location="packages/docs/src/cli/templates.ts:149">
P2: The `hasBuiltInThemeCssImport` helper's package-prefix and `/css` checks are evaluated independently, so any file that contains an unrelated local import with `/css` in its path (e.g., `./vendor/css/reset.css`) alongside any `@farming-labs/theme/` prefix will incorrectly skip the required theme CSS injection. Because this unified helper is now shared by all four framework injectors, the false-positive path affects every scaffolded framework. Consider matching the import as a single quoted path — for example with a regex like `@farming-labs\\/(?:theme|svelte-theme|astro-theme|nuxt-theme)\\/[^"'\\n]*\\/css` — so the package name and `/css` must be part of the same import specifier.</violation>
</file>

Tip: cubic can generate docs of your entire codebase and keep them up to date. Try it here.

Re-trigger cubic

### 5. Import theme CSS in `src/app.css`

Add your theme's CSS to your global stylesheet so docs styling applies. Use the import that matches the theme in your config (e.g. `fumadocs` below; for `greentree` use `@farming-labs/svelte-theme/greentree/css`).
Add your theme's CSS to your global stylesheet so docs styling applies. Use the import that matches the theme in your config (e.g. `default` below; for `greentree` use `@farming-labs/theme/greentree/css`).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The docs tell users to pick a CSS import that "matches the theme in your config," but the config snippet uses fumadocs() while the CSS example uses default/css. There is no documented mapping between the fumadocs() theme factory and the default/css path, so a user could reasonably derive a non-existent path like @farming-labs/theme/fumadocs/css. Consider explicitly documenting that the default fumadocs() theme maps to default/css — or rephrasing the guidance so it doesn't imply the theme function name and CSS path are the same.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At website/app/docs/installation/page.mdx, line 539:

<comment>The docs tell users to pick a CSS import that "matches the theme in your config," but the config snippet uses `fumadocs()` while the CSS example uses `default/css`. There is no documented mapping between the `fumadocs()` theme factory and the `default/css` path, so a user could reasonably derive a non-existent path like `@farming-labs/theme/fumadocs/css`. Consider explicitly documenting that the default `fumadocs()` theme maps to `default/css` — or rephrasing the guidance so it doesn't imply the theme function name and CSS path are the same.</comment>

<file context>
@@ -536,10 +536,10 @@ Replace `my-docs` with your project name. Then run `cd my-docs` and start the de
     ### 5. Import theme CSS in `src/app.css`
 
-    Add your theme's CSS to your global stylesheet so docs styling applies. Use the import that matches the theme in your config (e.g. `fumadocs` below; for `greentree` use `@farming-labs/svelte-theme/greentree/css`).
+    Add your theme's CSS to your global stylesheet so docs styling applies. Use the import that matches the theme in your config (e.g. `default` below; for `greentree` use `@farming-labs/theme/greentree/css`).
 
     ```css title="src/app.css"
</file context>

return `@farming-labs/theme/${getThemeInfo(theme).nextCssImport}/css`;
}

function hasBuiltInThemeCssImport(content: string): boolean {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The hasBuiltInThemeCssImport helper's package-prefix and /css checks are evaluated independently, so any file that contains an unrelated local import with /css in its path (e.g., ./vendor/css/reset.css) alongside any @farming-labs/theme/ prefix will incorrectly skip the required theme CSS injection. Because this unified helper is now shared by all four framework injectors, the false-positive path affects every scaffolded framework. Consider matching the import as a single quoted path — for example with a regex like @farming-labs\\/(?:theme|svelte-theme|astro-theme|nuxt-theme)\\/[^"'\\n]*\\/css — so the package name and /css must be part of the same import specifier.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/docs/src/cli/templates.ts, line 149:

<comment>The `hasBuiltInThemeCssImport` helper's package-prefix and `/css` checks are evaluated independently, so any file that contains an unrelated local import with `/css` in its path (e.g., `./vendor/css/reset.css`) alongside any `@farming-labs/theme/` prefix will incorrectly skip the required theme CSS injection. Because this unified helper is now shared by all four framework injectors, the false-positive path affects every scaffolded framework. Consider matching the import as a single quoted path — for example with a regex like `@farming-labs\\/(?:theme|svelte-theme|astro-theme|nuxt-theme)\\/[^"'\\n]*\\/css` — so the package name and `/css` must be part of the same import specifier.</comment>

<file context>
@@ -168,16 +135,27 @@ const THEME_INFO: Record<string, ThemeInfo> = {
+  return `@farming-labs/theme/${getThemeInfo(theme).nextCssImport}/css`;
+}
+
+function hasBuiltInThemeCssImport(content: string): boolean {
+  return (
+    (content.includes("@farming-labs/theme/") ||
</file context>
Suggested change
function hasBuiltInThemeCssImport(content: string): boolean {
function hasBuiltInThemeCssImport(content: string): boolean {
return /["']@farming-labs\/(?:theme|svelte-theme|astro-theme|nuxt-theme)\/[^"'\n]*\/css["']/.test(
content,
);
}

@Kinfe123

Kinfe123 commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

Re-verified after opening the PR using the repo-pinned package manager (corepack pnpm, pnpm 10.9.0):

  • Confirmed examples/docs/CLI guidance use @farming-labs/theme/<theme>/css and old framework CSS paths are gone from the checked surfaces.
  • Confirmed non-React layout roots opt into the shared framework CSS with data-fd-framework.
  • corepack pnpm --filter @farming-labs/theme run build
  • corepack pnpm --filter @farming-labs/docs run build
  • corepack pnpm --dir examples/sveltekit build
  • Astro equivalent build steps: sitemap generation + corepack pnpm exec astro build
  • corepack pnpm --dir examples/nuxt build
  • corepack pnpm --dir examples/next build
  • corepack pnpm --dir examples/tanstack-start build
  • corepack pnpm run format:check

Notes: plain pnpm in this Codex shell resolves to pnpm 11.7.0 and ignores the repo's legacy pnpm.overrides lockfile config, so I used the pinned Corepack pnpm. The initial Nuxt/Next failures were transient when running builds in parallel; both passed when rerun sequentially. No PR file changes were needed from this re-check.

@Kinfe123

Kinfe123 commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

Follow-up runnability check and fixes:

Fixed:

  • SvelteKit dev failed during Vite dependency scanning because the dynamic theme init <script> body was visible to Vite as ${themeInitScript}. The Svelte layout now builds the script tag from split strings, matching the existing dynamic style-tag workaround.
  • SvelteKit dev optimizer now targets es2022, matching the example build target and avoiding Svelte 5 source transform errors.
  • Astro dev was rendering but logged a 504 from Astro's dev toolbar optimized dependency; disabled the dev toolbar for the example.
  • Nuxt docs pages passed AskAITrigger as a component prop without importing the component; both docs routes now import it explicitly.

Browser-verified dev servers with Playwright:

  • SvelteKit: corepack pnpm --dir examples/sveltekit dev --host 127.0.0.1 --port 5174, checked /docs => 200, content rendered, data-fd-framework="sveltekit", no overlay, no failed responses, no page errors.
  • Astro: corepack pnpm --dir examples/astro dev --host 127.0.0.1 --port 4322, checked /docs => 200, content rendered, data-fd-framework="astro", no overlay, no failed responses, no page errors.
  • Nuxt: corepack pnpm --dir examples/nuxt dev --host 127.0.0.1 --port 3005, checked /docs => 200, content rendered, data-fd-framework="nuxt", custom Ask AI trigger rendered, no failed responses, no page errors.
  • Next: corepack pnpm --dir examples/next dev --hostname 127.0.0.1 --port 3006, checked /docs => 200, content rendered, no overlay, no failed responses, no page errors. Existing metadataBase warning remains.
  • TanStack Start: corepack pnpm --dir examples/tanstack-start dev --host 127.0.0.1 --port 3008, checked /docs => 200, content rendered, no overlay, no failed responses, no page errors.

Build/quality after fixes:

  • corepack pnpm --dir examples/sveltekit build
  • corepack pnpm --dir examples/nuxt build
  • Astro sitemap generation + corepack pnpm exec astro build
  • corepack pnpm --filter @farming-labs/theme run build
  • corepack pnpm run format:check
  • corepack pnpm run lint passes with 0 errors and the same existing 10 warnings.

@Kinfe123

Kinfe123 commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

Confirmed the hardline footer issue from the SvelteKit screenshot. The exact oversized nav did not reproduce in the current Next example because it uses different React/Fumadocs footer markup, but it did reproduce across the non-React hardline examples: SvelteKit, Astro, and Nuxt.\n\nPushed fix a77a9bf4: removes the hardline card treatment from the nav container and resets the non-React prev/next card inherited min-heights in the shared framework CSS bundle.\n\nVerified after the fix:\n- Browser checks on SvelteKit, Astro, and Nuxt: nav container is transparent/no shadow, actual next card is compact (~79px instead of 140px), no page errors or failed requests.\n- Dark-mode SvelteKit visual check matches the intended compact hardline footer.\n- corepack pnpm --filter @farming-labs/theme run build\n- corepack pnpm run format:check\n- corepack pnpm run lint (same 10 existing warnings, 0 errors)\n- corepack pnpm --dir examples/sveltekit build\n- corepack pnpm --dir examples/nuxt build\n- Astro build via pinned manual path: corepack pnpm --filter @farming-labs/docs run build, sitemap generate, corepack pnpm exec astro build from examples/astro\n\nNote: corepack pnpm --dir examples/astro build still fails in this environment because the package script invokes bare pnpm, which resolves to pnpm 11 and attempts a node_modules purge without a TTY. The pinned manual steps pass.

@Kinfe123 Kinfe123 added the refactor: theme css Refactor theme CSS exports and framework styling label Jul 6, 2026
@Kinfe123

Kinfe123 commented Jul 6, 2026

Copy link
Copy Markdown
Member Author

Updated the PR with the SvelteKit Hardline parity fix.

What changed:

  • Let runtime theme layout tokens win over shared framework CSS fallbacks, so Hardline's contentWidth is honored.
  • Constrained the framework article column to the theme content width instead of stretching full-width.
  • Scoped the article+TOC two-column grid to wide desktop only, which fixes the mobile collapse where the hidden TOC still reserved 268px.
  • Added non-React Hardline heading chip styling and code fence titles in the SvelteKit example so it matches the Next hardline comparison more closely.

Verified:

  • Playwright desktop/mobile visual + layout metrics on SvelteKit Hardline. Mobile now reports 390px page/article, 358px content, display: none TOC, and no horizontal overflow.
  • corepack pnpm --filter @farming-labs/theme run build
  • corepack pnpm run format:check
  • corepack pnpm run lint (10 existing warnings, 0 errors)
  • corepack pnpm --dir examples/sveltekit build
  • corepack pnpm --dir examples/nuxt build
  • Astro manual build path: @farming-labs/docs build, sitemap generation, corepack pnpm exec astro build
  • corepack pnpm --dir examples/next build

Notes: Nuxt/Astro/SvelteKit builds still print the existing gray-matter eval warning; Astro also notes local Node 23 while Vercel uses Node 24; Next prints the existing Turbopack NFT and metadataBase warnings. None failed the build.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 4 files (changes from recent commits).

Not reviewed (too large): packages/fumadocs/styles/bundles/shared-framework.css (~34 lines) - if these are generated or fixture files, add them to ignored paths to exclude them from future reviews.

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/fumadocs/styles/hardline.css">

<violation number="1" location="packages/fumadocs/styles/hardline.css:269">
P2: The Hardline theme's `.fd-docs-content h1–h4` headings lost their previous `text-transform: uppercase` declaration. This appears unrelated to the PR's stated goal of unifying CSS imports and scoping structural CSS to framework adapters. Uppercase remains in use for other Hardline elements (table headers, sidebar labels, nav cards), so removing it only from the primary content headings breaks internal consistency and is likely an accidental omission during the refactor. If intentional, it should be documented; otherwise the declaration should be restored.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

.fd-docs-content h3,
.fd-docs-content h4 {
text-transform: uppercase;
letter-spacing: 0.01em;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The Hardline theme's .fd-docs-content h1–h4 headings lost their previous text-transform: uppercase declaration. This appears unrelated to the PR's stated goal of unifying CSS imports and scoping structural CSS to framework adapters. Uppercase remains in use for other Hardline elements (table headers, sidebar labels, nav cards), so removing it only from the primary content headings breaks internal consistency and is likely an accidental omission during the refactor. If intentional, it should be documented; otherwise the declaration should be restored.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/fumadocs/styles/hardline.css, line 269:

<comment>The Hardline theme's `.fd-docs-content h1–h4` headings lost their previous `text-transform: uppercase` declaration. This appears unrelated to the PR's stated goal of unifying CSS imports and scoping structural CSS to framework adapters. Uppercase remains in use for other Hardline elements (table headers, sidebar labels, nav cards), so removing it only from the primary content headings breaks internal consistency and is likely an accidental omission during the refactor. If intentional, it should be documented; otherwise the declaration should be restored.</comment>

<file context>
@@ -266,7 +266,6 @@ aside button[class*="bg-fd-secondary"] {
 .fd-docs-content h3,
 .fd-docs-content h4 {
-  text-transform: uppercase;
   letter-spacing: 0.01em;
 }
 
</file context>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor: theme css Refactor theme CSS exports and framework styling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant