@toriistudio/v0-playground 0.1.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/LICENSE.md +21 -0
- package/README.md +79 -0
- package/dist/index.d.mts +45 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +631 -0
- package/dist/index.mjs +606 -0
- package/dist/preset.d.mts +5 -0
- package/dist/preset.d.ts +5 -0
- package/dist/preset.js +219 -0
- package/dist/preset.mjs +186 -0
- package/package.json +89 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Origin UI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# ✨ V0 Playground ✨
|
|
2
|
+
|
|
3
|
+
A lightweight, interactive playground for rapidly testing and showcasing your React components with built-in Tailwind CSS support and live prop controls.
|
|
4
|
+
|
|
5
|
+
Perfect for prototyping components, sharing usage examples, or building your own version of tools like [v0.dev](https://v0.dev).
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## ✅ Features
|
|
10
|
+
|
|
11
|
+
- ⚡️ Minimal setup, works out of the box with Tailwind
|
|
12
|
+
- 🎛️ Live-editable props using `useControls`
|
|
13
|
+
- 🧩 Fully typed, headless playground architecture
|
|
14
|
+
- 🌓 Dark mode compatible
|
|
15
|
+
- 🛠️ Easily themeable with Tailwind and tokens
|
|
16
|
+
- 🧪 Great for testing component variants in isolation
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## 🚀 Installation
|
|
21
|
+
|
|
22
|
+
Install the package and its peer dependencies:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install @toriistudio/v0-playground
|
|
26
|
+
# or
|
|
27
|
+
yarn add @toriistudio/v0-playground
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## 🧩 Tailwind Setup
|
|
31
|
+
|
|
32
|
+
Make sure your `tailwind.config.ts` includes the preset and relevant content paths:
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
import preset from "@toriistudio/v0-playground/preset";
|
|
36
|
+
|
|
37
|
+
export default {
|
|
38
|
+
presets: [preset],
|
|
39
|
+
content: [
|
|
40
|
+
"./src/**/*.{ts,tsx}",
|
|
41
|
+
"./node_modules/@toriistudio/**/*.{js,ts,jsx,tsx}", // 👈 Required
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## 🧪 Usage
|
|
47
|
+
|
|
48
|
+
Use `Playground` to wrap any component and control props with `useControls`:
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { Playground, useControls } from "@toriistudio/v0-playground";
|
|
52
|
+
|
|
53
|
+
function MyComponent() {
|
|
54
|
+
const { label } = useControls({
|
|
55
|
+
label: { type: "string", value: "Click me" },
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
return <button>{label}</button>;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default function App() {
|
|
62
|
+
return (
|
|
63
|
+
<Playground>
|
|
64
|
+
<MyComponent />
|
|
65
|
+
</Playground>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## 💡 Example Use Cases
|
|
71
|
+
|
|
72
|
+
- Build custom component sandboxes
|
|
73
|
+
- Share interactive component demos
|
|
74
|
+
- Prototype interfaces quickly with real data
|
|
75
|
+
- Debug and test variants visually
|
|
76
|
+
|
|
77
|
+
## 🤙 License
|
|
78
|
+
|
|
79
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React, { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
declare function Playground({ children }: {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}): react_jsx_runtime.JSX.Element;
|
|
7
|
+
|
|
8
|
+
type ControlType = {
|
|
9
|
+
type: "boolean";
|
|
10
|
+
value: boolean;
|
|
11
|
+
} | {
|
|
12
|
+
type: "number";
|
|
13
|
+
value: number;
|
|
14
|
+
min?: number;
|
|
15
|
+
max?: number;
|
|
16
|
+
step?: number;
|
|
17
|
+
} | {
|
|
18
|
+
type: "string";
|
|
19
|
+
value: string;
|
|
20
|
+
} | {
|
|
21
|
+
type: "color";
|
|
22
|
+
value: string;
|
|
23
|
+
} | {
|
|
24
|
+
type: "select";
|
|
25
|
+
value: string;
|
|
26
|
+
options: string[];
|
|
27
|
+
} | {
|
|
28
|
+
type: "button";
|
|
29
|
+
onClick?: () => void;
|
|
30
|
+
label?: string;
|
|
31
|
+
render?: () => React.ReactNode;
|
|
32
|
+
};
|
|
33
|
+
type ControlsSchema = Record<string, ControlType>;
|
|
34
|
+
declare const useControls: <T extends ControlsSchema>(schema: T, options?: {
|
|
35
|
+
componentName?: string;
|
|
36
|
+
}) => { [K in keyof T]: T[K] extends {
|
|
37
|
+
value: infer V;
|
|
38
|
+
} ? V : never; } & {
|
|
39
|
+
controls: Record<string, any>;
|
|
40
|
+
schema: ControlsSchema;
|
|
41
|
+
setValue: (key: string, value: any) => void;
|
|
42
|
+
jsx: () => string;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export { type ControlType, type ControlsSchema, Playground, useControls };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React, { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
declare function Playground({ children }: {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}): react_jsx_runtime.JSX.Element;
|
|
7
|
+
|
|
8
|
+
type ControlType = {
|
|
9
|
+
type: "boolean";
|
|
10
|
+
value: boolean;
|
|
11
|
+
} | {
|
|
12
|
+
type: "number";
|
|
13
|
+
value: number;
|
|
14
|
+
min?: number;
|
|
15
|
+
max?: number;
|
|
16
|
+
step?: number;
|
|
17
|
+
} | {
|
|
18
|
+
type: "string";
|
|
19
|
+
value: string;
|
|
20
|
+
} | {
|
|
21
|
+
type: "color";
|
|
22
|
+
value: string;
|
|
23
|
+
} | {
|
|
24
|
+
type: "select";
|
|
25
|
+
value: string;
|
|
26
|
+
options: string[];
|
|
27
|
+
} | {
|
|
28
|
+
type: "button";
|
|
29
|
+
onClick?: () => void;
|
|
30
|
+
label?: string;
|
|
31
|
+
render?: () => React.ReactNode;
|
|
32
|
+
};
|
|
33
|
+
type ControlsSchema = Record<string, ControlType>;
|
|
34
|
+
declare const useControls: <T extends ControlsSchema>(schema: T, options?: {
|
|
35
|
+
componentName?: string;
|
|
36
|
+
}) => { [K in keyof T]: T[K] extends {
|
|
37
|
+
value: infer V;
|
|
38
|
+
} ? V : never; } & {
|
|
39
|
+
controls: Record<string, any>;
|
|
40
|
+
schema: ControlsSchema;
|
|
41
|
+
setValue: (key: string, value: any) => void;
|
|
42
|
+
jsx: () => string;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export { type ControlType, type ControlsSchema, Playground, useControls };
|