@mandujs/mcp 0.38.12 → 0.39.0-beta.1

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.
Files changed (183) hide show
  1. package/README.md +3 -3
  2. package/package.json +3 -5
  3. package/src/activity-adapter.ts +23 -23
  4. package/src/activity-monitor.ts +39 -10
  5. package/src/adapters/index.ts +20 -20
  6. package/src/adapters/monitor-adapter.ts +100 -100
  7. package/src/adapters/tool-adapter.ts +90 -90
  8. package/src/executor/index.ts +22 -22
  9. package/src/executor/tool-executor.ts +148 -148
  10. package/src/hooks/config-watcher.ts +173 -173
  11. package/src/hooks/index.ts +23 -23
  12. package/src/hooks/mcp-hooks.ts +227 -227
  13. package/src/index.ts +5 -5
  14. package/src/logging/index.ts +15 -15
  15. package/src/logging/mcp-transport.ts +134 -134
  16. package/src/new-resources.ts +2 -2
  17. package/src/profiles.ts +25 -54
  18. package/src/prompts.ts +4 -4
  19. package/src/registry/index.ts +13 -13
  20. package/src/registry/mcp-tool-registry.ts +298 -298
  21. package/src/resources/generated-skills/catalog.ts +36 -0
  22. package/src/resources/generated-skills/mandu-agent-workflow/SKILL.md +48 -0
  23. package/src/resources/generated-skills/mandu-contract/SKILL.md +20 -0
  24. package/src/resources/generated-skills/mandu-fs-routes/SKILL.md +19 -0
  25. package/src/resources/generated-skills/mandu-guard/SKILL.md +20 -0
  26. package/src/resources/generated-skills/mandu-hydration/SKILL.md +19 -0
  27. package/src/resources/generated-skills/mandu-testing/SKILL.md +20 -0
  28. package/src/resources/handlers.ts +3 -3
  29. package/src/resources/skills/guides.ts +49 -49
  30. package/src/resources/skills/index.ts +12 -12
  31. package/src/resources/skills/loader.ts +8 -35
  32. package/src/resources/skills/recipes.ts +28 -28
  33. package/src/server.ts +1 -1
  34. package/src/tools/agent.ts +479 -409
  35. package/src/tools/ate-exemplar.ts +92 -92
  36. package/src/tools/ate-flakes.ts +90 -90
  37. package/src/tools/ate-mutate.ts +103 -103
  38. package/src/tools/ate-mutation-report.ts +64 -64
  39. package/src/tools/ate-oracle-pending.ts +49 -49
  40. package/src/tools/ate-oracle-replay.ts +44 -44
  41. package/src/tools/ate-oracle-verdict.ts +70 -70
  42. package/src/tools/ate-prompt.ts +146 -146
  43. package/src/tools/ate-run.ts +1 -1
  44. package/src/tools/ate.ts +38 -38
  45. package/src/tools/brain.ts +6 -6
  46. package/src/tools/composite.ts +19 -61
  47. package/src/tools/contract.ts +11 -9
  48. package/src/tools/deploy-plan.ts +2 -2
  49. package/src/tools/deploy-preview.ts +316 -316
  50. package/src/tools/design.ts +825 -825
  51. package/src/tools/docs.ts +350 -350
  52. package/src/tools/generate.ts +4 -3
  53. package/src/tools/guard.ts +1 -1
  54. package/src/tools/history.ts +1 -1
  55. package/src/tools/hydration.ts +64 -64
  56. package/src/tools/index.ts +0 -118
  57. package/src/tools/kitchen.ts +72 -72
  58. package/src/tools/lint.ts +226 -226
  59. package/src/tools/loop-close.ts +175 -175
  60. package/src/tools/negotiate.ts +263 -263
  61. package/src/tools/resource.ts +1 -1
  62. package/src/tools/run-tests.ts +424 -424
  63. package/src/tools/runtime.ts +1 -1
  64. package/src/tools/seo.ts +1 -1
  65. package/src/tools/slot-validation.ts +19 -19
  66. package/src/tools/spec.ts +201 -201
  67. package/src/tools/transaction.ts +1 -1
  68. package/src/tx-lock.ts +73 -73
  69. package/src/utils/runtime-control.ts +52 -52
  70. package/src/utils/withWarnings.ts +1 -1
  71. package/src/resources/skills/mandu-agent-workflow/SKILL.md +0 -124
  72. package/src/resources/skills/mandu-agent-workflow/metadata.json +0 -7
  73. package/src/resources/skills/mandu-composition/SKILL.md +0 -131
  74. package/src/resources/skills/mandu-composition/metadata.json +0 -13
  75. package/src/resources/skills/mandu-composition/rules/_sections.md +0 -26
  76. package/src/resources/skills/mandu-composition/rules/_template.md +0 -77
  77. package/src/resources/skills/mandu-composition/rules/comp-arch-avoid-boolean-props.md +0 -146
  78. package/src/resources/skills/mandu-composition/rules/comp-arch-compound-components.md +0 -164
  79. package/src/resources/skills/mandu-composition/rules/comp-island-event.md +0 -161
  80. package/src/resources/skills/mandu-composition/rules/comp-island-slot-split.md +0 -167
  81. package/src/resources/skills/mandu-composition/rules/comp-pattern-children.md +0 -149
  82. package/src/resources/skills/mandu-composition/rules/comp-state-context-interface.md +0 -148
  83. package/src/resources/skills/mandu-composition/rules/comp-state-lift-state.md +0 -150
  84. package/src/resources/skills/mandu-deployment/SKILL.md +0 -135
  85. package/src/resources/skills/mandu-deployment/_sections.md +0 -41
  86. package/src/resources/skills/mandu-deployment/_template.md +0 -38
  87. package/src/resources/skills/mandu-deployment/metadata.json +0 -13
  88. package/src/resources/skills/mandu-deployment/rules/db-provider-supabase.md +0 -300
  89. package/src/resources/skills/mandu-deployment/rules/deploy-build-bun.md +0 -109
  90. package/src/resources/skills/mandu-deployment/rules/deploy-build-output.md +0 -115
  91. package/src/resources/skills/mandu-deployment/rules/deploy-cicd-github.md +0 -219
  92. package/src/resources/skills/mandu-deployment/rules/deploy-docker-bun.md +0 -150
  93. package/src/resources/skills/mandu-deployment/rules/deploy-docker-compose.md +0 -223
  94. package/src/resources/skills/mandu-deployment/rules/deploy-platform-fly.md +0 -152
  95. package/src/resources/skills/mandu-deployment/rules/deploy-platform-render.md +0 -179
  96. package/src/resources/skills/mandu-deployment/rules/deploy-platform-vercel.md +0 -140
  97. package/src/resources/skills/mandu-fs-routes/SKILL.md +0 -122
  98. package/src/resources/skills/mandu-fs-routes/metadata.json +0 -12
  99. package/src/resources/skills/mandu-fs-routes/rules/_sections.md +0 -36
  100. package/src/resources/skills/mandu-fs-routes/rules/_template.md +0 -69
  101. package/src/resources/skills/mandu-fs-routes/rules/routes-api-methods.md +0 -65
  102. package/src/resources/skills/mandu-fs-routes/rules/routes-dynamic-param.md +0 -93
  103. package/src/resources/skills/mandu-fs-routes/rules/routes-naming-page.md +0 -55
  104. package/src/resources/skills/mandu-guard/SKILL.md +0 -162
  105. package/src/resources/skills/mandu-guard/metadata.json +0 -12
  106. package/src/resources/skills/mandu-guard/rules/_sections.md +0 -36
  107. package/src/resources/skills/mandu-guard/rules/_template.md +0 -82
  108. package/src/resources/skills/mandu-guard/rules/guard-config-rules.md +0 -100
  109. package/src/resources/skills/mandu-guard/rules/guard-layer-direction.md +0 -76
  110. package/src/resources/skills/mandu-guard/rules/guard-preset-mandu.md +0 -81
  111. package/src/resources/skills/mandu-guard/rules/guard-validate-import.md +0 -80
  112. package/src/resources/skills/mandu-hydration/SKILL.md +0 -139
  113. package/src/resources/skills/mandu-hydration/metadata.json +0 -12
  114. package/src/resources/skills/mandu-hydration/rules/_sections.md +0 -31
  115. package/src/resources/skills/mandu-hydration/rules/_template.md +0 -72
  116. package/src/resources/skills/mandu-hydration/rules/hydration-data-event.md +0 -109
  117. package/src/resources/skills/mandu-hydration/rules/hydration-directive-use-client.md +0 -55
  118. package/src/resources/skills/mandu-hydration/rules/hydration-island-setup.md +0 -160
  119. package/src/resources/skills/mandu-hydration/rules/hydration-priority-visible.md +0 -91
  120. package/src/resources/skills/mandu-performance/SKILL.md +0 -125
  121. package/src/resources/skills/mandu-performance/metadata.json +0 -14
  122. package/src/resources/skills/mandu-performance/rules/_sections.md +0 -31
  123. package/src/resources/skills/mandu-performance/rules/_template.md +0 -64
  124. package/src/resources/skills/mandu-performance/rules/perf-async-defer-await.md +0 -103
  125. package/src/resources/skills/mandu-performance/rules/perf-async-parallel.md +0 -95
  126. package/src/resources/skills/mandu-performance/rules/perf-bun-file.md +0 -124
  127. package/src/resources/skills/mandu-performance/rules/perf-bun-serve.md +0 -125
  128. package/src/resources/skills/mandu-performance/rules/perf-bundle-imports.md +0 -80
  129. package/src/resources/skills/mandu-performance/rules/perf-bundle-island-lazy.md +0 -145
  130. package/src/resources/skills/mandu-performance/rules/perf-cache-react.md +0 -98
  131. package/src/resources/skills/mandu-performance/rules/perf-render-transitions.md +0 -154
  132. package/src/resources/skills/mandu-security/SKILL.md +0 -127
  133. package/src/resources/skills/mandu-security/metadata.json +0 -13
  134. package/src/resources/skills/mandu-security/rules/_sections.md +0 -31
  135. package/src/resources/skills/mandu-security/rules/_template.md +0 -74
  136. package/src/resources/skills/mandu-security/rules/sec-auth-guard.md +0 -127
  137. package/src/resources/skills/mandu-security/rules/sec-env-management.md +0 -133
  138. package/src/resources/skills/mandu-security/rules/sec-input-validate.md +0 -148
  139. package/src/resources/skills/mandu-security/rules/sec-protect-csrf.md +0 -146
  140. package/src/resources/skills/mandu-security/rules/sec-protect-headers.md +0 -138
  141. package/src/resources/skills/mandu-slot/SKILL.md +0 -125
  142. package/src/resources/skills/mandu-slot/metadata.json +0 -12
  143. package/src/resources/skills/mandu-slot/rules/_sections.md +0 -36
  144. package/src/resources/skills/mandu-slot/rules/_template.md +0 -63
  145. package/src/resources/skills/mandu-slot/rules/slot-basic-structure.md +0 -38
  146. package/src/resources/skills/mandu-slot/rules/slot-ctx-response.md +0 -56
  147. package/src/resources/skills/mandu-slot/rules/slot-guard-auth.md +0 -59
  148. package/src/resources/skills/mandu-slot/rules/slot-http-methods.md +0 -64
  149. package/src/resources/skills/mandu-styling/SKILL.md +0 -196
  150. package/src/resources/skills/mandu-styling/_sections.md +0 -43
  151. package/src/resources/skills/mandu-styling/_template.md +0 -32
  152. package/src/resources/skills/mandu-styling/metadata.json +0 -15
  153. package/src/resources/skills/mandu-styling/rules/style-component-compound.md +0 -235
  154. package/src/resources/skills/mandu-styling/rules/style-component-slots.md +0 -255
  155. package/src/resources/skills/mandu-styling/rules/style-component-tokens.md +0 -205
  156. package/src/resources/skills/mandu-styling/rules/style-island-animations.md +0 -272
  157. package/src/resources/skills/mandu-styling/rules/style-island-scoping.md +0 -167
  158. package/src/resources/skills/mandu-styling/rules/style-island-variants.md +0 -221
  159. package/src/resources/skills/mandu-styling/rules/style-perf-critical.md +0 -209
  160. package/src/resources/skills/mandu-styling/rules/style-perf-purge.md +0 -192
  161. package/src/resources/skills/mandu-styling/rules/style-setup-modules.md +0 -162
  162. package/src/resources/skills/mandu-styling/rules/style-setup-panda.md +0 -164
  163. package/src/resources/skills/mandu-styling/rules/style-setup-tailwind.md +0 -170
  164. package/src/resources/skills/mandu-styling/rules/style-tailwind-v4-gotchas.md +0 -179
  165. package/src/resources/skills/mandu-styling/rules/style-theme-darkmode.md +0 -229
  166. package/src/resources/skills/mandu-testing/SKILL.md +0 -132
  167. package/src/resources/skills/mandu-testing/metadata.json +0 -13
  168. package/src/resources/skills/mandu-testing/rules/_sections.md +0 -26
  169. package/src/resources/skills/mandu-testing/rules/_template.md +0 -65
  170. package/src/resources/skills/mandu-testing/rules/test-component-island.md +0 -195
  171. package/src/resources/skills/mandu-testing/rules/test-e2e-playwright.md +0 -196
  172. package/src/resources/skills/mandu-testing/rules/test-mock-fetch.md +0 -219
  173. package/src/resources/skills/mandu-testing/rules/test-slot-unit.md +0 -192
  174. package/src/resources/skills/mandu-ui/SKILL.md +0 -159
  175. package/src/resources/skills/mandu-ui/_sections.md +0 -23
  176. package/src/resources/skills/mandu-ui/_template.md +0 -32
  177. package/src/resources/skills/mandu-ui/metadata.json +0 -13
  178. package/src/resources/skills/mandu-ui/rules/ui-accessibility-aria.md +0 -232
  179. package/src/resources/skills/mandu-ui/rules/ui-accessibility-focus.md +0 -238
  180. package/src/resources/skills/mandu-ui/rules/ui-composition-patterns.md +0 -259
  181. package/src/resources/skills/mandu-ui/rules/ui-island-integration.md +0 -258
  182. package/src/resources/skills/mandu-ui/rules/ui-radix-patterns.md +0 -213
  183. package/src/resources/skills/mandu-ui/rules/ui-shadcn-setup.md +0 -209
@@ -1,272 +0,0 @@
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,167 +0,0 @@
1
- ---
2
- title: Island Style Scoping
3
- impact: HIGH
4
- impactDescription: Prevents style conflicts between independent Islands
5
- tags: styling, island, scoping, isolation
6
- ---
7
-
8
- ## Island Style Scoping
9
-
10
- **Impact: HIGH (Prevents style conflicts between independent Islands)**
11
-
12
- Island는 독립적으로 hydrate되므로 스타일 충돌을 방지해야 합니다.
13
-
14
- **문제 상황:**
15
-
16
- ```tsx
17
- // ❌ 전역 클래스 충돌 가능
18
- <div className="card">...</div> // Island A
19
- <div className="card">...</div> // Island B - 다른 스타일 의도
20
- ```
21
-
22
- ## 해결 방법 1: data-island 속성
23
-
24
- ```tsx
25
- // app/counter/client.tsx
26
- "use client";
27
-
28
- export function CounterIsland() {
29
- return (
30
- <div
31
- data-island="counter"
32
- className="p-4 rounded-lg bg-blue-500"
33
- >
34
- <button className="[&[data-island=counter]_&]:text-white">
35
- Count
36
- </button>
37
- </div>
38
- );
39
- }
40
- ```
41
-
42
- ```css
43
- /* Tailwind 커스텀 variant */
44
- [data-island="counter"] {
45
- /* Island 특화 스타일 */
46
- }
47
- ```
48
-
49
- ## 해결 방법 2: CSS Modules (권장)
50
-
51
- ```tsx
52
- // app/counter/client.tsx
53
- "use client";
54
-
55
- import styles from "./counter.module.css";
56
-
57
- export function CounterIsland() {
58
- return (
59
- <div className={styles.container}>
60
- <button className={styles.button}>Count</button>
61
- </div>
62
- );
63
- }
64
- ```
65
-
66
- ```css
67
- /* app/counter/counter.module.css */
68
- .container {
69
- @apply p-4 rounded-lg bg-blue-500;
70
- }
71
-
72
- .button {
73
- @apply text-white font-medium;
74
- }
75
- ```
76
-
77
- ## 해결 방법 3: Tailwind Prefix
78
-
79
- ```typescript
80
- // tailwind.config.ts
81
- export default {
82
- prefix: "", // 전역은 prefix 없음
83
- // 또는 Island별 prefix
84
- };
85
- ```
86
-
87
- ```tsx
88
- // 컴포넌트별 네임스페이스
89
- const ns = "counter";
90
-
91
- export function CounterIsland() {
92
- return (
93
- <div className={`${ns}-container p-4`}>
94
- <button className={`${ns}-btn`}>Count</button>
95
- </div>
96
- );
97
- }
98
- ```
99
-
100
- ## 해결 방법 4: CSS Layers
101
-
102
- ```css
103
- /* app/globals.css */
104
- @layer components {
105
- .island-counter {
106
- @apply p-4 rounded-lg;
107
- }
108
- }
109
-
110
- @layer islands.counter {
111
- .container {
112
- @apply bg-blue-500;
113
- }
114
- }
115
-
116
- @layer islands.form {
117
- .container {
118
- @apply bg-green-500;
119
- }
120
- }
121
- ```
122
-
123
- ## Best Practice: Compound + Module 조합
124
-
125
- ```tsx
126
- // app/card/client.tsx
127
- "use client";
128
-
129
- import { cn } from "@/lib/utils";
130
- import styles from "./card.module.css";
131
-
132
- export const Card = {
133
- Root: ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
134
- <div className={cn(styles.root, className)} {...props} />
135
- ),
136
- Header: ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
137
- <div className={cn(styles.header, className)} {...props} />
138
- ),
139
- Content: ({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) => (
140
- <div className={cn(styles.content, className)} {...props} />
141
- ),
142
- };
143
- ```
144
-
145
- ```css
146
- /* app/card/card.module.css */
147
- .root {
148
- @apply rounded-lg border bg-white shadow-sm;
149
- }
150
-
151
- .header {
152
- @apply px-6 py-4 border-b;
153
- }
154
-
155
- .content {
156
- @apply px-6 py-4;
157
- }
158
- ```
159
-
160
- ## 스타일 충돌 체크리스트
161
-
162
- - [ ] 전역 클래스명 사용 금지 (`.card`, `.button` 등)
163
- - [ ] CSS Modules 또는 data-island 속성 사용
164
- - [ ] cn() 함수로 클래스 병합 시 순서 주의
165
- - [ ] 다크모드 변수는 :root에 정의
166
-
167
- Reference: [Tailwind CSS Scoping](https://tailwindcss.com/docs/adding-custom-styles)
@@ -1,221 +0,0 @@
1
- ---
2
- title: Island Style Variants
3
- impact: HIGH
4
- impactDescription: Conditional styling patterns for Island components
5
- tags: styling, island, variants, cva
6
- ---
7
-
8
- ## Island Style Variants
9
-
10
- **Impact: HIGH (Conditional styling patterns for Island components)**
11
-
12
- Island 컴포넌트의 조건부 스타일링을 체계적으로 관리하세요.
13
-
14
- **class-variance-authority (cva) 설치:**
15
-
16
- ```bash
17
- bun add class-variance-authority
18
- ```
19
-
20
- ## cva 기본 패턴
21
-
22
- ```tsx
23
- // app/button/client.tsx
24
- "use client";
25
-
26
- import { cva, type VariantProps } from "class-variance-authority";
27
- import { cn } from "@/lib/utils";
28
-
29
- const buttonVariants = cva(
30
- // Base styles
31
- "inline-flex items-center justify-center rounded-md font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 disabled:pointer-events-none disabled:opacity-50",
32
- {
33
- variants: {
34
- variant: {
35
- default: "bg-mandu-primary text-white hover:bg-mandu-primary/90",
36
- destructive: "bg-red-500 text-white hover:bg-red-500/90",
37
- outline: "border border-input bg-background hover:bg-accent",
38
- secondary: "bg-mandu-secondary text-white hover:bg-mandu-secondary/80",
39
- ghost: "hover:bg-accent hover:text-accent-foreground",
40
- link: "text-mandu-primary underline-offset-4 hover:underline",
41
- },
42
- size: {
43
- default: "h-10 px-4 py-2",
44
- sm: "h-9 rounded-md px-3",
45
- lg: "h-11 rounded-md px-8",
46
- icon: "h-10 w-10",
47
- },
48
- },
49
- defaultVariants: {
50
- variant: "default",
51
- size: "default",
52
- },
53
- }
54
- );
55
-
56
- interface ButtonProps
57
- extends React.ButtonHTMLAttributes<HTMLButtonElement>,
58
- VariantProps<typeof buttonVariants> {}
59
-
60
- export function ButtonIsland({ className, variant, size, ...props }: ButtonProps) {
61
- return (
62
- <button className={cn(buttonVariants({ variant, size }), className)} {...props} />
63
- );
64
- }
65
-
66
- // Export for reuse
67
- export { buttonVariants };
68
- ```
69
-
70
- ## 복합 Variants
71
-
72
- ```tsx
73
- const cardVariants = cva("rounded-lg border", {
74
- variants: {
75
- variant: {
76
- default: "bg-white",
77
- elevated: "bg-white shadow-lg",
78
- outlined: "bg-transparent",
79
- },
80
- padding: {
81
- none: "",
82
- sm: "p-4",
83
- md: "p-6",
84
- lg: "p-8",
85
- },
86
- interactive: {
87
- true: "cursor-pointer hover:shadow-md transition-shadow",
88
- false: "",
89
- },
90
- },
91
- compoundVariants: [
92
- {
93
- variant: "elevated",
94
- interactive: true,
95
- className: "hover:shadow-xl",
96
- },
97
- {
98
- variant: "outlined",
99
- interactive: true,
100
- className: "hover:border-mandu-primary",
101
- },
102
- ],
103
- defaultVariants: {
104
- variant: "default",
105
- padding: "md",
106
- interactive: false,
107
- },
108
- });
109
- ```
110
-
111
- ## Boolean Variants
112
-
113
- ```tsx
114
- const inputVariants = cva(
115
- "flex h-10 w-full rounded-md border px-3 py-2 text-sm",
116
- {
117
- variants: {
118
- hasError: {
119
- true: "border-red-500 focus:ring-red-500",
120
- false: "border-gray-300 focus:ring-mandu-primary",
121
- },
122
- isDisabled: {
123
- true: "bg-gray-100 cursor-not-allowed opacity-50",
124
- false: "bg-white",
125
- },
126
- },
127
- defaultVariants: {
128
- hasError: false,
129
- isDisabled: false,
130
- },
131
- }
132
- );
133
-
134
- export function InputIsland({ error, disabled, ...props }: InputProps) {
135
- return (
136
- <input
137
- className={inputVariants({
138
- hasError: !!error,
139
- isDisabled: disabled,
140
- })}
141
- disabled={disabled}
142
- {...props}
143
- />
144
- );
145
- }
146
- ```
147
-
148
- ## Responsive Variants
149
-
150
- ```tsx
151
- // 반응형은 Tailwind 클래스로 처리
152
- export function CardIsland({ className, ...props }: CardProps) {
153
- return (
154
- <div
155
- className={cn(
156
- cardVariants({ variant: "default", padding: "md" }),
157
- // 반응형 오버라이드
158
- "md:p-8 lg:p-10",
159
- className
160
- )}
161
- {...props}
162
- />
163
- );
164
- }
165
- ```
166
-
167
- ## Slot Pattern과 조합
168
-
169
- ```tsx
170
- // app/alert/client.tsx
171
- "use client";
172
-
173
- import { cva } from "class-variance-authority";
174
-
175
- const alertVariants = cva(
176
- "relative w-full rounded-lg border p-4",
177
- {
178
- variants: {
179
- variant: {
180
- default: "bg-background text-foreground",
181
- info: "border-blue-200 bg-blue-50 text-blue-900",
182
- success: "border-green-200 bg-green-50 text-green-900",
183
- warning: "border-yellow-200 bg-yellow-50 text-yellow-900",
184
- error: "border-red-200 bg-red-50 text-red-900",
185
- },
186
- },
187
- defaultVariants: {
188
- variant: "default",
189
- },
190
- }
191
- );
192
-
193
- const iconVariants = cva("h-5 w-5", {
194
- variants: {
195
- variant: {
196
- default: "text-foreground",
197
- info: "text-blue-600",
198
- success: "text-green-600",
199
- warning: "text-yellow-600",
200
- error: "text-red-600",
201
- },
202
- },
203
- });
204
-
205
- export const Alert = {
206
- Root: ({ variant, className, ...props }) => (
207
- <div className={cn(alertVariants({ variant }), className)} {...props} />
208
- ),
209
- Icon: ({ variant, className, ...props }) => (
210
- <span className={cn(iconVariants({ variant }), className)} {...props} />
211
- ),
212
- Title: ({ className, ...props }) => (
213
- <h5 className={cn("font-medium leading-none", className)} {...props} />
214
- ),
215
- Description: ({ className, ...props }) => (
216
- <div className={cn("text-sm opacity-90", className)} {...props} />
217
- ),
218
- };
219
- ```
220
-
221
- Reference: [class-variance-authority](https://cva.style/docs)