@designtools/codesurface 0.1.1

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.
Files changed (36) hide show
  1. package/README.md +105 -0
  2. package/dist/cli.js +3360 -0
  3. package/dist/client/assets/index-B5g8qgFW.css +1 -0
  4. package/dist/client/assets/index-BB9cuIlF.js +111 -0
  5. package/dist/client/assets/index-BH-ji2K7.js +150 -0
  6. package/dist/client/assets/index-BH4MtIeE.js +150 -0
  7. package/dist/client/assets/index-BRJOTqhn.js +130 -0
  8. package/dist/client/assets/index-Bb8QmYLf.css +1 -0
  9. package/dist/client/assets/index-BdWkGSfZ.js +130 -0
  10. package/dist/client/assets/index-BnRqJ-Bb.js +150 -0
  11. package/dist/client/assets/index-BneJISnX.js +150 -0
  12. package/dist/client/assets/index-C9_QxP1g.css +1 -0
  13. package/dist/client/assets/index-CBjuhHfq.js +150 -0
  14. package/dist/client/assets/index-CEFmdeB7.css +1 -0
  15. package/dist/client/assets/index-CQpCDasO.js +131 -0
  16. package/dist/client/assets/index-CRUCeIYi.css +1 -0
  17. package/dist/client/assets/index-CUSGVUIj.js +150 -0
  18. package/dist/client/assets/index-CdshIoQY.css +1 -0
  19. package/dist/client/assets/index-Cne4pc0S.css +1 -0
  20. package/dist/client/assets/index-Cps9lJoI.css +1 -0
  21. package/dist/client/assets/index-Cs7mKzsY.css +1 -0
  22. package/dist/client/assets/index-D11nArXR.css +1 -0
  23. package/dist/client/assets/index-D2DhQd-K.js +51 -0
  24. package/dist/client/assets/index-DG2JRz0f.js +150 -0
  25. package/dist/client/assets/index-DO-UYUx0.js +150 -0
  26. package/dist/client/assets/index-DOb58Ii1.js +111 -0
  27. package/dist/client/assets/index-DVd7DS_W.css +1 -0
  28. package/dist/client/assets/index-DZNHUm4M.js +130 -0
  29. package/dist/client/assets/index-Di7zgczR.css +1 -0
  30. package/dist/client/assets/index-DlUCyHdA.css +1 -0
  31. package/dist/client/assets/index-FTflg87d.js +130 -0
  32. package/dist/client/assets/index-U5_kmGxX.js +150 -0
  33. package/dist/client/assets/index-_4EXPfyt.css +1 -0
  34. package/dist/client/assets/index-gow3pju2.css +1 -0
  35. package/dist/client/index.html +13 -0
  36. package/package.json +50 -0
package/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # @designtools/codesurface
2
+
3
+ A CLI-launched visual design layer for React applications. Select elements in your running app and edit styles, tokens, and component variants — changes write back to your source files.
4
+
5
+ ## Requirements
6
+
7
+ - Node.js >= 18
8
+ - **Next.js** >= 14 (only supported framework currently)
9
+ - **React** >= 18
10
+ - **Tailwind CSS** v3 or v4 (only supported styling system for class writes)
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install -D @designtools/codesurface @designtools/next-plugin
16
+ ```
17
+
18
+ ## Setup
19
+
20
+ ### 1. Wrap your Next.js config
21
+
22
+ ```ts
23
+ // next.config.ts
24
+ import { withDesigntools } from "@designtools/next-plugin";
25
+
26
+ const nextConfig = {
27
+ // your existing config
28
+ };
29
+
30
+ export default withDesigntools(nextConfig);
31
+ ```
32
+
33
+ This does two things in development (at compile time only — your source files are not modified):
34
+
35
+ - Injects `data-source` attributes into every JSX element at build time, mapping each element to its source file, line, and column. These only exist in the compiled output.
36
+ - Auto-mounts the `<CodeSurface />` selection overlay component in your root layout.
37
+
38
+ Neither is included in production builds.
39
+
40
+ ### 2. Add `data-slot` to your components
41
+
42
+ For CodeSurface to recognize reusable components (and distinguish them from plain HTML elements), add a `data-slot` attribute to the root element of each component:
43
+
44
+ ```tsx
45
+ // components/ui/button.tsx
46
+ export function Button({ children, className, ...props }) {
47
+ return (
48
+ <button data-slot="button" className={cn("...", className)} {...props}>
49
+ {children}
50
+ </button>
51
+ );
52
+ }
53
+ ```
54
+
55
+ The `data-slot` value should be a kebab-case name matching the component (e.g. `card-title` for `CardTitle`). This enables component-level editing — selecting a Button in the editor will let you modify its base styles in the component file, not just the instance.
56
+
57
+ Components without `data-slot` can still be selected and edited at the element level.
58
+
59
+ ### 3. Run it
60
+
61
+ Start your Next.js dev server, then start CodeSurface from your project root:
62
+
63
+ ```bash
64
+ # Terminal 1
65
+ npm run dev
66
+
67
+ # Terminal 2
68
+ npx codesurface
69
+ ```
70
+
71
+ The editor opens at `http://localhost:4400`. Your app loads inside an iframe — no proxy, no middleware.
72
+
73
+ ### CLI options
74
+
75
+ | Flag | Default | Description |
76
+ |------|---------|-------------|
77
+ | `--port` | `3000` | Port your dev server runs on |
78
+ | `--tool-port` | `4400` | Port for the editor UI |
79
+
80
+ ## How it works
81
+
82
+ 1. Click an element in the iframe to select it
83
+ 2. The editor panel shows its computed styles and Tailwind classes
84
+ 3. Edit values — changes are written directly to your source files as Tailwind utility classes
85
+ 4. Your dev server picks up the file change and hot-reloads
86
+
87
+ Changes are written as Tailwind classes (e.g. `text-sm`, `bg-blue-500`). When no matching utility exists, arbitrary value syntax is used (e.g. `text-[14px]`).
88
+
89
+ ## What it can edit
90
+
91
+ - **Element styles** — layout, spacing, typography, colors, borders, shadows, opacity
92
+ - **Design tokens** — CSS custom properties in your stylesheets
93
+ - **Component variants** — base classes and variant mappings (works with CVA)
94
+ - **Box shadows** — shadow token definitions in CSS or `@theme` blocks
95
+
96
+ ## Limitations
97
+
98
+ - **Next.js only** — framework detection exists for Remix and Vite but they are untested
99
+ - **Tailwind only for class writes** — CSS variable and plain CSS token editing works, but className writes produce Tailwind utility classes
100
+ - **Development only** — the plugin and overlays are stripped from production builds
101
+ - **App Router** — the auto-mount targets `app/layout.tsx` (or `src/app/layout.tsx`). Pages Router is not supported for auto-mounting
102
+
103
+ ## License
104
+
105
+ CC-BY-NC-4.0