@sreedev/my3dui 0.1.9 → 0.2.2

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/README.md CHANGED
@@ -41,6 +41,22 @@ yarn add @sreedev/my3dui react react-dom
41
41
  pnpm add @sreedev/my3dui react react-dom
42
42
  ```
43
43
 
44
+ ### Import styles (required for theming)
45
+
46
+ Import the library's built CSS once in your app (e.g. in `main.tsx` or `_app.tsx`) so design tokens and Tailwind utilities apply:
47
+
48
+ ```tsx
49
+ import "@sreedev/my3dui/styles.css";
50
+ ```
51
+
52
+ Or from the package path:
53
+
54
+ ```tsx
55
+ import "@sreedev/my3dui/styles.css"; // or "./node_modules/@sreedev/my3dui/dist/styles.css"
56
+ ```
57
+
58
+ The CSS includes Tailwind base/components/utilities and all theme token definitions (`:root`, `.dark`, `.neon`, `.glass`, `.corporate`, `.vibrant`). You do **not** need to install Tailwind in your app to use My3DUI components; the built CSS is self-contained. For custom utilities or content beyond the library, you can still add your own Tailwind config and extend the theme.
59
+
44
60
  ### Optional Dependencies
45
61
 
46
62
  For 3D component support, install the following packages:
@@ -65,18 +81,58 @@ All components are exported from the main entry. Use tree-shaking for optimal bu
65
81
 
66
82
  **Effects:** `Particles`, `Bloom`, `Reflection`, `Fog`, `ShadowSystem`, `GlowEffect`, `WaveEffect`, `NoiseField`
67
83
 
84
+ **Theme:** `ThemeProvider`, `useTheme`, `useThemeOptional`, `ThemeName`
85
+
86
+ ## Multi-theme system
87
+
88
+ My3DUI ships with six themes controlled by a class on `document.documentElement`. Use `ThemeProvider` to switch themes and persist the choice.
89
+
90
+ **Themes:** `light` (default), `dark`, `neon`, `glass`, `corporate`, `vibrant`
91
+
92
+ ```tsx
93
+ import { ThemeProvider, useTheme } from "@sreedev/my3dui";
94
+ import "@sreedev/my3dui/styles.css";
95
+
96
+ function App() {
97
+ return (
98
+ <ThemeProvider defaultTheme="light" storageKey="my3dui-theme">
99
+ <Demo />
100
+ </ThemeProvider>
101
+ );
102
+ }
103
+
104
+ function Demo() {
105
+ const { theme, setTheme } = useTheme();
106
+ return (
107
+ <select value={theme} onChange={(e) => setTheme(e.target.value)}>
108
+ <option value="light">Light</option>
109
+ <option value="dark">Dark</option>
110
+ <option value="neon">Neon</option>
111
+ <option value="glass">Glass</option>
112
+ <option value="corporate">Corporate</option>
113
+ <option value="vibrant">Vibrant</option>
114
+ </select>
115
+ );
116
+ }
117
+ ```
118
+
119
+ All components use CSS variables for colors, so they automatically adapt to the active theme. No extra Tailwind setup is required in the consumer app when using the built CSS.
120
+
68
121
  ## Design system
69
122
 
70
123
  ### Design tokens
71
124
 
72
- The library uses a consistent token system (see `lib/tokens.ts`):
125
+ The library uses two layers of tokens:
126
+
127
+ **1. CSS variables (in `styles.css`)** — Drive theming; values are RGB triplets so Tailwind can apply opacity:
128
+
129
+ - **Colors:** `--color-primary`, `--color-primary-foreground`, `--color-secondary`, `--color-accent`, `--color-danger`, `--color-success`, `--color-warning`, `--color-background`, `--color-foreground`, `--color-surface`, `--color-border`, `--color-text-primary`, `--color-text-secondary`, `--color-ring`, `--color-muted`, `--color-muted-foreground`
130
+ - **Shadows:** `--shadow-soft`, `--shadow-glow`
131
+ - **Radius:** `--radius-sm`, `--radius-md`, `--radius-lg`, `--radius-xl`, `--radius-2xl`, `--radius-full`
73
132
 
74
- - **Spacing:** Scale 0–24 (1 unit = 0.25rem). Use for `gap`, `padding`, `margin` in layouts.
75
- - **Radius:** `none`, `sm`, `md`, `lg`, `xl`, `2xl`, `3xl`, `full`.
76
- - **Z-index:** `dropdown`, `sticky`, `overlay`, `modal`, `popover`, `toast`, `tooltip`.
77
- - **Container sizes:** `sm` (48rem), `md` (64rem), `lg` (80rem), `xl` (87.5rem), `full`.
133
+ Each theme (`:root`, `.dark`, `.neon`, `.glass`, `.corporate`, `.vibrant`) sets these variables.
78
134
 
79
- Components that accept numeric `gap` or `padding` (e.g. `Stack`, `Grid`, `Container`) use this spacing scale.
135
+ **2. JS tokens (in `lib/tokens.ts`)** Spacing scale, z-index scale, duration, breakpoints for layout and animation. Used by layout components and shared utilities.
80
136
 
81
137
  ### Variants (CVA)
82
138