create-huenei-template 0.2.2 → 0.2.4
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/dist/config/templates.js +3 -3
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-component/SKILL.md +288 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-component/references/component-patterns.md +358 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-di/SKILL.md +387 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-di/references/di-patterns.md +519 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-directives/SKILL.md +437 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-directives/references/directive-patterns.md +570 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-forms/SKILL.md +434 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-forms/references/form-patterns.md +398 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-http/SKILL.md +366 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-http/references/http-patterns.md +448 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-routing/SKILL.md +395 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-routing/references/routing-patterns.md +472 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-signals/SKILL.md +302 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-signals/references/signal-patterns.md +404 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-ssr/SKILL.md +435 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-ssr/references/ssr-patterns.md +497 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-testing/SKILL.md +660 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-testing/references/testing-patterns.md +707 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-tooling/SKILL.md +352 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/angular-tooling/references/tooling-patterns.md +448 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-accessibility/SKILL.md +780 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-advanced-components/SKILL.md +718 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-advanced-design-systems/SKILL.md +612 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-advanced-layouts/SKILL.md +594 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-animations/SKILL.md +432 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-animations/references/animation-patterns.md +427 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-debugging/SKILL.md +354 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-debugging/references/troubleshooting-guide.md +306 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-framework-integration/SKILL.md +578 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-framework-integration/references/react-patterns.md +353 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-fundamentals-v4/SKILL.md +608 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-fundamentals-v4/references/advanced-theme-patterns.md +215 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-fundamentals-v4/references/custom-utilities-guide.md +281 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-mobile-first/SKILL.md +768 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-performance/SKILL.md +374 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-performance/references/bundle-optimization.md +244 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-plugins/SKILL.md +505 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-responsive-darkmode/SKILL.md +601 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/tailwindcss-responsive-darkmode/references/advanced-responsive-patterns.md +485 -0
- package/dist/templates/frontend/angular-base/.cursor/skills/web-design-guidelines/SKILL.md +39 -0
- package/dist/templates/frontend/angular-base/package.json +0 -1
- package/dist/templates/frontend/angular-base/pnpm-lock.yaml +8183 -0
- package/package.json +1 -1
- package/templates/frontend/angular-base/.cursor/skills/angular-component/SKILL.md +288 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-component/references/component-patterns.md +358 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-di/SKILL.md +387 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-di/references/di-patterns.md +519 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-directives/SKILL.md +437 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-directives/references/directive-patterns.md +570 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-forms/SKILL.md +434 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-forms/references/form-patterns.md +398 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-http/SKILL.md +366 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-http/references/http-patterns.md +448 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-routing/SKILL.md +395 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-routing/references/routing-patterns.md +472 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-signals/SKILL.md +302 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-signals/references/signal-patterns.md +404 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-ssr/SKILL.md +435 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-ssr/references/ssr-patterns.md +497 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-testing/SKILL.md +660 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-testing/references/testing-patterns.md +707 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-tooling/SKILL.md +352 -0
- package/templates/frontend/angular-base/.cursor/skills/angular-tooling/references/tooling-patterns.md +448 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-accessibility/SKILL.md +780 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-advanced-components/SKILL.md +718 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-advanced-design-systems/SKILL.md +612 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-advanced-layouts/SKILL.md +594 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-animations/SKILL.md +432 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-animations/references/animation-patterns.md +427 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-debugging/SKILL.md +354 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-debugging/references/troubleshooting-guide.md +306 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-framework-integration/SKILL.md +578 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-framework-integration/references/react-patterns.md +353 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-fundamentals-v4/SKILL.md +608 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-fundamentals-v4/references/advanced-theme-patterns.md +215 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-fundamentals-v4/references/custom-utilities-guide.md +281 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-mobile-first/SKILL.md +768 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-performance/SKILL.md +374 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-performance/references/bundle-optimization.md +244 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-plugins/SKILL.md +505 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-responsive-darkmode/SKILL.md +601 -0
- package/templates/frontend/angular-base/.cursor/skills/tailwindcss-responsive-darkmode/references/advanced-responsive-patterns.md +485 -0
- package/templates/frontend/angular-base/.cursor/skills/web-design-guidelines/SKILL.md +39 -0
- package/templates/frontend/angular-base/package.json +0 -1
- package/templates/frontend/angular-base/pnpm-lock.yaml +8183 -0
- package/templates/frontend/angular-base/package-lock.json +0 -13321
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
# React + Tailwind Patterns
|
|
2
|
+
|
|
3
|
+
## Component Architecture
|
|
4
|
+
|
|
5
|
+
### Base Component Pattern
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
// components/ui/Button.tsx
|
|
9
|
+
import { forwardRef, type ButtonHTMLAttributes } from 'react'
|
|
10
|
+
import { cn } from '@/lib/utils'
|
|
11
|
+
|
|
12
|
+
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
13
|
+
variant?: 'primary' | 'secondary' | 'outline' | 'ghost' | 'destructive'
|
|
14
|
+
size?: 'sm' | 'md' | 'lg' | 'icon'
|
|
15
|
+
isLoading?: boolean
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const buttonVariants = {
|
|
19
|
+
primary: 'bg-primary-600 text-white hover:bg-primary-700 focus-visible:ring-primary-500',
|
|
20
|
+
secondary: 'bg-gray-100 text-gray-900 hover:bg-gray-200 dark:bg-gray-800 dark:text-white',
|
|
21
|
+
outline: 'border-2 border-gray-300 hover:bg-gray-50 dark:border-gray-600 dark:hover:bg-gray-800',
|
|
22
|
+
ghost: 'hover:bg-gray-100 dark:hover:bg-gray-800',
|
|
23
|
+
destructive: 'bg-red-600 text-white hover:bg-red-700 focus-visible:ring-red-500',
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const buttonSizes = {
|
|
27
|
+
sm: 'h-8 px-3 text-sm',
|
|
28
|
+
md: 'h-10 px-4 text-base',
|
|
29
|
+
lg: 'h-12 px-6 text-lg',
|
|
30
|
+
icon: 'h-10 w-10',
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
34
|
+
({ className, variant = 'primary', size = 'md', isLoading, disabled, children, ...props }, ref) => {
|
|
35
|
+
return (
|
|
36
|
+
<button
|
|
37
|
+
ref={ref}
|
|
38
|
+
disabled={disabled || isLoading}
|
|
39
|
+
className={cn(
|
|
40
|
+
'inline-flex items-center justify-center gap-2 font-medium rounded-lg',
|
|
41
|
+
'transition-colors duration-200',
|
|
42
|
+
'focus:outline-none focus-visible:ring-2 focus-visible:ring-offset-2',
|
|
43
|
+
'disabled:opacity-50 disabled:pointer-events-none',
|
|
44
|
+
buttonVariants[variant],
|
|
45
|
+
buttonSizes[size],
|
|
46
|
+
className
|
|
47
|
+
)}
|
|
48
|
+
{...props}
|
|
49
|
+
>
|
|
50
|
+
{isLoading && <Spinner className="h-4 w-4" />}
|
|
51
|
+
{children}
|
|
52
|
+
</button>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
Button.displayName = 'Button'
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Utility Function
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
// lib/utils.ts
|
|
63
|
+
import { clsx, type ClassValue } from 'clsx'
|
|
64
|
+
import { twMerge } from 'tailwind-merge'
|
|
65
|
+
|
|
66
|
+
export function cn(...inputs: ClassValue[]) {
|
|
67
|
+
return twMerge(clsx(inputs))
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Compound Components
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
// components/ui/Card.tsx
|
|
75
|
+
import { cn } from '@/lib/utils'
|
|
76
|
+
|
|
77
|
+
interface CardProps extends React.HTMLAttributes<HTMLDivElement> {}
|
|
78
|
+
|
|
79
|
+
export function Card({ className, ...props }: CardProps) {
|
|
80
|
+
return (
|
|
81
|
+
<div
|
|
82
|
+
className={cn(
|
|
83
|
+
'rounded-xl border border-gray-200 bg-white shadow-sm',
|
|
84
|
+
'dark:border-gray-800 dark:bg-gray-900',
|
|
85
|
+
className
|
|
86
|
+
)}
|
|
87
|
+
{...props}
|
|
88
|
+
/>
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function CardHeader({ className, ...props }: CardProps) {
|
|
93
|
+
return <div className={cn('p-6 pb-0', className)} {...props} />
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function CardTitle({ className, ...props }: React.HTMLAttributes<HTMLHeadingElement>) {
|
|
97
|
+
return (
|
|
98
|
+
<h3
|
|
99
|
+
className={cn('text-xl font-semibold text-gray-900 dark:text-white', className)}
|
|
100
|
+
{...props}
|
|
101
|
+
/>
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function CardDescription({ className, ...props }: React.HTMLAttributes<HTMLParagraphElement>) {
|
|
106
|
+
return (
|
|
107
|
+
<p className={cn('mt-1.5 text-sm text-gray-500 dark:text-gray-400', className)} {...props} />
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export function CardContent({ className, ...props }: CardProps) {
|
|
112
|
+
return <div className={cn('p-6', className)} {...props} />
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function CardFooter({ className, ...props }: CardProps) {
|
|
116
|
+
return (
|
|
117
|
+
<div
|
|
118
|
+
className={cn('flex items-center p-6 pt-0', className)}
|
|
119
|
+
{...props}
|
|
120
|
+
/>
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Usage:
|
|
126
|
+
```tsx
|
|
127
|
+
<Card>
|
|
128
|
+
<CardHeader>
|
|
129
|
+
<CardTitle>Account Settings</CardTitle>
|
|
130
|
+
<CardDescription>Manage your account preferences</CardDescription>
|
|
131
|
+
</CardHeader>
|
|
132
|
+
<CardContent>
|
|
133
|
+
<form>...</form>
|
|
134
|
+
</CardContent>
|
|
135
|
+
<CardFooter>
|
|
136
|
+
<Button>Save Changes</Button>
|
|
137
|
+
</CardFooter>
|
|
138
|
+
</Card>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Polymorphic Components
|
|
142
|
+
|
|
143
|
+
```tsx
|
|
144
|
+
// components/ui/Box.tsx
|
|
145
|
+
import { forwardRef, type ElementType, type ComponentPropsWithoutRef } from 'react'
|
|
146
|
+
import { cn } from '@/lib/utils'
|
|
147
|
+
|
|
148
|
+
type BoxProps<T extends ElementType = 'div'> = {
|
|
149
|
+
as?: T
|
|
150
|
+
className?: string
|
|
151
|
+
} & ComponentPropsWithoutRef<T>
|
|
152
|
+
|
|
153
|
+
export const Box = forwardRef(
|
|
154
|
+
<T extends ElementType = 'div'>(
|
|
155
|
+
{ as, className, ...props }: BoxProps<T>,
|
|
156
|
+
ref: React.Ref<Element>
|
|
157
|
+
) => {
|
|
158
|
+
const Component = as || 'div'
|
|
159
|
+
return <Component ref={ref} className={cn(className)} {...props} />
|
|
160
|
+
}
|
|
161
|
+
) as <T extends ElementType = 'div'>(
|
|
162
|
+
props: BoxProps<T> & { ref?: React.Ref<Element> }
|
|
163
|
+
) => React.ReactElement | null
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Usage:
|
|
167
|
+
```tsx
|
|
168
|
+
<Box as="section" className="p-4 bg-gray-50">Section content</Box>
|
|
169
|
+
<Box as="article" className="prose">Article content</Box>
|
|
170
|
+
<Box as="aside" className="w-64">Sidebar</Box>
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Variant Props with cva
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
npm install class-variance-authority
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
```tsx
|
|
180
|
+
// components/ui/Badge.tsx
|
|
181
|
+
import { cva, type VariantProps } from 'class-variance-authority'
|
|
182
|
+
import { cn } from '@/lib/utils'
|
|
183
|
+
|
|
184
|
+
const badgeVariants = cva(
|
|
185
|
+
'inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors',
|
|
186
|
+
{
|
|
187
|
+
variants: {
|
|
188
|
+
variant: {
|
|
189
|
+
default: 'bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-100',
|
|
190
|
+
primary: 'bg-primary-100 text-primary-800 dark:bg-primary-900 dark:text-primary-100',
|
|
191
|
+
success: 'bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-100',
|
|
192
|
+
warning: 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-100',
|
|
193
|
+
danger: 'bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-100',
|
|
194
|
+
},
|
|
195
|
+
size: {
|
|
196
|
+
sm: 'text-xs px-2 py-0.5',
|
|
197
|
+
md: 'text-sm px-2.5 py-0.5',
|
|
198
|
+
lg: 'text-base px-3 py-1',
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
defaultVariants: {
|
|
202
|
+
variant: 'default',
|
|
203
|
+
size: 'md',
|
|
204
|
+
},
|
|
205
|
+
}
|
|
206
|
+
)
|
|
207
|
+
|
|
208
|
+
interface BadgeProps
|
|
209
|
+
extends React.HTMLAttributes<HTMLSpanElement>,
|
|
210
|
+
VariantProps<typeof badgeVariants> {}
|
|
211
|
+
|
|
212
|
+
export function Badge({ className, variant, size, ...props }: BadgeProps) {
|
|
213
|
+
return <span className={cn(badgeVariants({ variant, size }), className)} {...props} />
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Animation Patterns
|
|
218
|
+
|
|
219
|
+
```tsx
|
|
220
|
+
// components/ui/FadeIn.tsx
|
|
221
|
+
import { cn } from '@/lib/utils'
|
|
222
|
+
|
|
223
|
+
interface FadeInProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
224
|
+
delay?: number
|
|
225
|
+
duration?: number
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export function FadeIn({
|
|
229
|
+
className,
|
|
230
|
+
delay = 0,
|
|
231
|
+
duration = 500,
|
|
232
|
+
style,
|
|
233
|
+
...props
|
|
234
|
+
}: FadeInProps) {
|
|
235
|
+
return (
|
|
236
|
+
<div
|
|
237
|
+
className={cn(
|
|
238
|
+
'animate-in fade-in slide-in-from-bottom-4',
|
|
239
|
+
className
|
|
240
|
+
)}
|
|
241
|
+
style={{
|
|
242
|
+
animationDelay: `${delay}ms`,
|
|
243
|
+
animationDuration: `${duration}ms`,
|
|
244
|
+
...style,
|
|
245
|
+
}}
|
|
246
|
+
{...props}
|
|
247
|
+
/>
|
|
248
|
+
)
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## Form Components
|
|
253
|
+
|
|
254
|
+
```tsx
|
|
255
|
+
// components/ui/Input.tsx
|
|
256
|
+
import { forwardRef, type InputHTMLAttributes } from 'react'
|
|
257
|
+
import { cn } from '@/lib/utils'
|
|
258
|
+
|
|
259
|
+
export interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
260
|
+
error?: boolean
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export const Input = forwardRef<HTMLInputElement, InputProps>(
|
|
264
|
+
({ className, error, type = 'text', ...props }, ref) => {
|
|
265
|
+
return (
|
|
266
|
+
<input
|
|
267
|
+
type={type}
|
|
268
|
+
ref={ref}
|
|
269
|
+
className={cn(
|
|
270
|
+
'w-full rounded-lg border px-3 py-2',
|
|
271
|
+
'bg-white dark:bg-gray-900',
|
|
272
|
+
'text-gray-900 dark:text-white',
|
|
273
|
+
'placeholder:text-gray-400',
|
|
274
|
+
'transition-colors duration-200',
|
|
275
|
+
'focus:outline-none focus:ring-2 focus:ring-offset-2',
|
|
276
|
+
error
|
|
277
|
+
? 'border-red-500 focus:ring-red-500'
|
|
278
|
+
: 'border-gray-300 dark:border-gray-700 focus:ring-primary-500',
|
|
279
|
+
'disabled:cursor-not-allowed disabled:opacity-50',
|
|
280
|
+
className
|
|
281
|
+
)}
|
|
282
|
+
{...props}
|
|
283
|
+
/>
|
|
284
|
+
)
|
|
285
|
+
}
|
|
286
|
+
)
|
|
287
|
+
Input.displayName = 'Input'
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
## Responsive Component Patterns
|
|
291
|
+
|
|
292
|
+
```tsx
|
|
293
|
+
// components/layout/Container.tsx
|
|
294
|
+
import { cn } from '@/lib/utils'
|
|
295
|
+
|
|
296
|
+
interface ContainerProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
297
|
+
size?: 'sm' | 'md' | 'lg' | 'xl' | 'full'
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
const containerSizes = {
|
|
301
|
+
sm: 'max-w-screen-sm',
|
|
302
|
+
md: 'max-w-screen-md',
|
|
303
|
+
lg: 'max-w-screen-lg',
|
|
304
|
+
xl: 'max-w-screen-xl',
|
|
305
|
+
full: 'max-w-full',
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
export function Container({ className, size = 'lg', ...props }: ContainerProps) {
|
|
309
|
+
return (
|
|
310
|
+
<div
|
|
311
|
+
className={cn(
|
|
312
|
+
'mx-auto w-full px-4 sm:px-6 lg:px-8',
|
|
313
|
+
containerSizes[size],
|
|
314
|
+
className
|
|
315
|
+
)}
|
|
316
|
+
{...props}
|
|
317
|
+
/>
|
|
318
|
+
)
|
|
319
|
+
}
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
## Dark Mode Hook
|
|
323
|
+
|
|
324
|
+
```tsx
|
|
325
|
+
// hooks/useDarkMode.ts
|
|
326
|
+
import { useEffect, useState } from 'react'
|
|
327
|
+
|
|
328
|
+
export function useDarkMode() {
|
|
329
|
+
const [isDark, setIsDark] = useState(false)
|
|
330
|
+
|
|
331
|
+
useEffect(() => {
|
|
332
|
+
const root = document.documentElement
|
|
333
|
+
const stored = localStorage.getItem('theme')
|
|
334
|
+
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches
|
|
335
|
+
|
|
336
|
+
if (stored === 'dark' || (!stored && prefersDark)) {
|
|
337
|
+
root.classList.add('dark')
|
|
338
|
+
setIsDark(true)
|
|
339
|
+
}
|
|
340
|
+
}, [])
|
|
341
|
+
|
|
342
|
+
const toggle = () => {
|
|
343
|
+
const root = document.documentElement
|
|
344
|
+
const newValue = !isDark
|
|
345
|
+
|
|
346
|
+
root.classList.toggle('dark', newValue)
|
|
347
|
+
localStorage.setItem('theme', newValue ? 'dark' : 'light')
|
|
348
|
+
setIsDark(newValue)
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
return { isDark, toggle }
|
|
352
|
+
}
|
|
353
|
+
```
|