| name | schema-development |
| description | Create and modify Visual Layout Builder schema components, breakpoints, and layouts. Use when working with types/schema.ts, creating new components, adding breakpoints, or modifying layout configurations. Helps ensure Component Independence architecture compliance. |
| allowed-tools | Read, Glob, Grep |
Schema Development Skill
Visual Layout Builder์ Schema ์์คํ
๊ฐ๋ฐ์ ์ํ ์ ๋ฌธ ์คํฌ์
๋๋ค. Component Independence ์ํคํ
์ฒ๋ฅผ ์ค์ํ๋ฉฐ schema๋ฅผ ์์ฑ, ์์ , ๊ฒ์ฆํฉ๋๋ค.
When to Use
types/schema.ts ํ์
์ ์ ์์
- ์๋ก์ด ์ปดํฌ๋ํธ ์์ฑ ๋๋ ์์
- Breakpoint ์ค์ ๋ฐ ๊ด๋ฆฌ
- Layout ๊ตฌ์กฐ ์ค๊ณ
- Schema ๊ฒ์ฆ ๋ก์ง ๊ฐ์
lib/schema-utils.ts ๋๋ lib/schema-validation.ts ์์
Core Architecture Principles
1. Component Independence (ํต์ฌ ์์น)
๊ฐ ์ปดํฌ๋ํธ๋ ๋
๋ฆฝ์ ์ผ๋ก ์์ ์ positioning, layout, styling์ ์ ์ํฉ๋๋ค:
interface Component {
id: string
name: string
semanticTag: SemanticTag
positioning: ComponentPositioning
layout: ComponentLayout
styling?: ComponentStyling
responsive?: ResponsiveBehavior
responsiveCanvasLayout?: ResponsiveCanvasLayout
}
2. Semantic Tag Mapping
๊ฐ ์๋งจํฑ ํ๊ทธ์ ๊ถ์ฅ๋๋ positioning:
| Semantic Tag | Recommended Positioning | Use Case |
|---|
header | sticky or fixed | ํ์ด์ง ์๋จ ๋ค๋น๊ฒ์ด์
|
nav | sticky | ๋ค๋น๊ฒ์ด์
๋ฉ๋ด |
main | static | ์ฃผ์ ์ฝํ
์ธ ์์ญ |
aside | sticky or static | ์ฌ์ด๋๋ฐ |
footer | static | ํ์ด์ง ํ๋จ |
section | static | ์ฝํ
์ธ ์น์
|
article | static | ๋
๋ฆฝ์ ์ธ ์ฝํ
์ธ |
div | static | ์ผ๋ฐ ์ปจํ
์ด๋ |
form | static | ํผ ์์ญ |
3. Layout Types
layout: {
type: "flex",
flex: {
direction: "column",
justify: "start",
items: "stretch",
gap: 16
}
}
layout: {
type: "grid",
grid: {
cols: 3,
rows: "auto",
gap: 24
}
}
layout: {
type: "container",
container: {
maxWidth: "7xl",
padding: 16,
centered: true
}
}
Creating New Components
Step 1: Generate Component ID
import { generateComponentId } from '@/lib/schema-utils'
const newId = generateComponentId(existingComponents)
Step 2: Define Component Structure
const newComponent: Component = {
id: newId,
name: "HeroSection",
semanticTag: "section",
positioning: {
type: "static"
},
layout: {
type: "flex",
flex: {
direction: "column",
justify: "center",
items: "center",
gap: 24
}
},
styling: {
height: "500px",
className: "min-h-[500px] px-4 text-center"
},
responsiveCanvasLayout: {
mobile: { x: 0, y: 1, width: 4, height: 3 },
tablet: { x: 0, y: 1, width: 8, height: 3 },
desktop: { x: 0, y: 1, width: 12, height: 3 }
}
}
Step 3: Add to Schema
const updatedComponents = [...schema.components, newComponent]
const updatedLayouts = {
...schema.layouts,
[currentBreakpoint]: {
...currentLayout,
components: [...currentLayout.components, newId]
}
}
Breakpoint Management
Dynamic Breakpoint Support
const validNames = [
"mobile",
"tablet",
"desktop",
"laptop",
"4k",
"mobile-sm",
"tablet_lg"
]
const invalidNames = [
"",
"mobile@tablet",
"mobile tablet",
"๋ชจ๋ฐ์ผ",
"a".repeat(101),
"constructor"
]
Creating Breakpoints
const newBreakpoint: Breakpoint = {
name: "laptop",
minWidth: 1024,
gridCols: 12,
gridRows: 10
}
Validation Rules
Component Validation
- Name must be PascalCase:
MyComponent, HeroSection
- ID must be unique: No duplicates in components array
- Positioning type required: Must specify type field
- Layout type required: Must specify type field
Canvas Layout Validation
- CANVAS_LAYOUT_ORDER_MISMATCH
- COMPLEX_GRID_LAYOUT_DETECTED
- CANVAS_COMPONENTS_OVERLAP
- CANVAS_OUT_OF_BOUNDS
- CANVAS_ZERO_SIZE
- CANVAS_NEGATIVE_COORDINATE
- CANVAS_FRACTIONAL_COORDINATE
- CANVAS_COMPONENT_NOT_IN_LAYOUT
- MISSING_CANVAS_LAYOUT
Schema Normalization
ํญ์ ์คํค๋ง ์์ ํ normalizeSchema() ํธ์ถ:
import { normalizeSchema } from '@/lib/schema-utils'
const normalizedSchema = normalizeSchema(updatedSchema)
์ด๋ Breakpoint Inheritance (Mobile โ Tablet โ Desktop)๋ฅผ ์ฒ๋ฆฌํฉ๋๋ค.
Common Patterns
GitHub-style Layout
{
structure: "sidebar-main",
components: ["c1", "c2", "c3"],
roles: {
header: "c1",
sidebar: "c2",
main: "c3"
}
}
Dashboard Layout
{
structure: "horizontal",
components: ["c1", "c2", "c3", "c4"],
containerLayout: {
type: "flex",
flex: { direction: "column" }
}
}
Reference Files
types/schema.ts - ๋ชจ๋ ํ์
์ ์
lib/schema-utils.ts - ์คํค๋ง ์ ํธ๋ฆฌํฐ ํจ์
lib/schema-validation.ts - ๊ฒ์ฆ ๋ก์ง
lib/component-library.ts - ์ฌ์ ์ ์ ์ปดํฌ๋ํธ
docs/schema-v2-examples.md - ์คํค๋ง ์์