@mandujs/mcp 0.13.0 → 0.17.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/README.md +102 -7
- package/package.json +3 -2
- package/src/adapters/index.ts +20 -20
- package/src/adapters/monitor-adapter.ts +100 -100
- package/src/adapters/tool-adapter.ts +88 -88
- package/src/executor/error-handler.ts +250 -250
- package/src/executor/index.ts +22 -22
- package/src/executor/tool-executor.ts +148 -148
- package/src/hooks/config-watcher.ts +174 -174
- package/src/hooks/index.ts +23 -23
- package/src/hooks/mcp-hooks.ts +227 -227
- package/src/logging/index.ts +15 -15
- package/src/logging/mcp-transport.ts +134 -134
- package/src/registry/index.ts +13 -13
- package/src/registry/mcp-tool-registry.ts +298 -298
- package/src/resources/skills/guides.ts +1136 -1136
- package/src/resources/skills/index.ts +12 -12
- package/src/resources/skills/loader.ts +218 -218
- package/src/resources/skills/mandu-composition/SKILL.md +91 -91
- package/src/resources/skills/mandu-composition/metadata.json +13 -13
- package/src/resources/skills/mandu-composition/rules/_sections.md +26 -26
- package/src/resources/skills/mandu-composition/rules/_template.md +77 -77
- package/src/resources/skills/mandu-composition/rules/comp-arch-avoid-boolean-props.md +146 -146
- package/src/resources/skills/mandu-composition/rules/comp-arch-compound-components.md +164 -164
- package/src/resources/skills/mandu-composition/rules/comp-island-event.md +161 -161
- package/src/resources/skills/mandu-composition/rules/comp-island-slot-split.md +167 -167
- package/src/resources/skills/mandu-composition/rules/comp-pattern-children.md +149 -149
- package/src/resources/skills/mandu-composition/rules/comp-state-context-interface.md +148 -148
- package/src/resources/skills/mandu-composition/rules/comp-state-lift-state.md +150 -150
- package/src/resources/skills/mandu-deployment/SKILL.md +92 -92
- package/src/resources/skills/mandu-deployment/_sections.md +41 -41
- package/src/resources/skills/mandu-deployment/_template.md +38 -38
- package/src/resources/skills/mandu-deployment/metadata.json +13 -13
- package/src/resources/skills/mandu-deployment/rules/deploy-build-bun.md +109 -109
- package/src/resources/skills/mandu-deployment/rules/deploy-build-output.md +115 -115
- package/src/resources/skills/mandu-deployment/rules/deploy-cicd-github.md +219 -219
- package/src/resources/skills/mandu-deployment/rules/deploy-docker-bun.md +150 -150
- package/src/resources/skills/mandu-deployment/rules/deploy-docker-compose.md +223 -223
- package/src/resources/skills/mandu-deployment/rules/deploy-platform-fly.md +152 -152
- package/src/resources/skills/mandu-deployment/rules/deploy-platform-render.md +179 -179
- package/src/resources/skills/mandu-deployment/rules/deploy-platform-supabase.md +323 -323
- package/src/resources/skills/mandu-deployment/rules/deploy-platform-vercel.md +140 -140
- package/src/resources/skills/mandu-fs-routes/SKILL.md +82 -82
- package/src/resources/skills/mandu-fs-routes/metadata.json +12 -12
- package/src/resources/skills/mandu-fs-routes/rules/_sections.md +36 -36
- package/src/resources/skills/mandu-fs-routes/rules/_template.md +69 -69
- package/src/resources/skills/mandu-fs-routes/rules/routes-api-methods.md +65 -65
- package/src/resources/skills/mandu-fs-routes/rules/routes-dynamic-param.md +93 -93
- package/src/resources/skills/mandu-fs-routes/rules/routes-naming-page.md +55 -55
- package/src/resources/skills/mandu-guard/SKILL.md +129 -129
- package/src/resources/skills/mandu-guard/metadata.json +12 -12
- package/src/resources/skills/mandu-guard/rules/_sections.md +36 -36
- package/src/resources/skills/mandu-guard/rules/_template.md +82 -82
- package/src/resources/skills/mandu-guard/rules/guard-config-rules.md +100 -100
- package/src/resources/skills/mandu-guard/rules/guard-layer-direction.md +76 -76
- package/src/resources/skills/mandu-guard/rules/guard-preset-mandu.md +81 -81
- package/src/resources/skills/mandu-guard/rules/guard-validate-import.md +80 -80
- package/src/resources/skills/mandu-hydration/SKILL.md +91 -91
- package/src/resources/skills/mandu-hydration/metadata.json +12 -12
- package/src/resources/skills/mandu-hydration/rules/_sections.md +31 -31
- package/src/resources/skills/mandu-hydration/rules/_template.md +72 -72
- package/src/resources/skills/mandu-hydration/rules/hydration-data-event.md +109 -109
- package/src/resources/skills/mandu-hydration/rules/hydration-directive-use-client.md +55 -55
- package/src/resources/skills/mandu-hydration/rules/hydration-island-setup.md +113 -113
- package/src/resources/skills/mandu-hydration/rules/hydration-priority-visible.md +68 -68
- package/src/resources/skills/mandu-performance/SKILL.md +85 -85
- package/src/resources/skills/mandu-performance/metadata.json +14 -14
- package/src/resources/skills/mandu-performance/rules/_sections.md +31 -31
- package/src/resources/skills/mandu-performance/rules/_template.md +64 -64
- package/src/resources/skills/mandu-performance/rules/perf-async-defer-await.md +103 -103
- package/src/resources/skills/mandu-performance/rules/perf-async-parallel.md +95 -95
- package/src/resources/skills/mandu-performance/rules/perf-bun-file.md +124 -124
- package/src/resources/skills/mandu-performance/rules/perf-bun-serve.md +125 -125
- package/src/resources/skills/mandu-performance/rules/perf-bundle-imports.md +80 -80
- package/src/resources/skills/mandu-performance/rules/perf-bundle-island-lazy.md +145 -145
- package/src/resources/skills/mandu-performance/rules/perf-cache-react.md +98 -98
- package/src/resources/skills/mandu-performance/rules/perf-render-transitions.md +154 -154
- package/src/resources/skills/mandu-security/SKILL.md +87 -87
- package/src/resources/skills/mandu-security/metadata.json +13 -13
- package/src/resources/skills/mandu-security/rules/_sections.md +31 -31
- package/src/resources/skills/mandu-security/rules/_template.md +74 -74
- package/src/resources/skills/mandu-security/rules/sec-auth-guard.md +127 -127
- package/src/resources/skills/mandu-security/rules/sec-env-management.md +133 -133
- package/src/resources/skills/mandu-security/rules/sec-input-validate.md +148 -148
- package/src/resources/skills/mandu-security/rules/sec-protect-csrf.md +146 -146
- package/src/resources/skills/mandu-security/rules/sec-protect-headers.md +138 -138
- package/src/resources/skills/mandu-slot/SKILL.md +85 -85
- package/src/resources/skills/mandu-slot/metadata.json +12 -12
- package/src/resources/skills/mandu-slot/rules/_sections.md +36 -36
- package/src/resources/skills/mandu-slot/rules/_template.md +63 -63
- package/src/resources/skills/mandu-slot/rules/slot-basic-structure.md +38 -38
- package/src/resources/skills/mandu-slot/rules/slot-ctx-response.md +56 -56
- package/src/resources/skills/mandu-slot/rules/slot-guard-auth.md +59 -59
- package/src/resources/skills/mandu-slot/rules/slot-http-methods.md +64 -64
- package/src/resources/skills/mandu-styling/SKILL.md +154 -154
- package/src/resources/skills/mandu-styling/_sections.md +43 -43
- package/src/resources/skills/mandu-styling/_template.md +32 -32
- package/src/resources/skills/mandu-styling/metadata.json +15 -15
- package/src/resources/skills/mandu-styling/rules/style-component-compound.md +235 -235
- package/src/resources/skills/mandu-styling/rules/style-component-slots.md +255 -255
- package/src/resources/skills/mandu-styling/rules/style-component-tokens.md +205 -205
- package/src/resources/skills/mandu-styling/rules/style-island-animations.md +272 -272
- package/src/resources/skills/mandu-styling/rules/style-island-scoping.md +167 -167
- package/src/resources/skills/mandu-styling/rules/style-island-variants.md +221 -221
- package/src/resources/skills/mandu-styling/rules/style-perf-critical.md +209 -209
- package/src/resources/skills/mandu-styling/rules/style-perf-purge.md +192 -192
- package/src/resources/skills/mandu-styling/rules/style-setup-modules.md +162 -162
- package/src/resources/skills/mandu-styling/rules/style-setup-panda.md +164 -164
- package/src/resources/skills/mandu-styling/rules/style-setup-tailwind.md +170 -170
- package/src/resources/skills/mandu-styling/rules/style-tailwind-v4-gotchas.md +179 -179
- package/src/resources/skills/mandu-styling/rules/style-theme-darkmode.md +229 -229
- package/src/resources/skills/mandu-testing/SKILL.md +99 -99
- package/src/resources/skills/mandu-testing/metadata.json +13 -13
- package/src/resources/skills/mandu-testing/rules/_sections.md +26 -26
- package/src/resources/skills/mandu-testing/rules/_template.md +65 -65
- package/src/resources/skills/mandu-testing/rules/test-component-island.md +195 -195
- package/src/resources/skills/mandu-testing/rules/test-e2e-playwright.md +196 -196
- package/src/resources/skills/mandu-testing/rules/test-mock-fetch.md +219 -219
- package/src/resources/skills/mandu-testing/rules/test-slot-unit.md +192 -192
- package/src/resources/skills/mandu-ui/SKILL.md +117 -117
- package/src/resources/skills/mandu-ui/_sections.md +23 -23
- package/src/resources/skills/mandu-ui/_template.md +32 -32
- package/src/resources/skills/mandu-ui/metadata.json +13 -13
- package/src/resources/skills/mandu-ui/rules/ui-accessibility-aria.md +232 -232
- package/src/resources/skills/mandu-ui/rules/ui-accessibility-focus.md +238 -238
- package/src/resources/skills/mandu-ui/rules/ui-composition-patterns.md +259 -259
- package/src/resources/skills/mandu-ui/rules/ui-island-integration.md +258 -258
- package/src/resources/skills/mandu-ui/rules/ui-radix-patterns.md +213 -213
- package/src/resources/skills/mandu-ui/rules/ui-shadcn-setup.md +209 -209
- package/src/resources/skills/recipes.ts +932 -932
- package/src/tools/ate.ts +219 -0
- package/src/tools/index.ts +4 -1
- package/src/tools/project.ts +334 -334
- package/src/tools/runtime.ts +497 -497
- package/src/tools/seo.ts +417 -417
- package/src/utils/withWarnings.ts +83 -83
|
@@ -1,272 +1,272 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Island Animations
|
|
3
|
-
impact: HIGH
|
|
4
|
-
impactDescription: Client-side animations for interactive Islands
|
|
5
|
-
tags: styling, island, animations, transitions
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## Island Animations
|
|
9
|
-
|
|
10
|
-
**Impact: HIGH (Client-side animations for interactive Islands)**
|
|
11
|
-
|
|
12
|
-
Island 컴포넌트에서 부드러운 애니메이션을 구현하세요.
|
|
13
|
-
|
|
14
|
-
## Tailwind 애니메이션
|
|
15
|
-
|
|
16
|
-
```typescript
|
|
17
|
-
// tailwind.config.ts
|
|
18
|
-
export default {
|
|
19
|
-
theme: {
|
|
20
|
-
extend: {
|
|
21
|
-
animation: {
|
|
22
|
-
"fade-in": "fadeIn 0.2s ease-out",
|
|
23
|
-
"fade-out": "fadeOut 0.2s ease-out",
|
|
24
|
-
"slide-in": "slideIn 0.3s ease-out",
|
|
25
|
-
"slide-out": "slideOut 0.3s ease-out",
|
|
26
|
-
"scale-in": "scaleIn 0.2s ease-out",
|
|
27
|
-
"spin-slow": "spin 3s linear infinite",
|
|
28
|
-
},
|
|
29
|
-
keyframes: {
|
|
30
|
-
fadeIn: {
|
|
31
|
-
"0%": { opacity: "0" },
|
|
32
|
-
"100%": { opacity: "1" },
|
|
33
|
-
},
|
|
34
|
-
fadeOut: {
|
|
35
|
-
"0%": { opacity: "1" },
|
|
36
|
-
"100%": { opacity: "0" },
|
|
37
|
-
},
|
|
38
|
-
slideIn: {
|
|
39
|
-
"0%": { transform: "translateY(-10px)", opacity: "0" },
|
|
40
|
-
"100%": { transform: "translateY(0)", opacity: "1" },
|
|
41
|
-
},
|
|
42
|
-
slideOut: {
|
|
43
|
-
"0%": { transform: "translateY(0)", opacity: "1" },
|
|
44
|
-
"100%": { transform: "translateY(-10px)", opacity: "0" },
|
|
45
|
-
},
|
|
46
|
-
scaleIn: {
|
|
47
|
-
"0%": { transform: "scale(0.95)", opacity: "0" },
|
|
48
|
-
"100%": { transform: "scale(1)", opacity: "1" },
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
},
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## 조건부 애니메이션
|
|
57
|
-
|
|
58
|
-
```tsx
|
|
59
|
-
// app/dropdown/client.tsx
|
|
60
|
-
"use client";
|
|
61
|
-
|
|
62
|
-
import { useState } from "react";
|
|
63
|
-
import { cn } from "@/lib/utils";
|
|
64
|
-
|
|
65
|
-
export function DropdownIsland() {
|
|
66
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
67
|
-
|
|
68
|
-
return (
|
|
69
|
-
<div className="relative">
|
|
70
|
-
<button onClick={() => setIsOpen(!isOpen)}>
|
|
71
|
-
Toggle
|
|
72
|
-
</button>
|
|
73
|
-
|
|
74
|
-
<div
|
|
75
|
-
className={cn(
|
|
76
|
-
"absolute top-full mt-2 w-48 rounded-md bg-white shadow-lg",
|
|
77
|
-
"transition-all duration-200",
|
|
78
|
-
isOpen
|
|
79
|
-
? "animate-fade-in opacity-100 translate-y-0"
|
|
80
|
-
: "opacity-0 -translate-y-2 pointer-events-none"
|
|
81
|
-
)}
|
|
82
|
-
>
|
|
83
|
-
<ul className="py-2">
|
|
84
|
-
<li className="px-4 py-2 hover:bg-gray-100">Option 1</li>
|
|
85
|
-
<li className="px-4 py-2 hover:bg-gray-100">Option 2</li>
|
|
86
|
-
</ul>
|
|
87
|
-
</div>
|
|
88
|
-
</div>
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
## CSS Transition 패턴
|
|
94
|
-
|
|
95
|
-
```tsx
|
|
96
|
-
// app/accordion/client.tsx
|
|
97
|
-
"use client";
|
|
98
|
-
|
|
99
|
-
import { useState, useRef, useEffect } from "react";
|
|
100
|
-
|
|
101
|
-
export function AccordionIsland({ title, children }) {
|
|
102
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
103
|
-
const contentRef = useRef<HTMLDivElement>(null);
|
|
104
|
-
const [height, setHeight] = useState(0);
|
|
105
|
-
|
|
106
|
-
useEffect(() => {
|
|
107
|
-
if (contentRef.current) {
|
|
108
|
-
setHeight(isOpen ? contentRef.current.scrollHeight : 0);
|
|
109
|
-
}
|
|
110
|
-
}, [isOpen]);
|
|
111
|
-
|
|
112
|
-
return (
|
|
113
|
-
<div className="border-b">
|
|
114
|
-
<button
|
|
115
|
-
className="flex w-full items-center justify-between py-4"
|
|
116
|
-
onClick={() => setIsOpen(!isOpen)}
|
|
117
|
-
>
|
|
118
|
-
<span>{title}</span>
|
|
119
|
-
<span
|
|
120
|
-
className={cn(
|
|
121
|
-
"transition-transform duration-200",
|
|
122
|
-
isOpen && "rotate-180"
|
|
123
|
-
)}
|
|
124
|
-
>
|
|
125
|
-
▼
|
|
126
|
-
</span>
|
|
127
|
-
</button>
|
|
128
|
-
|
|
129
|
-
<div
|
|
130
|
-
style={{ height }}
|
|
131
|
-
className="overflow-hidden transition-[height] duration-200 ease-out"
|
|
132
|
-
>
|
|
133
|
-
<div ref={contentRef} className="pb-4">
|
|
134
|
-
{children}
|
|
135
|
-
</div>
|
|
136
|
-
</div>
|
|
137
|
-
</div>
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
## Loading States
|
|
143
|
-
|
|
144
|
-
```tsx
|
|
145
|
-
// app/button/client.tsx
|
|
146
|
-
"use client";
|
|
147
|
-
|
|
148
|
-
export function LoadingButtonIsland({ loading, children, ...props }) {
|
|
149
|
-
return (
|
|
150
|
-
<button
|
|
151
|
-
disabled={loading}
|
|
152
|
-
className={cn(
|
|
153
|
-
"relative inline-flex items-center justify-center",
|
|
154
|
-
loading && "cursor-wait"
|
|
155
|
-
)}
|
|
156
|
-
{...props}
|
|
157
|
-
>
|
|
158
|
-
{loading && (
|
|
159
|
-
<span className="absolute inset-0 flex items-center justify-center">
|
|
160
|
-
<svg
|
|
161
|
-
className="h-5 w-5 animate-spin text-current"
|
|
162
|
-
fill="none"
|
|
163
|
-
viewBox="0 0 24 24"
|
|
164
|
-
>
|
|
165
|
-
<circle
|
|
166
|
-
className="opacity-25"
|
|
167
|
-
cx="12"
|
|
168
|
-
cy="12"
|
|
169
|
-
r="10"
|
|
170
|
-
stroke="currentColor"
|
|
171
|
-
strokeWidth="4"
|
|
172
|
-
/>
|
|
173
|
-
<path
|
|
174
|
-
className="opacity-75"
|
|
175
|
-
fill="currentColor"
|
|
176
|
-
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
|
|
177
|
-
/>
|
|
178
|
-
</svg>
|
|
179
|
-
</span>
|
|
180
|
-
)}
|
|
181
|
-
<span className={cn(loading && "invisible")}>{children}</span>
|
|
182
|
-
</button>
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
## Skeleton Loading
|
|
188
|
-
|
|
189
|
-
```tsx
|
|
190
|
-
// components/skeleton.tsx
|
|
191
|
-
export function Skeleton({ className, ...props }) {
|
|
192
|
-
return (
|
|
193
|
-
<div
|
|
194
|
-
className={cn(
|
|
195
|
-
"animate-pulse rounded-md bg-gray-200 dark:bg-gray-700",
|
|
196
|
-
className
|
|
197
|
-
)}
|
|
198
|
-
{...props}
|
|
199
|
-
/>
|
|
200
|
-
);
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// 사용
|
|
204
|
-
<div className="space-y-2">
|
|
205
|
-
<Skeleton className="h-4 w-3/4" />
|
|
206
|
-
<Skeleton className="h-4 w-1/2" />
|
|
207
|
-
</div>
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
## Page Transitions (View Transitions API)
|
|
211
|
-
|
|
212
|
-
```tsx
|
|
213
|
-
// app/layout.tsx
|
|
214
|
-
export default function Layout({ children }) {
|
|
215
|
-
return (
|
|
216
|
-
<html>
|
|
217
|
-
<body>
|
|
218
|
-
<div className="[view-transition-name:main]">
|
|
219
|
-
{children}
|
|
220
|
-
</div>
|
|
221
|
-
</body>
|
|
222
|
-
</html>
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
```css
|
|
228
|
-
/* globals.css */
|
|
229
|
-
@media (prefers-reduced-motion: no-preference) {
|
|
230
|
-
::view-transition-old(main),
|
|
231
|
-
::view-transition-new(main) {
|
|
232
|
-
animation-duration: 0.3s;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
::view-transition-old(main) {
|
|
236
|
-
animation-name: fadeOut;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
::view-transition-new(main) {
|
|
240
|
-
animation-name: fadeIn;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
## 접근성: Reduced Motion
|
|
246
|
-
|
|
247
|
-
```tsx
|
|
248
|
-
// hooks/useReducedMotion.ts
|
|
249
|
-
export function useReducedMotion() {
|
|
250
|
-
const [prefersReduced, setPrefersReduced] = useState(false);
|
|
251
|
-
|
|
252
|
-
useEffect(() => {
|
|
253
|
-
const mq = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
254
|
-
setPrefersReduced(mq.matches);
|
|
255
|
-
|
|
256
|
-
const handler = (e: MediaQueryListEvent) => setPrefersReduced(e.matches);
|
|
257
|
-
mq.addEventListener("change", handler);
|
|
258
|
-
return () => mq.removeEventListener("change", handler);
|
|
259
|
-
}, []);
|
|
260
|
-
|
|
261
|
-
return prefersReduced;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// 사용
|
|
265
|
-
const reducedMotion = useReducedMotion();
|
|
266
|
-
|
|
267
|
-
<div className={cn(
|
|
268
|
-
!reducedMotion && "animate-fade-in"
|
|
269
|
-
)}>
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
Reference: [Tailwind Animation](https://tailwindcss.com/docs/animation)
|
|
1
|
+
---
|
|
2
|
+
title: Island Animations
|
|
3
|
+
impact: HIGH
|
|
4
|
+
impactDescription: Client-side animations for interactive Islands
|
|
5
|
+
tags: styling, island, animations, transitions
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Island Animations
|
|
9
|
+
|
|
10
|
+
**Impact: HIGH (Client-side animations for interactive Islands)**
|
|
11
|
+
|
|
12
|
+
Island 컴포넌트에서 부드러운 애니메이션을 구현하세요.
|
|
13
|
+
|
|
14
|
+
## Tailwind 애니메이션
|
|
15
|
+
|
|
16
|
+
```typescript
|
|
17
|
+
// tailwind.config.ts
|
|
18
|
+
export default {
|
|
19
|
+
theme: {
|
|
20
|
+
extend: {
|
|
21
|
+
animation: {
|
|
22
|
+
"fade-in": "fadeIn 0.2s ease-out",
|
|
23
|
+
"fade-out": "fadeOut 0.2s ease-out",
|
|
24
|
+
"slide-in": "slideIn 0.3s ease-out",
|
|
25
|
+
"slide-out": "slideOut 0.3s ease-out",
|
|
26
|
+
"scale-in": "scaleIn 0.2s ease-out",
|
|
27
|
+
"spin-slow": "spin 3s linear infinite",
|
|
28
|
+
},
|
|
29
|
+
keyframes: {
|
|
30
|
+
fadeIn: {
|
|
31
|
+
"0%": { opacity: "0" },
|
|
32
|
+
"100%": { opacity: "1" },
|
|
33
|
+
},
|
|
34
|
+
fadeOut: {
|
|
35
|
+
"0%": { opacity: "1" },
|
|
36
|
+
"100%": { opacity: "0" },
|
|
37
|
+
},
|
|
38
|
+
slideIn: {
|
|
39
|
+
"0%": { transform: "translateY(-10px)", opacity: "0" },
|
|
40
|
+
"100%": { transform: "translateY(0)", opacity: "1" },
|
|
41
|
+
},
|
|
42
|
+
slideOut: {
|
|
43
|
+
"0%": { transform: "translateY(0)", opacity: "1" },
|
|
44
|
+
"100%": { transform: "translateY(-10px)", opacity: "0" },
|
|
45
|
+
},
|
|
46
|
+
scaleIn: {
|
|
47
|
+
"0%": { transform: "scale(0.95)", opacity: "0" },
|
|
48
|
+
"100%": { transform: "scale(1)", opacity: "1" },
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## 조건부 애니메이션
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
// app/dropdown/client.tsx
|
|
60
|
+
"use client";
|
|
61
|
+
|
|
62
|
+
import { useState } from "react";
|
|
63
|
+
import { cn } from "@/lib/utils";
|
|
64
|
+
|
|
65
|
+
export function DropdownIsland() {
|
|
66
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<div className="relative">
|
|
70
|
+
<button onClick={() => setIsOpen(!isOpen)}>
|
|
71
|
+
Toggle
|
|
72
|
+
</button>
|
|
73
|
+
|
|
74
|
+
<div
|
|
75
|
+
className={cn(
|
|
76
|
+
"absolute top-full mt-2 w-48 rounded-md bg-white shadow-lg",
|
|
77
|
+
"transition-all duration-200",
|
|
78
|
+
isOpen
|
|
79
|
+
? "animate-fade-in opacity-100 translate-y-0"
|
|
80
|
+
: "opacity-0 -translate-y-2 pointer-events-none"
|
|
81
|
+
)}
|
|
82
|
+
>
|
|
83
|
+
<ul className="py-2">
|
|
84
|
+
<li className="px-4 py-2 hover:bg-gray-100">Option 1</li>
|
|
85
|
+
<li className="px-4 py-2 hover:bg-gray-100">Option 2</li>
|
|
86
|
+
</ul>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## CSS Transition 패턴
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
// app/accordion/client.tsx
|
|
97
|
+
"use client";
|
|
98
|
+
|
|
99
|
+
import { useState, useRef, useEffect } from "react";
|
|
100
|
+
|
|
101
|
+
export function AccordionIsland({ title, children }) {
|
|
102
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
103
|
+
const contentRef = useRef<HTMLDivElement>(null);
|
|
104
|
+
const [height, setHeight] = useState(0);
|
|
105
|
+
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
if (contentRef.current) {
|
|
108
|
+
setHeight(isOpen ? contentRef.current.scrollHeight : 0);
|
|
109
|
+
}
|
|
110
|
+
}, [isOpen]);
|
|
111
|
+
|
|
112
|
+
return (
|
|
113
|
+
<div className="border-b">
|
|
114
|
+
<button
|
|
115
|
+
className="flex w-full items-center justify-between py-4"
|
|
116
|
+
onClick={() => setIsOpen(!isOpen)}
|
|
117
|
+
>
|
|
118
|
+
<span>{title}</span>
|
|
119
|
+
<span
|
|
120
|
+
className={cn(
|
|
121
|
+
"transition-transform duration-200",
|
|
122
|
+
isOpen && "rotate-180"
|
|
123
|
+
)}
|
|
124
|
+
>
|
|
125
|
+
▼
|
|
126
|
+
</span>
|
|
127
|
+
</button>
|
|
128
|
+
|
|
129
|
+
<div
|
|
130
|
+
style={{ height }}
|
|
131
|
+
className="overflow-hidden transition-[height] duration-200 ease-out"
|
|
132
|
+
>
|
|
133
|
+
<div ref={contentRef} className="pb-4">
|
|
134
|
+
{children}
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
</div>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Loading States
|
|
143
|
+
|
|
144
|
+
```tsx
|
|
145
|
+
// app/button/client.tsx
|
|
146
|
+
"use client";
|
|
147
|
+
|
|
148
|
+
export function LoadingButtonIsland({ loading, children, ...props }) {
|
|
149
|
+
return (
|
|
150
|
+
<button
|
|
151
|
+
disabled={loading}
|
|
152
|
+
className={cn(
|
|
153
|
+
"relative inline-flex items-center justify-center",
|
|
154
|
+
loading && "cursor-wait"
|
|
155
|
+
)}
|
|
156
|
+
{...props}
|
|
157
|
+
>
|
|
158
|
+
{loading && (
|
|
159
|
+
<span className="absolute inset-0 flex items-center justify-center">
|
|
160
|
+
<svg
|
|
161
|
+
className="h-5 w-5 animate-spin text-current"
|
|
162
|
+
fill="none"
|
|
163
|
+
viewBox="0 0 24 24"
|
|
164
|
+
>
|
|
165
|
+
<circle
|
|
166
|
+
className="opacity-25"
|
|
167
|
+
cx="12"
|
|
168
|
+
cy="12"
|
|
169
|
+
r="10"
|
|
170
|
+
stroke="currentColor"
|
|
171
|
+
strokeWidth="4"
|
|
172
|
+
/>
|
|
173
|
+
<path
|
|
174
|
+
className="opacity-75"
|
|
175
|
+
fill="currentColor"
|
|
176
|
+
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
|
|
177
|
+
/>
|
|
178
|
+
</svg>
|
|
179
|
+
</span>
|
|
180
|
+
)}
|
|
181
|
+
<span className={cn(loading && "invisible")}>{children}</span>
|
|
182
|
+
</button>
|
|
183
|
+
);
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Skeleton Loading
|
|
188
|
+
|
|
189
|
+
```tsx
|
|
190
|
+
// components/skeleton.tsx
|
|
191
|
+
export function Skeleton({ className, ...props }) {
|
|
192
|
+
return (
|
|
193
|
+
<div
|
|
194
|
+
className={cn(
|
|
195
|
+
"animate-pulse rounded-md bg-gray-200 dark:bg-gray-700",
|
|
196
|
+
className
|
|
197
|
+
)}
|
|
198
|
+
{...props}
|
|
199
|
+
/>
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// 사용
|
|
204
|
+
<div className="space-y-2">
|
|
205
|
+
<Skeleton className="h-4 w-3/4" />
|
|
206
|
+
<Skeleton className="h-4 w-1/2" />
|
|
207
|
+
</div>
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Page Transitions (View Transitions API)
|
|
211
|
+
|
|
212
|
+
```tsx
|
|
213
|
+
// app/layout.tsx
|
|
214
|
+
export default function Layout({ children }) {
|
|
215
|
+
return (
|
|
216
|
+
<html>
|
|
217
|
+
<body>
|
|
218
|
+
<div className="[view-transition-name:main]">
|
|
219
|
+
{children}
|
|
220
|
+
</div>
|
|
221
|
+
</body>
|
|
222
|
+
</html>
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
```css
|
|
228
|
+
/* globals.css */
|
|
229
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
230
|
+
::view-transition-old(main),
|
|
231
|
+
::view-transition-new(main) {
|
|
232
|
+
animation-duration: 0.3s;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
::view-transition-old(main) {
|
|
236
|
+
animation-name: fadeOut;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
::view-transition-new(main) {
|
|
240
|
+
animation-name: fadeIn;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## 접근성: Reduced Motion
|
|
246
|
+
|
|
247
|
+
```tsx
|
|
248
|
+
// hooks/useReducedMotion.ts
|
|
249
|
+
export function useReducedMotion() {
|
|
250
|
+
const [prefersReduced, setPrefersReduced] = useState(false);
|
|
251
|
+
|
|
252
|
+
useEffect(() => {
|
|
253
|
+
const mq = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
254
|
+
setPrefersReduced(mq.matches);
|
|
255
|
+
|
|
256
|
+
const handler = (e: MediaQueryListEvent) => setPrefersReduced(e.matches);
|
|
257
|
+
mq.addEventListener("change", handler);
|
|
258
|
+
return () => mq.removeEventListener("change", handler);
|
|
259
|
+
}, []);
|
|
260
|
+
|
|
261
|
+
return prefersReduced;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
// 사용
|
|
265
|
+
const reducedMotion = useReducedMotion();
|
|
266
|
+
|
|
267
|
+
<div className={cn(
|
|
268
|
+
!reducedMotion && "animate-fade-in"
|
|
269
|
+
)}>
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
Reference: [Tailwind Animation](https://tailwindcss.com/docs/animation)
|