|
| 1 | +'use client' |
| 2 | + |
| 3 | +import { type CSSProperties } from 'react' |
| 4 | + |
| 5 | +import { DesignSystemShowcase } from '@/components/ui/design-system/DesignSystemShowcase' |
| 6 | + |
| 7 | +type GridDevice = 'desktop' | 'mobile' |
| 8 | + |
| 9 | +type GridSpec = { |
| 10 | + id: string |
| 11 | + label: string |
| 12 | + columns: number |
| 13 | +} |
| 14 | + |
| 15 | +type GridGroup = { |
| 16 | + id: string |
| 17 | + heading: string |
| 18 | + badge: string |
| 19 | + device: GridDevice |
| 20 | + frameWidth: number |
| 21 | + gridWidth: number |
| 22 | + gutter: number |
| 23 | + height: number |
| 24 | + specs: GridSpec[] |
| 25 | +} |
| 26 | + |
| 27 | +type GridCustomProperties = CSSProperties & { |
| 28 | + '--grid-count'?: number |
| 29 | + '--grid-content-width'?: string |
| 30 | + '--grid-frame-width'?: string |
| 31 | + '--grid-gutter'?: string |
| 32 | + '--grid-height'?: string |
| 33 | +} |
| 34 | + |
| 35 | +const DESKTOP_GRID_GROUPS: GridGroup[] = [ |
| 36 | + { |
| 37 | + id: 'desktop-long', |
| 38 | + heading: '작업영역 1120px (정보값 많은 페이지에 활용)', |
| 39 | + badge: 'Long', |
| 40 | + device: 'desktop', |
| 41 | + frameWidth: 1280, |
| 42 | + gridWidth: 1120, |
| 43 | + gutter: 20, |
| 44 | + height: 440, |
| 45 | + specs: [ |
| 46 | + { id: 'desktop-long-12', label: '12단', columns: 12 }, |
| 47 | + { id: 'desktop-long-8', label: '8단', columns: 8 }, |
| 48 | + { id: 'desktop-long-4', label: '4단', columns: 4 }, |
| 49 | + { id: 'desktop-long-2', label: '2단', columns: 2 } |
| 50 | + ] |
| 51 | + }, |
| 52 | + { |
| 53 | + id: 'desktop-short', |
| 54 | + heading: '작업영역 550px (정보값 적은 페이지에 활용)', |
| 55 | + badge: 'Short', |
| 56 | + device: 'desktop', |
| 57 | + frameWidth: 1280, |
| 58 | + gridWidth: 550, |
| 59 | + gutter: 20, |
| 60 | + height: 400, |
| 61 | + specs: [ |
| 62 | + { id: 'desktop-short-12', label: '12단', columns: 12 }, |
| 63 | + { id: 'desktop-short-8', label: '8단', columns: 8 }, |
| 64 | + { id: 'desktop-short-4', label: '4단', columns: 4 }, |
| 65 | + { id: 'desktop-short-2', label: '2단', columns: 2 } |
| 66 | + ] |
| 67 | + } |
| 68 | +] |
| 69 | + |
| 70 | +const MOBILE_GRID_GROUP: GridGroup = { |
| 71 | + id: 'mobile', |
| 72 | + heading: '작업영역 343px', |
| 73 | + badge: 'Mobile', |
| 74 | + device: 'mobile', |
| 75 | + frameWidth: 375, |
| 76 | + gridWidth: 343, |
| 77 | + gutter: 8, |
| 78 | + height: 320, |
| 79 | + specs: [ |
| 80 | + { id: 'mobile-4', label: '4단', columns: 4 }, |
| 81 | + { id: 'mobile-3', label: '3단', columns: 3 }, |
| 82 | + { id: 'mobile-2', label: '2단', columns: 2 } |
| 83 | + ] |
| 84 | +} |
| 85 | + |
| 86 | +const formatColumnDetail = (columns: number, gridWidth: number, gutter: number) => { |
| 87 | + const totalGutter = gutter * (columns - 1) |
| 88 | + const width = (gridWidth - totalGutter) / columns |
| 89 | + const rounded = Number(width.toFixed(2)) |
| 90 | + const formatted = Number.isInteger(rounded) ? rounded.toFixed(0) : rounded.toString() |
| 91 | + |
| 92 | + return `${formatted}px · Gutter ${gutter}px` |
| 93 | +} |
| 94 | + |
| 95 | +const GridPreview = ({ |
| 96 | + columns, |
| 97 | + device, |
| 98 | + frameWidth, |
| 99 | + gridWidth, |
| 100 | + gutter, |
| 101 | + height |
| 102 | +}: { |
| 103 | + columns: number |
| 104 | + device: GridDevice |
| 105 | + frameWidth: number |
| 106 | + gridWidth: number |
| 107 | + gutter: number |
| 108 | + height: number |
| 109 | +}) => { |
| 110 | + const customStyle: GridCustomProperties = { |
| 111 | + '--grid-count': columns, |
| 112 | + '--grid-frame-width': `${frameWidth}px`, |
| 113 | + '--grid-content-width': `${gridWidth}px`, |
| 114 | + '--grid-gutter': `${gutter}px`, |
| 115 | + '--grid-height': `${height}px` |
| 116 | + } |
| 117 | + |
| 118 | + return ( |
| 119 | + <div className="ds-grid-viewport" data-device={device} style={customStyle}> |
| 120 | + <div className="ds-grid-columns"> |
| 121 | + {Array.from({ length: columns }).map((_, index) => ( |
| 122 | + <span key={index} className="ds-grid-column" aria-hidden="true" /> |
| 123 | + ))} |
| 124 | + </div> |
| 125 | + </div> |
| 126 | + ) |
| 127 | +} |
| 128 | + |
| 129 | +export default function DesignSystemPage() { |
| 130 | + return ( |
| 131 | + <div className="min-h-screen bg-black px-4 py-10 text-white"> |
| 132 | + <div className="mx-auto w-full max-w-6xl space-y-8"> |
| 133 | + <div> |
| 134 | + <p className="text-xs uppercase tracking-[0.3em] text-white/40">Internal Only</p> |
| 135 | + <h1 className="mt-2 text-3xl font-bold">GDGoC Design System</h1> |
| 136 | + <p className="text-sm text-white/60"> |
| 137 | + 개발 중 확인용 임시 페이지입니다. PR 시 제거 예정. |
| 138 | + </p> |
| 139 | + </div> |
| 140 | + <DesignSystemShowcase /> |
| 141 | + </div> |
| 142 | + </div> |
| 143 | + ) |
| 144 | +} |
0 commit comments