loopwind 0.12.1 → 0.12.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.
@@ -1,269 +0,0 @@
1
- # shadcn/ui Design System Integration
2
-
3
- loopwind uses **shadcn/ui's design system** by default, providing beautiful and consistent colors, typography, and components.
4
-
5
- ## Default Color Palette
6
-
7
- All templates automatically have access to shadcn's semantic color tokens:
8
-
9
- ```typescript
10
- colors: {
11
- // Primary colors
12
- primary: '#18181b', // Main brand color
13
- 'primary-foreground': '#fafafa',
14
-
15
- // Secondary colors
16
- secondary: '#f4f4f5', // Subtle accents
17
- 'secondary-foreground': '#18181b',
18
-
19
- // Background
20
- background: '#ffffff', // Page background
21
- foreground: '#09090b', // Main text color
22
-
23
- // Muted
24
- muted: '#f4f4f5', // Subtle backgrounds
25
- 'muted-foreground': '#71717a', // Muted text
26
-
27
- // Accent
28
- accent: '#f4f4f5', // Highlight color
29
- 'accent-foreground': '#18181b',
30
-
31
- // Destructive
32
- destructive: '#ef4444', // Error/danger states
33
- 'destructive-foreground': '#fafafa',
34
-
35
- // UI Elements
36
- border: '#e4e4e7', // Border color
37
- input: '#e4e4e7', // Input borders
38
- ring: '#18181b', // Focus rings
39
- card: '#ffffff', // Card background
40
- 'card-foreground': '#09090b',
41
- popover: '#ffffff', // Popover background
42
- 'popover-foreground': '#09090b',
43
- }
44
- ```
45
-
46
- ## Using shadcn Colors in Templates
47
-
48
- ### Basic Usage
49
-
50
- ```tsx
51
- export default function Template({ title, tw }) {
52
- return (
53
- <div style={tw('bg-background text-foreground')}>
54
- <h1 style={tw('text-primary font-bold')}>
55
- {title}
56
- </h1>
57
- <p style={tw('text-muted-foreground')}>
58
- Subtle secondary text
59
- </p>
60
- </div>
61
- );
62
- }
63
- ```
64
-
65
- ### Opacity Modifiers (shadcn Style)
66
-
67
- Use Tailwind's slash syntax for opacity:
68
-
69
- ```tsx
70
- <div style={tw('bg-primary/50')}> {/* 50% opacity */}
71
- <p style={tw('text-muted-foreground/75')}> {/* 75% opacity */}
72
- <div style={tw('border/30')}> {/* Border with 30% opacity */}
73
- ```
74
-
75
- **Supported syntax:**
76
- - `bg-{color}/{opacity}` - Background with opacity
77
- - `text-{color}/{opacity}` - Text with opacity
78
- - `border-{color}/{opacity}` - Border with opacity
79
-
80
- ### Cards and Containers
81
-
82
- ```tsx
83
- <div style={tw('bg-card border rounded-xl p-16')}>
84
- <h2 style={tw('text-card-foreground font-bold')}>Card Title</h2>
85
- <p style={tw('text-muted-foreground')}>Card content</p>
86
- </div>
87
- ```
88
-
89
- ### Destructive/Error States
90
-
91
- ```tsx
92
- <div style={tw('bg-destructive/10 border-destructive/50 rounded-lg p-4')}>
93
- <p style={tw('text-destructive font-medium')}>
94
- Error: Something went wrong
95
- </p>
96
- </div>
97
- ```
98
-
99
- ## Complete Example
100
-
101
- Here's a template using shadcn design system:
102
-
103
- ```tsx
104
- import React from 'react';
105
-
106
- export const meta = {
107
- name: "shadcn-card",
108
- description: "Card using shadcn design system",
109
- type: "image",
110
- size: { width: 1200, height: 630 }
111
- };
112
-
113
- export default function ShadcnCard({ title, description, status, tw }) {
114
- return (
115
- <div style={tw('w-full h-full flex items-center justify-center bg-background p-20')}>
116
- <div style={tw('bg-card border rounded-xl p-16 flex flex-col')}>
117
- {/* Header */}
118
- <div style={tw('flex items-center mb-6')}>
119
- <div style={tw('bg-primary rounded-lg p-3')}>
120
- <span style={tw('text-primary-foreground text-2xl')}>✓</span>
121
- </div>
122
- <h1 style={tw('text-4xl font-bold text-foreground ml-4')}>
123
- {title}
124
- </h1>
125
- </div>
126
-
127
- {/* Description */}
128
- <p style={tw('text-2xl text-muted-foreground mb-6')}>
129
- {description}
130
- </p>
131
-
132
- {/* Status badge */}
133
- <div style={tw('bg-secondary rounded-md p-2')}>
134
- <span style={tw('text-secondary-foreground font-medium')}>
135
- Status: {status}
136
- </span>
137
- </div>
138
-
139
- {/* Subtle border */}
140
- <div style={tw('border-t/50 mt-6 pt-6')}>
141
- <p style={tw('text-muted-foreground/75 text-sm')}>
142
- Powered by loopwind + shadcn
143
- </p>
144
- </div>
145
- </div>
146
- </div>
147
- );
148
- }
149
- ```
150
-
151
- ## Customizing Colors
152
-
153
- Users can override the default shadcn colors in their `loopwind.json`:
154
-
155
- ```json
156
- {
157
- "colors": {
158
- "primary": "#3b82f6",
159
- "primary-foreground": "#ffffff",
160
- "secondary": "#f1f5f9",
161
- "secondary-foreground": "#0f172a"
162
- // ... other colors
163
- }
164
- }
165
- ```
166
-
167
- Or use their existing `tailwind.config.js` colors - loopwind automatically detects and uses them!
168
-
169
- ## shadcn Themes
170
-
171
- loopwind uses the **Zinc theme** by default. Users can easily switch to other shadcn themes:
172
-
173
- ### Slate Theme
174
- ```json
175
- {
176
- "colors": {
177
- "primary": "#020617",
178
- "secondary": "#f1f5f9",
179
- "muted": "#f1f5f9",
180
- "accent": "#f1f5f9",
181
- "border": "#e2e8f0"
182
- }
183
- }
184
- ```
185
-
186
- ### Stone Theme
187
- ```json
188
- {
189
- "colors": {
190
- "primary": "#0c0a09",
191
- "secondary": "#f5f5f4",
192
- "muted": "#f5f5f4",
193
- "accent": "#f5f5f4",
194
- "border": "#e7e5e4"
195
- }
196
- }
197
- ```
198
-
199
- ### Dark Mode
200
- ```json
201
- {
202
- "colors": {
203
- "primary": "#fafafa",
204
- "primary-foreground": "#18181b",
205
- "background": "#09090b",
206
- "foreground": "#fafafa",
207
- "card": "#18181b",
208
- "card-foreground": "#fafafa",
209
- "muted": "#27272a",
210
- "muted-foreground": "#a1a1aa",
211
- "border": "#27272a"
212
- }
213
- }
214
- ```
215
-
216
- ## Supported shadcn Classes
217
-
218
- ### Colors
219
- - `text-primary`, `text-secondary`, `text-muted`, `text-accent`, `text-destructive`
220
- - `bg-primary`, `bg-secondary`, `bg-muted`, `bg-accent`, `bg-destructive`, `bg-card`
221
- - `border`, `border-primary`, `border-destructive`, etc.
222
-
223
- ### Foreground Variants
224
- - `text-primary-foreground`
225
- - `text-secondary-foreground`
226
- - `text-muted-foreground`
227
- - `text-card-foreground`
228
-
229
- ### With Opacity
230
- - `bg-primary/50`, `text-muted-foreground/75`, `border/30`
231
- - Any color can have `/10`, `/20`, `/30`, ... `/90`, `/100`
232
-
233
- ## Best Practices
234
-
235
- 1. **Use semantic colors** - `text-foreground` instead of `text-black`
236
- 2. **Leverage opacity modifiers** - `bg-primary/10` for subtle highlights
237
- 3. **Card patterns** - `bg-card border rounded-xl` for containers
238
- 4. **Consistent foregrounds** - Pair colors with their foreground variants
239
- 5. **Muted for secondary** - Use `text-muted-foreground` for less important text
240
-
241
- ## Migration from Custom Colors
242
-
243
- Before (custom gradient):
244
- ```tsx
245
- <div style={{
246
- background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
247
- color: 'white'
248
- }}>
249
- ```
250
-
251
- After (shadcn):
252
- ```tsx
253
- <div style={tw('bg-primary text-primary-foreground')}>
254
- ```
255
-
256
- Much cleaner and themeable!
257
-
258
- ## Summary
259
-
260
- | Feature | Supported | Example |
261
- |---------|-----------|---------|
262
- | **Semantic colors** | ✅ | `text-primary`, `bg-card` |
263
- | **Foreground variants** | ✅ | `text-muted-foreground` |
264
- | **Opacity modifiers** | ✅ | `bg-primary/50`, `text-muted/75` |
265
- | **Border colors** | ✅ | `border`, `border-destructive/50` |
266
- | **Dark mode** | ✅ | Override in loopwind.json |
267
- | **Custom themes** | ✅ | Full shadcn palette customizable |
268
-
269
- **loopwind templates automatically work with shadcn's design system!** 🎨
package/TAILWIND.md DELETED
@@ -1,228 +0,0 @@
1
- # Using Tailwind Classes in Templates
2
-
3
- ## Overview
4
-
5
- Templates can use Tailwind utility classes instead of writing inline styles! The `tw()` function is automatically provided to every template and converts Tailwind classes to inline styles that Satori can render.
6
-
7
- ## Basic Usage
8
-
9
- ```tsx
10
- export default function MyTemplate({ title, tw }) {
11
- return (
12
- <div style={tw('flex items-center justify-center w-full h-full bg-blue-500')}>
13
- <h1 style={tw('text-6xl font-bold text-white')}>
14
- {title}
15
- </h1>
16
- </div>
17
- );
18
- }
19
- ```
20
-
21
- ## Combining with Custom Styles
22
-
23
- You can mix Tailwind classes with custom styles using the spread operator:
24
-
25
- ```tsx
26
- export default function MyTemplate({ title, tw, config }) {
27
- return (
28
- <div
29
- style={{
30
- ...tw('flex flex-col p-20 text-white'),
31
- background: `linear-gradient(135deg, ${config?.colors?.primary} 0%, ${config?.colors?.secondary} 100%)`,
32
- }}
33
- >
34
- <h1 style={tw('text-8xl font-bold')}>{title}</h1>
35
- </div>
36
- );
37
- }
38
- ```
39
-
40
- ## Supported Tailwind Classes
41
-
42
- ### Layout
43
-
44
- - **Display**: `flex`, `inline-flex`, `block`, `inline-block`, `hidden`
45
- - **Flex Direction**: `flex-row`, `flex-col`, `flex-row-reverse`, `flex-col-reverse`
46
- - **Justify**: `justify-start`, `justify-end`, `justify-center`, `justify-between`, `justify-around`
47
- - **Align**: `items-start`, `items-end`, `items-center`, `items-baseline`, `items-stretch`
48
-
49
- ### Spacing
50
-
51
- - **Padding**: `p-{n}`, `px-{n}`, `py-{n}`, `pt-{n}`, `pb-{n}`, `pl-{n}`, `pr-{n}`
52
- - **Margin**: `m-{n}`, `mx-{n}`, `my-{n}`, `mt-{n}`, `mb-{n}`, `ml-{n}`, `mr-{n}`
53
- - **Gap**: `gap-{n}`, `gap-x-{n}`, `gap-y-{n}`
54
- - **Sizes**: 0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24, 32, 40, 48, 56, 64
55
-
56
- Examples:
57
- ```tsx
58
- tw('p-4') // padding: 1rem
59
- tw('px-8') // paddingLeft: 2rem, paddingRight: 2rem
60
- tw('m-6') // margin: 1.5rem
61
- tw('gap-4') // gap: 1rem
62
- ```
63
-
64
- ### Sizing
65
-
66
- - **Width**: `w-{n}`, `w-full`, `w-screen`
67
- - **Height**: `h-{n}`, `h-full`, `h-screen`
68
-
69
- Examples:
70
- ```tsx
71
- tw('w-full') // width: 100%
72
- tw('h-64') // height: 16rem
73
- ```
74
-
75
- ### Typography
76
-
77
- - **Font Size**: `text-xs`, `text-sm`, `text-base`, `text-lg`, `text-xl`, `text-2xl`, `text-3xl`, `text-4xl`, `text-5xl`, `text-6xl`, `text-7xl`, `text-8xl`, `text-9xl`
78
- - **Font Weight**: `font-thin`, `font-light`, `font-normal`, `font-medium`, `font-semibold`, `font-bold`, `font-extrabold`, `font-black`
79
- - **Text Align**: `text-left`, `text-center`, `text-right`
80
-
81
- Examples:
82
- ```tsx
83
- tw('text-6xl') // fontSize: 3.75rem
84
- tw('font-bold') // fontWeight: 700
85
- tw('text-center') // textAlign: center
86
- ```
87
-
88
- ### Borders
89
-
90
- - **Border Radius**: `rounded`, `rounded-sm`, `rounded-md`, `rounded-lg`, `rounded-xl`, `rounded-2xl`, `rounded-3xl`, `rounded-full`
91
-
92
- Examples:
93
- ```tsx
94
- tw('rounded-lg') // borderRadius: 0.5rem
95
- tw('rounded-full') // borderRadius: 9999px
96
- ```
97
-
98
- ### Effects
99
-
100
- - **Opacity**: `opacity-{0-100}`
101
-
102
- Examples:
103
- ```tsx
104
- tw('opacity-50') // opacity: 0.5
105
- tw('opacity-90') // opacity: 0.9
106
- ```
107
-
108
- ### Colors
109
-
110
- - **Static Colors**: `text-white`, `text-black`, `bg-white`, `bg-black`
111
- - **Config Colors**: `bg-primary`, `text-primary`, `bg-secondary`, etc. (from loopwind.json)
112
-
113
- Examples:
114
- ```tsx
115
- // Using static colors
116
- tw('bg-black text-white')
117
-
118
- // Using config colors (from loopwind.json)
119
- tw('bg-primary text-secondary')
120
- ```
121
-
122
- ## Config Color Integration
123
-
124
- The `tw()` function automatically uses colors from your `loopwind.json`:
125
-
126
- ```json
127
- {
128
- "colors": {
129
- "primary": "#667eea",
130
- "secondary": "#764ba2",
131
- "accent": "#3b82f6"
132
- }
133
- }
134
- ```
135
-
136
- ```tsx
137
- // In your template
138
- <div style={tw('bg-primary text-white')}>
139
- {/* background will be #667eea */}
140
- </div>
141
- ```
142
-
143
- ## Complete Example
144
-
145
- ```tsx
146
- import React from 'react';
147
-
148
- export const meta = {
149
- name: "social-card",
150
- description: "A social media card",
151
- size: { width: 1200, height: 630 },
152
- props: { title: "string", description: "string" }
153
- };
154
-
155
- interface SocialCardProps {
156
- title: string;
157
- description: string;
158
- tw?: (classes: string) => any;
159
- config?: any;
160
- }
161
-
162
- export default function SocialCard({
163
- title,
164
- description,
165
- tw = (c) => ({}),
166
- config
167
- }: SocialCardProps) {
168
- return (
169
- <div style={tw('w-full h-full flex flex-col justify-center items-center bg-primary text-white p-16')}>
170
- <h1 style={tw('text-6xl font-bold text-center mb-8')}>
171
- {title}
172
- </h1>
173
- <p style={tw('text-2xl text-center opacity-90')}>
174
- {description}
175
- </p>
176
- </div>
177
- );
178
- }
179
- ```
180
-
181
- ## Fallback for Missing tw
182
-
183
- Always provide a fallback for the `tw` function in case it's not provided:
184
-
185
- ```tsx
186
- export default function MyTemplate({
187
- title,
188
- tw = (classes: string) => ({}) // Fallback
189
- }: MyTemplateProps) {
190
- // Now tw is always safe to use
191
- return <div style={tw('flex items-center')}>{title}</div>;
192
- }
193
- ```
194
-
195
- ## Extending Tailwind Support
196
-
197
- The current implementation supports common Tailwind classes. To add more:
198
-
199
- 1. Edit `src/lib/tailwind.ts`
200
- 2. Add to `TAILWIND_MAP` or create a new parser function
201
- 3. Rebuild the CLI
202
-
203
- Example adding a new utility:
204
-
205
- ```typescript
206
- // In src/lib/tailwind.ts
207
- const TAILWIND_MAP = {
208
- // ... existing classes
209
- 'shadow-lg': { boxShadow: '0 10px 15px rgba(0,0,0,0.1)' },
210
- 'shadow-xl': { boxShadow: '0 20px 25px rgba(0,0,0,0.15)' },
211
- };
212
- ```
213
-
214
- ## Benefits
215
-
216
- 1. **Familiar Syntax**: Use the Tailwind classes you already know
217
- 2. **Cleaner Code**: Less verbose than inline styles
218
- 3. **Config Integration**: Automatic color mapping from loopwind.json
219
- 4. **Type Safe**: TypeScript support with CSSProperties
220
- 5. **Extensible**: Easy to add more utilities
221
-
222
- ## Limitations
223
-
224
- - Satori doesn't support all CSS features (no animations, transforms are limited)
225
- - Pseudo-classes (hover, focus) don't work (Satori renders static images)
226
- - Some Tailwind utilities may not have equivalents yet
227
-
228
- For advanced styling needs, combine Tailwind classes with custom inline styles!