@devalok/shilp-sutra 0.37.1 → 0.38.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/MIGRATION.md +67 -0
- package/dist/_chunks/tiptap.js +977 -968
- package/dist/_chunks/tiptap.js.map +1 -1
- package/dist/composed/index.d.ts +0 -2
- package/dist/composed/index.d.ts.map +1 -1
- package/dist/composed/index.js +5 -6
- package/dist/hooks/index.d.ts +2 -2
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +0 -1
- package/dist/ui/alert.d.ts +1 -2
- package/dist/ui/alert.d.ts.map +1 -1
- package/dist/ui/alert.js +1 -27
- package/dist/ui/alert.js.map +1 -1
- package/dist/ui/banner.d.ts +3 -5
- package/dist/ui/banner.d.ts.map +1 -1
- package/dist/ui/banner.js +13 -13
- package/dist/ui/banner.js.map +1 -1
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui/index.js +2 -2
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/input.d.ts +1 -9
- package/dist/ui/input.d.ts.map +1 -1
- package/dist/ui/input.js +26 -27
- package/dist/ui/input.js.map +1 -1
- package/dist/ui/segmented-control.d.ts +1 -1
- package/dist/ui/segmented-control.d.ts.map +1 -1
- package/dist/ui/segmented-control.js +2 -4
- package/dist/ui/segmented-control.js.map +1 -1
- package/docs/components/_header.md +1 -1
- package/docs/components/ui/alert.md +4 -1
- package/docs/components/ui/banner.md +3 -1
- package/docs/components/ui/input.md +4 -2
- package/docs/components/ui/segmented-control.md +13 -6
- package/docs/recipes/customize-brand.md +216 -0
- package/docs/recipes/index.md +51 -0
- package/docs/recipes/install-astro.md +178 -0
- package/docs/recipes/install-next-app-router.md +230 -0
- package/docs/recipes/install-next-pages.md +123 -0
- package/docs/recipes/install-remix.md +171 -0
- package/docs/recipes/install-tanstack-start.md +143 -0
- package/docs/recipes/install-vite.md +170 -0
- package/docs/recipes/server-components.md +209 -0
- package/docs/recipes/troubleshoot.md +217 -0
- package/llms-full.txt +26 -53
- package/llms.txt +33 -16
- package/package.json +45 -35
- package/dist/composed/responsive-overlay.d.ts +0 -23
- package/dist/composed/responsive-overlay.d.ts.map +0 -1
- package/dist/composed/responsive-overlay.js +0 -40
- package/dist/composed/responsive-overlay.js.map +0 -1
- package/dist/hooks/use-toast.d.ts +0 -17
- package/dist/hooks/use-toast.d.ts.map +0 -1
- package/dist/hooks/use-toast.js +0 -3
- package/dist/tailwind/index.cjs +0 -41
- package/dist/tailwind/index.d.ts +0 -2
- package/dist/tailwind/index.d.ts.map +0 -1
- package/dist/tailwind/index.js +0 -2
- package/dist/tailwind/preset.d.ts +0 -25
- package/dist/tailwind/preset.d.ts.map +0 -1
- package/dist/tailwind/preset.js +0 -17
- package/dist/tailwind/preset.js.map +0 -1
- package/docs/components/composed/responsive-overlay.md +0 -41
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# Install: Astro
|
|
2
|
+
|
|
3
|
+
> Setup recipe for adding `@devalok/shilp-sutra` to an Astro project with React islands.
|
|
4
|
+
|
|
5
|
+
## 1. Detect
|
|
6
|
+
|
|
7
|
+
You are in this recipe if:
|
|
8
|
+
|
|
9
|
+
- `astro.config.{ts,mjs,js}` exists at the project root
|
|
10
|
+
- `package.json` lists `"astro"`
|
|
11
|
+
- React is integrated via `@astrojs/react`
|
|
12
|
+
|
|
13
|
+
If `@astrojs/react` is not installed, install it first:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm astro add react
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 2. Install dependencies
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm add @devalok/shilp-sutra framer-motion
|
|
23
|
+
pnpm add -D tailwindcss@^4 @tailwindcss/vite
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Add only if rendering `<Toaster />`:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pnpm add sonner
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 3. Wire Tailwind 4 in `astro.config`
|
|
33
|
+
|
|
34
|
+
Astro has its own `@astrojs/tailwind` integration, but for Tailwind 4 use the Vite plugin directly (Astro 4.5+ supports this):
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
// astro.config.ts
|
|
38
|
+
import { defineConfig } from "astro/config";
|
|
39
|
+
import react from "@astrojs/react";
|
|
40
|
+
import tailwindcss from "@tailwindcss/vite";
|
|
41
|
+
|
|
42
|
+
export default defineConfig({
|
|
43
|
+
integrations: [react()],
|
|
44
|
+
vite: {
|
|
45
|
+
plugins: [tailwindcss()],
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Do **not** also enable `@astrojs/tailwind` — that integration is Tailwind 3 only and will conflict.
|
|
51
|
+
|
|
52
|
+
## 4. Wire tokens
|
|
53
|
+
|
|
54
|
+
Create `src/styles/globals.css`:
|
|
55
|
+
|
|
56
|
+
```css
|
|
57
|
+
@import "tailwindcss";
|
|
58
|
+
@import "@devalok/shilp-sutra/css";
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Import it from a layout component (e.g., `src/layouts/BaseLayout.astro`):
|
|
62
|
+
|
|
63
|
+
```astro
|
|
64
|
+
---
|
|
65
|
+
import "../styles/globals.css";
|
|
66
|
+
const { title = "App" } = Astro.props;
|
|
67
|
+
---
|
|
68
|
+
<!doctype html>
|
|
69
|
+
<html lang="en" class="">
|
|
70
|
+
<head>
|
|
71
|
+
<meta charset="utf-8" />
|
|
72
|
+
<meta name="viewport" content="width=device-width" />
|
|
73
|
+
<title>{title}</title>
|
|
74
|
+
</head>
|
|
75
|
+
<body>
|
|
76
|
+
<slot />
|
|
77
|
+
</body>
|
|
78
|
+
</html>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## 5. Theme toggle
|
|
82
|
+
|
|
83
|
+
Add the bootstrap script to `<head>` of `BaseLayout.astro` (before stylesheet imports):
|
|
84
|
+
|
|
85
|
+
```astro
|
|
86
|
+
---
|
|
87
|
+
import "../styles/globals.css";
|
|
88
|
+
---
|
|
89
|
+
<!doctype html>
|
|
90
|
+
<html lang="en">
|
|
91
|
+
<head>
|
|
92
|
+
<script is:inline>
|
|
93
|
+
try {
|
|
94
|
+
var stored = localStorage.getItem("theme");
|
|
95
|
+
var prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
96
|
+
if (stored === "dark" || (!stored && prefersDark))
|
|
97
|
+
document.documentElement.classList.add("dark");
|
|
98
|
+
} catch (e) {}
|
|
99
|
+
</script>
|
|
100
|
+
<!-- ... -->
|
|
101
|
+
</head>
|
|
102
|
+
<body><slot /></body>
|
|
103
|
+
</html>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
`is:inline` keeps it out of bundling, so it runs before any other JS.
|
|
107
|
+
|
|
108
|
+
For runtime toggling inside React islands, use the same `useColorMode` hook shown in [install-vite.md § 5](./install-vite.md#5-theme-toggle-no-next-themes-here).
|
|
109
|
+
|
|
110
|
+
## 6. Use components in islands
|
|
111
|
+
|
|
112
|
+
Shilp Sutra components are **client-only** (they use React hooks). Mount them in islands with a `client:*` directive:
|
|
113
|
+
|
|
114
|
+
```astro
|
|
115
|
+
---
|
|
116
|
+
import { Button } from "@devalok/shilp-sutra/ui/button";
|
|
117
|
+
---
|
|
118
|
+
<Button client:load>Hello</Button>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Static / non-interactive primitives (Text, Stack, Container, Code, VisuallyHidden) work without `client:*` because they render to static markup. Per-component imports are still required.
|
|
122
|
+
|
|
123
|
+
## 7. Toaster (optional)
|
|
124
|
+
|
|
125
|
+
Mount once in a top-level island. The simplest approach is a small React wrapper component:
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
// src/components/AppToaster.tsx
|
|
129
|
+
"use client";
|
|
130
|
+
import { Toaster } from "@devalok/shilp-sutra/ui/toaster";
|
|
131
|
+
export default function AppToaster() {
|
|
132
|
+
return <Toaster />;
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
```astro
|
|
137
|
+
---
|
|
138
|
+
import AppToaster from "../components/AppToaster";
|
|
139
|
+
---
|
|
140
|
+
<AppToaster client:load />
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## 8. Verify
|
|
144
|
+
|
|
145
|
+
Create `src/pages/index.astro`:
|
|
146
|
+
|
|
147
|
+
```astro
|
|
148
|
+
---
|
|
149
|
+
import BaseLayout from "../layouts/BaseLayout.astro";
|
|
150
|
+
import { Button } from "@devalok/shilp-sutra/ui/button";
|
|
151
|
+
import { Stack } from "@devalok/shilp-sutra/ui/stack";
|
|
152
|
+
import { Text } from "@devalok/shilp-sutra/ui/text";
|
|
153
|
+
---
|
|
154
|
+
<BaseLayout title="Home">
|
|
155
|
+
<Stack className="p-ds-08" gap="ds-04">
|
|
156
|
+
<Text variant="heading-2xl">Hello, Shilp Sutra</Text>
|
|
157
|
+
<Stack direction="row" gap="ds-03">
|
|
158
|
+
<Button client:load>Primary</Button>
|
|
159
|
+
<Button client:load variant="soft">Soft</Button>
|
|
160
|
+
</Stack>
|
|
161
|
+
</Stack>
|
|
162
|
+
</BaseLayout>
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Run `pnpm dev` and open the URL.
|
|
166
|
+
|
|
167
|
+
## 9. Astro-specific gotchas
|
|
168
|
+
|
|
169
|
+
- **No `transpilePackages` equivalent — and you do not need one.** Astro's Vite uses native ESM and resolves `@devalok/shilp-sutra` from `node_modules` directly.
|
|
170
|
+
- **Component must be inside a `client:*` island to be interactive.** A button without `client:load` will render but not respond to clicks.
|
|
171
|
+
- **Server-side islands (`server:defer`)** — fine, but RSC import rules apply (per-component imports only). See [server-components.md](./server-components.md).
|
|
172
|
+
- **`@astrojs/tailwind` and `@tailwindcss/vite` conflict.** Pick one. For Tailwind 4 use the Vite plugin.
|
|
173
|
+
|
|
174
|
+
## 10. What NOT to do
|
|
175
|
+
|
|
176
|
+
- ❌ Use `@astrojs/tailwind` (Tailwind 3 only).
|
|
177
|
+
- ❌ Add `tailwind.config.{ts,js}` — Tailwind 4 is CSS-first.
|
|
178
|
+
- ❌ Import shilp-sutra components into a `.astro` file expecting interactivity without `client:*`.
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
# Install: Next.js (App Router)
|
|
2
|
+
|
|
3
|
+
> Setup recipe for adding `@devalok/shilp-sutra` to a Next.js 13+ App Router project.
|
|
4
|
+
|
|
5
|
+
## 1. Detect the framework
|
|
6
|
+
|
|
7
|
+
You are in this recipe if **all** of these are true:
|
|
8
|
+
|
|
9
|
+
- `package.json` lists `"next"` at version `^13.0.0` or higher
|
|
10
|
+
- An `app/` directory exists at the project root or under `src/`
|
|
11
|
+
- An `app/layout.tsx` (or `.jsx`) file exists
|
|
12
|
+
- No `pages/` directory at the project root, OR `pages/` exists but only contains `_app.{js,tsx}` and `_document.{js,tsx}` (legacy artifacts)
|
|
13
|
+
|
|
14
|
+
If `pages/` is the primary router, use [install-next-pages.md](./install-next-pages.md).
|
|
15
|
+
|
|
16
|
+
## 2. Install dependencies
|
|
17
|
+
|
|
18
|
+
Pick the package manager that matches the project's lockfile.
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# pnpm (lockfile: pnpm-lock.yaml)
|
|
22
|
+
pnpm add @devalok/shilp-sutra framer-motion next-themes
|
|
23
|
+
pnpm add -D tailwindcss@^4 @tailwindcss/postcss
|
|
24
|
+
|
|
25
|
+
# npm (lockfile: package-lock.json)
|
|
26
|
+
npm install @devalok/shilp-sutra framer-motion next-themes
|
|
27
|
+
npm install -D tailwindcss@^4 @tailwindcss/postcss
|
|
28
|
+
|
|
29
|
+
# yarn (lockfile: yarn.lock)
|
|
30
|
+
yarn add @devalok/shilp-sutra framer-motion next-themes
|
|
31
|
+
yarn add -D tailwindcss@^4 @tailwindcss/postcss
|
|
32
|
+
|
|
33
|
+
# bun (lockfile: bun.lockb)
|
|
34
|
+
bun add @devalok/shilp-sutra framer-motion next-themes
|
|
35
|
+
bun add -d tailwindcss@^4 @tailwindcss/postcss
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Add only if you will render `<Toaster />`:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pnpm add sonner
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Add brand assets package if you need Devalok or Karm logos:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pnpm add @devalok/shilp-sutra-brand
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## 3. Configure PostCSS
|
|
51
|
+
|
|
52
|
+
Create or update `postcss.config.mjs` at the project root:
|
|
53
|
+
|
|
54
|
+
```js
|
|
55
|
+
export default {
|
|
56
|
+
plugins: {
|
|
57
|
+
"@tailwindcss/postcss": {},
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
If a `postcss.config.{js,cjs,json}` already exists, merge the plugin in. Do not delete the existing file.
|
|
63
|
+
|
|
64
|
+
## 4. Wire Tailwind 4 + design tokens
|
|
65
|
+
|
|
66
|
+
Locate the global CSS file. Common paths in priority order:
|
|
67
|
+
|
|
68
|
+
- `app/globals.css`
|
|
69
|
+
- `src/app/globals.css`
|
|
70
|
+
- `app/global.css`
|
|
71
|
+
|
|
72
|
+
If none exists, create `app/globals.css`. Set the file contents to (or merge into):
|
|
73
|
+
|
|
74
|
+
```css
|
|
75
|
+
@import "tailwindcss";
|
|
76
|
+
@import "@devalok/shilp-sutra/css";
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
**Order matters.** `tailwindcss` MUST come first. The shilp-sutra `/css` entry registers `@theme` blocks that the Tailwind import must process.
|
|
80
|
+
|
|
81
|
+
If the project has its own theme overrides, place them AFTER both imports:
|
|
82
|
+
|
|
83
|
+
```css
|
|
84
|
+
@import "tailwindcss";
|
|
85
|
+
@import "@devalok/shilp-sutra/css";
|
|
86
|
+
|
|
87
|
+
@theme {
|
|
88
|
+
--color-brand: oklch(0.65 0.2 280);
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Import the CSS file once from `app/layout.tsx` (it should already be imported in a fresh `create-next-app` project):
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
import "./globals.css";
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## 5. Configure `transpilePackages`
|
|
99
|
+
|
|
100
|
+
Edit `next.config.{ts,js,mjs}`. Add the `transpilePackages` field:
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
import type { NextConfig } from "next";
|
|
104
|
+
|
|
105
|
+
const nextConfig: NextConfig = {
|
|
106
|
+
transpilePackages: ["@devalok/shilp-sutra", "@devalok/shilp-sutra-brand"],
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export default nextConfig;
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
If a `transpilePackages` array already exists, append to it. Do not replace.
|
|
113
|
+
|
|
114
|
+
Without `transpilePackages`, Next will refuse to load our pre-built `dist/*.js` because it ships native ESM that does not match Next's CJS-leaning loader for `node_modules`.
|
|
115
|
+
|
|
116
|
+
## 6. Scaffold the Providers wrapper
|
|
117
|
+
|
|
118
|
+
Create `app/providers.tsx`:
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
"use client";
|
|
122
|
+
|
|
123
|
+
import type { ReactNode } from "react";
|
|
124
|
+
import { ThemeProvider } from "next-themes";
|
|
125
|
+
import { Toaster } from "@devalok/shilp-sutra/ui/toaster";
|
|
126
|
+
|
|
127
|
+
export function Providers({ children }: { children: ReactNode }) {
|
|
128
|
+
return (
|
|
129
|
+
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
|
|
130
|
+
{children}
|
|
131
|
+
<Toaster />
|
|
132
|
+
</ThemeProvider>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
`next-themes` is already in the install list from § 2 — no extra install step needed here. If `<Toaster />` is not used:
|
|
138
|
+
|
|
139
|
+
- Drop the `Toaster` import and its JSX usage
|
|
140
|
+
- Skip installing `sonner`
|
|
141
|
+
|
|
142
|
+
Mount `<Providers>` from `app/layout.tsx`:
|
|
143
|
+
|
|
144
|
+
```tsx
|
|
145
|
+
import "./globals.css";
|
|
146
|
+
import { Providers } from "./providers";
|
|
147
|
+
|
|
148
|
+
export default function RootLayout({ children }: { children: React.ReactNode }) {
|
|
149
|
+
return (
|
|
150
|
+
<html lang="en" suppressHydrationWarning>
|
|
151
|
+
<body>
|
|
152
|
+
<Providers>{children}</Providers>
|
|
153
|
+
</body>
|
|
154
|
+
</html>
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
`suppressHydrationWarning` on `<html>` is required because `next-themes` writes the `class` attribute before React hydrates. Without it, every page logs a hydration warning.
|
|
160
|
+
|
|
161
|
+
## 7. Verify the install
|
|
162
|
+
|
|
163
|
+
Replace the contents of `app/page.tsx`:
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
import { Button } from "@devalok/shilp-sutra/ui/button";
|
|
167
|
+
import { Stack } from "@devalok/shilp-sutra/ui/stack";
|
|
168
|
+
import { Text } from "@devalok/shilp-sutra/ui/text";
|
|
169
|
+
|
|
170
|
+
export default function Home() {
|
|
171
|
+
return (
|
|
172
|
+
<Stack className="p-ds-08" gap="ds-04">
|
|
173
|
+
<Text variant="heading-2xl">Hello, Shilp Sutra</Text>
|
|
174
|
+
<Stack direction="row" gap="ds-03">
|
|
175
|
+
<Button>Primary</Button>
|
|
176
|
+
<Button variant="soft">Soft</Button>
|
|
177
|
+
<Button variant="outline">Outline</Button>
|
|
178
|
+
</Stack>
|
|
179
|
+
</Stack>
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Run the dev server:
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
pnpm dev
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Open `http://localhost:3000`. You should see:
|
|
191
|
+
|
|
192
|
+
- The heading rendered in **Ranade** (display font), the buttons in **Inter** (body font)
|
|
193
|
+
- The primary button on a saturated accent background, the soft button with a tinted background and no border, the outline button with a border and transparent background
|
|
194
|
+
- No hydration warning in the browser console
|
|
195
|
+
- No 404 for fonts (fonts are bundled inside the package; `next/font` is not required)
|
|
196
|
+
|
|
197
|
+
If anything is off, see [troubleshoot.md](./troubleshoot.md).
|
|
198
|
+
|
|
199
|
+
## 8. Common gotchas
|
|
200
|
+
|
|
201
|
+
- **CSS import order.** `tailwindcss` BEFORE `@devalok/shilp-sutra/css`. Reversing the order silently produces a build with no design-system utilities.
|
|
202
|
+
- **Multiple `framer-motion` copies.** Run `pnpm why framer-motion`. If it shows more than one resolved version, contexts (`MotionConfig`, `LayoutGroup`, `AnimatePresence`) silently break. Fix:
|
|
203
|
+
```jsonc
|
|
204
|
+
// package.json
|
|
205
|
+
{
|
|
206
|
+
"pnpm": {
|
|
207
|
+
"overrides": {
|
|
208
|
+
"framer-motion": "^12"
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
For npm/yarn/bun equivalents, see [troubleshoot.md](./troubleshoot.md).
|
|
214
|
+
- **Server Component imports.** Use per-component imports (`@devalok/shilp-sutra/ui/text`) inside Server Components. The barrel import `@devalok/shilp-sutra/ui` pulls client-only code and breaks RSC. See [server-components.md](./server-components.md).
|
|
215
|
+
- **`p-3` vs `p-ds-03`.** Our spacing namespace is `--spacing-ds-*` to avoid collision with consumer numeric spacing. Use `p-ds-04`, not `p-4`.
|
|
216
|
+
- **Bare `shadow` is dead.** Tailwind 4 has no `--shadow-DEFAULT`. Use `shadow-raised`, `shadow-overlay`, or `shadow-floating`.
|
|
217
|
+
|
|
218
|
+
## 9. What you should NOT do
|
|
219
|
+
|
|
220
|
+
- ❌ Create `tailwind.config.ts` with `presets: [shilpSutra]` — the JS preset was removed in 0.38.
|
|
221
|
+
- ❌ Add `@plugin "@devalok/shilp-sutra/tailwind"` — also removed.
|
|
222
|
+
- ❌ Wrap the whole app in `<MotionConfig reducedMotion="...">` unless the user explicitly asks for a global motion override; Shilp Sutra components already respect `prefers-reduced-motion`.
|
|
223
|
+
- ❌ Import from `@devalok/shilp-sutra/tailwind` — the export was removed in 0.38.
|
|
224
|
+
- ❌ Run `pnpm add @radix-ui/react-*` — Radix is vendored; no @radix-ui runtime deps are required.
|
|
225
|
+
|
|
226
|
+
## 10. Optional next steps
|
|
227
|
+
|
|
228
|
+
- **Brand customization** — swap accent color, radius scale, or fonts: see [customize-brand.md](./customize-brand.md).
|
|
229
|
+
- **App shell** — add a sidebar + topbar layout: read `llms-full.txt` sections for `AppSidebar` and `TopBar`.
|
|
230
|
+
- **Server-safe components** — push as much rendering as possible into Server Components: see [server-components.md](./server-components.md).
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Install: Next.js (Pages Router)
|
|
2
|
+
|
|
3
|
+
> Setup recipe for adding `@devalok/shilp-sutra` to a Next.js project that uses the Pages Router (`pages/_app.tsx` as the entry).
|
|
4
|
+
|
|
5
|
+
## 1. Detect
|
|
6
|
+
|
|
7
|
+
You are in this recipe if:
|
|
8
|
+
|
|
9
|
+
- `package.json` lists `"next"` (any version `>= 12`)
|
|
10
|
+
- A `pages/` directory exists at the project root or under `src/` and contains `_app.{js,tsx}` (and optionally `_document.{js,tsx}`)
|
|
11
|
+
- `app/` directory does NOT exist, OR exists but is unused
|
|
12
|
+
|
|
13
|
+
If both `app/` and `pages/` exist, prefer [install-next-app-router.md](./install-next-app-router.md) and treat the Pages Router as legacy.
|
|
14
|
+
|
|
15
|
+
## 2. Install
|
|
16
|
+
|
|
17
|
+
Same dependencies as the App Router recipe — see [install-next-app-router.md § 2](./install-next-app-router.md#2-install-dependencies). Replace `next-themes`'s `attribute="class"` setup with the same on Pages Router (it works identically).
|
|
18
|
+
|
|
19
|
+
## 3. PostCSS
|
|
20
|
+
|
|
21
|
+
Same as App Router — see [§ 3](./install-next-app-router.md#3-configure-postcss).
|
|
22
|
+
|
|
23
|
+
## 4. Wire Tailwind 4 + tokens
|
|
24
|
+
|
|
25
|
+
Common CSS entry paths in priority order:
|
|
26
|
+
|
|
27
|
+
- `styles/globals.css`
|
|
28
|
+
- `src/styles/globals.css`
|
|
29
|
+
- `pages/_app.css` (rare)
|
|
30
|
+
|
|
31
|
+
If none exists, create `styles/globals.css` with:
|
|
32
|
+
|
|
33
|
+
```css
|
|
34
|
+
@import "tailwindcss";
|
|
35
|
+
@import "@devalok/shilp-sutra/css";
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Import it from `pages/_app.tsx`:
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
import "../styles/globals.css";
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## 5. `transpilePackages`
|
|
45
|
+
|
|
46
|
+
Identical to App Router — see [§ 5](./install-next-app-router.md#5-configure-transpilepackages).
|
|
47
|
+
|
|
48
|
+
## 6. Providers in `_app.tsx`
|
|
49
|
+
|
|
50
|
+
Replace or merge into `pages/_app.tsx`:
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
import "../styles/globals.css";
|
|
54
|
+
import type { AppProps } from "next/app";
|
|
55
|
+
import { ThemeProvider } from "next-themes";
|
|
56
|
+
import { Toaster } from "@devalok/shilp-sutra/ui/toaster";
|
|
57
|
+
|
|
58
|
+
export default function App({ Component, pageProps }: AppProps) {
|
|
59
|
+
return (
|
|
60
|
+
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
|
|
61
|
+
<Component {...pageProps} />
|
|
62
|
+
<Toaster />
|
|
63
|
+
</ThemeProvider>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
For `next-themes` to avoid hydration warnings, add a `_document.tsx` with `suppressHydrationWarning` on the `<html>`:
|
|
69
|
+
|
|
70
|
+
```tsx
|
|
71
|
+
// pages/_document.tsx
|
|
72
|
+
import { Html, Head, Main, NextScript } from "next/document";
|
|
73
|
+
|
|
74
|
+
export default function Document() {
|
|
75
|
+
return (
|
|
76
|
+
<Html lang="en" suppressHydrationWarning>
|
|
77
|
+
<Head />
|
|
78
|
+
<body>
|
|
79
|
+
<Main />
|
|
80
|
+
<NextScript />
|
|
81
|
+
</body>
|
|
82
|
+
</Html>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## 7. Verify
|
|
88
|
+
|
|
89
|
+
Replace `pages/index.tsx`:
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
import { Button } from "@devalok/shilp-sutra/ui/button";
|
|
93
|
+
import { Stack } from "@devalok/shilp-sutra/ui/stack";
|
|
94
|
+
import { Text } from "@devalok/shilp-sutra/ui/text";
|
|
95
|
+
|
|
96
|
+
export default function Home() {
|
|
97
|
+
return (
|
|
98
|
+
<Stack className="p-ds-08" gap="ds-04">
|
|
99
|
+
<Text variant="heading-2xl">Hello, Shilp Sutra</Text>
|
|
100
|
+
<Stack direction="row" gap="ds-03">
|
|
101
|
+
<Button>Primary</Button>
|
|
102
|
+
<Button variant="soft">Soft</Button>
|
|
103
|
+
</Stack>
|
|
104
|
+
</Stack>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Run `pnpm dev` and open `http://localhost:3000`. Expected output is the same as the App Router recipe — see [§ 7](./install-next-app-router.md#7-verify-the-install).
|
|
110
|
+
|
|
111
|
+
## 8. Pages Router specifics
|
|
112
|
+
|
|
113
|
+
- **No React Server Components.** Every component runs on the client. Per-component imports still help tree-shaking but are not required for RSC safety.
|
|
114
|
+
- **`getServerSideProps` / `getStaticProps`** — do not import shilp-sutra components inside these (they run server-side and won't render JSX). Components are imported and used in the page module's default export, as usual.
|
|
115
|
+
- **`pages/_document.tsx` runs server-only.** Do not import shilp-sutra components there.
|
|
116
|
+
|
|
117
|
+
## 9. Gotchas
|
|
118
|
+
|
|
119
|
+
Same as App Router — see [§ 8](./install-next-app-router.md#8-common-gotchas).
|
|
120
|
+
|
|
121
|
+
## 10. What NOT to do
|
|
122
|
+
|
|
123
|
+
Same as App Router — see [§ 9](./install-next-app-router.md#9-what-you-should-not-do).
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# Install: Remix
|
|
2
|
+
|
|
3
|
+
> Setup recipe for adding `@devalok/shilp-sutra` to a Remix project (v2 with Vite).
|
|
4
|
+
|
|
5
|
+
## 1. Detect
|
|
6
|
+
|
|
7
|
+
You are in this recipe if:
|
|
8
|
+
|
|
9
|
+
- `package.json` lists `"@remix-run/node"` and `"@remix-run/react"`
|
|
10
|
+
- `vite.config.{ts,js}` exists with the `vitePlugin` from `@remix-run/dev`
|
|
11
|
+
- `app/root.tsx` exists with `<Outlet />` inside `<Document>` shell
|
|
12
|
+
|
|
13
|
+
For React Router v7 (the spiritual successor to Remix), use the [install-vite.md](./install-vite.md) recipe — it works the same way.
|
|
14
|
+
|
|
15
|
+
## 2. Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add @devalok/shilp-sutra framer-motion
|
|
19
|
+
pnpm add -D tailwindcss@^4 @tailwindcss/vite
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Optional:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpm add sonner # only if rendering <Toaster />
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## 3. Wire Tailwind 4 in `vite.config.ts`
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { vitePlugin as remix } from "@remix-run/dev";
|
|
32
|
+
import tailwindcss from "@tailwindcss/vite";
|
|
33
|
+
import { defineConfig } from "vite";
|
|
34
|
+
|
|
35
|
+
export default defineConfig({
|
|
36
|
+
plugins: [
|
|
37
|
+
tailwindcss(),
|
|
38
|
+
remix(),
|
|
39
|
+
],
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`tailwindcss()` should come before `remix()` so the design tokens are processed first.
|
|
44
|
+
|
|
45
|
+
## 4. Wire tokens
|
|
46
|
+
|
|
47
|
+
Create `app/styles/globals.css`:
|
|
48
|
+
|
|
49
|
+
```css
|
|
50
|
+
@import "tailwindcss";
|
|
51
|
+
@import "@devalok/shilp-sutra/css";
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Wire it as a Remix link export from `app/root.tsx`:
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
import type { LinksFunction } from "@remix-run/node";
|
|
58
|
+
import globalsCss from "./styles/globals.css?url";
|
|
59
|
+
|
|
60
|
+
export const links: LinksFunction = () => [
|
|
61
|
+
{ rel: "stylesheet", href: globalsCss },
|
|
62
|
+
];
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The `?url` suffix is critical — it tells Vite to emit the file as an asset URL instead of inlining the CSS contents.
|
|
66
|
+
|
|
67
|
+
## 5. Theme toggle
|
|
68
|
+
|
|
69
|
+
Create `public/theme-bootstrap.js` (a static asset served verbatim):
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
(function () {
|
|
73
|
+
try {
|
|
74
|
+
var stored = localStorage.getItem("theme");
|
|
75
|
+
var prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
76
|
+
if (stored === "dark" || (!stored && prefersDark)) {
|
|
77
|
+
document.documentElement.classList.add("dark");
|
|
78
|
+
}
|
|
79
|
+
} catch (e) {}
|
|
80
|
+
})();
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Reference it from `app/root.tsx` so it loads before any React hydration:
|
|
84
|
+
|
|
85
|
+
```tsx
|
|
86
|
+
import { Outlet, Meta, Links, Scripts, ScrollRestoration } from "@remix-run/react";
|
|
87
|
+
|
|
88
|
+
export default function App() {
|
|
89
|
+
return (
|
|
90
|
+
<html lang="en" suppressHydrationWarning>
|
|
91
|
+
<head>
|
|
92
|
+
<Meta />
|
|
93
|
+
<Links />
|
|
94
|
+
<script src="/theme-bootstrap.js" />
|
|
95
|
+
</head>
|
|
96
|
+
<body>
|
|
97
|
+
<Outlet />
|
|
98
|
+
<ScrollRestoration />
|
|
99
|
+
<Scripts />
|
|
100
|
+
</body>
|
|
101
|
+
</html>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
For runtime toggling inside React components, use `useColorMode`:
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
import { useColorMode } from "@devalok/shilp-sutra/hooks/use-color-mode";
|
|
110
|
+
|
|
111
|
+
export function ThemeToggle() {
|
|
112
|
+
const { mode, toggle } = useColorMode();
|
|
113
|
+
return (
|
|
114
|
+
<button onClick={toggle} aria-label="Toggle theme">
|
|
115
|
+
{mode === "dark" ? "☀" : "☾"}
|
|
116
|
+
</button>
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## 6. Toaster (optional)
|
|
122
|
+
|
|
123
|
+
Mount once in `app/root.tsx` next to `<Outlet />`:
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
import { Toaster } from "@devalok/shilp-sutra/ui/toaster";
|
|
127
|
+
|
|
128
|
+
// inside <body>
|
|
129
|
+
<>
|
|
130
|
+
<Outlet />
|
|
131
|
+
<Toaster />
|
|
132
|
+
</>
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## 7. Verify
|
|
136
|
+
|
|
137
|
+
Create `app/routes/_index.tsx`:
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
import { Button } from "@devalok/shilp-sutra/ui/button";
|
|
141
|
+
import { Stack } from "@devalok/shilp-sutra/ui/stack";
|
|
142
|
+
import { Text } from "@devalok/shilp-sutra/ui/text";
|
|
143
|
+
|
|
144
|
+
export default function Index() {
|
|
145
|
+
return (
|
|
146
|
+
<Stack className="p-ds-08" gap="ds-04">
|
|
147
|
+
<Text variant="heading-2xl">Hello, Shilp Sutra</Text>
|
|
148
|
+
<Stack direction="row" gap="ds-03">
|
|
149
|
+
<Button>Primary</Button>
|
|
150
|
+
<Button variant="soft">Soft</Button>
|
|
151
|
+
</Stack>
|
|
152
|
+
</Stack>
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
Run `pnpm dev` and open the URL.
|
|
158
|
+
|
|
159
|
+
## 8. Remix-specific gotchas
|
|
160
|
+
|
|
161
|
+
- **`?url` suffix on CSS imports.** Without it, Vite tries to inline the CSS, which breaks Tailwind processing.
|
|
162
|
+
- **Loaders are server-only.** Do not import shilp-sutra components inside a `loader` function — they will not render.
|
|
163
|
+
- **Server-rendered output.** Remix SSRs every route. The CSS-in-JS-free approach of shilp-sutra works perfectly here; no extra config needed.
|
|
164
|
+
- **`framer-motion` and SSR.** All shilp-sutra animations gracefully degrade for the initial server render. No special handling required.
|
|
165
|
+
- **CSP.** If your CSP blocks inline scripts, the `theme-bootstrap.js` static asset above already complies (no `unsafe-inline` needed).
|
|
166
|
+
|
|
167
|
+
## 9. What NOT to do
|
|
168
|
+
|
|
169
|
+
- ❌ Add `tailwind.config.{ts,js}` — Tailwind 4 is CSS-first.
|
|
170
|
+
- ❌ Skip the `?url` suffix on CSS imports.
|
|
171
|
+
- ❌ Mount `<Toaster />` inside route components — it should live once at the root.
|