/** * ๐ŸŽจ ๊ทธ๋ฆฌ๋“œ ์‹œ์Šคํ…œ - ์ปฌ๋Ÿผ ์ŠคํŒฌ ์ƒ์ˆ˜ ์ •์˜ * * Tailwind CSS 12์ปฌ๋Ÿผ ๊ทธ๋ฆฌ๋“œ ์‹œ์Šคํ…œ์„ ์œ„ํ•œ ํ”„๋ฆฌ์…‹ ์ •์˜ */ /** * ์ปฌ๋Ÿผ ์ŠคํŒฌ ํ”„๋ฆฌ์…‹ ํƒ€์ž… */ export type ColumnSpanPreset = | "full" // 12 ์ปฌ๋Ÿผ (100%) | "half" // 6 ์ปฌ๋Ÿผ (50%) | "third" // 4 ์ปฌ๋Ÿผ (33%) | "twoThirds" // 8 ์ปฌ๋Ÿผ (67%) | "quarter" // 3 ์ปฌ๋Ÿผ (25%) | "threeQuarters" // 9 ์ปฌ๋Ÿผ (75%) | "label" // 3 ์ปฌ๋Ÿผ (25%) - ํผ ๋ผ๋ฒจ ์ „์šฉ | "input" // 9 ์ปฌ๋Ÿผ (75%) - ํผ ์ž…๋ ฅ ์ „์šฉ | "small" // 2 ์ปฌ๋Ÿผ (17%) | "medium" // 4 ์ปฌ๋Ÿผ (33%) | "large" // 8 ์ปฌ๋Ÿผ (67%) | "auto"; // ์ž๋™ ๊ณ„์‚ฐ /** * ์ปฌ๋Ÿผ ์ŠคํŒฌ ๊ฐ’ ๋งคํ•‘ */ export const COLUMN_SPAN_VALUES: Record = { full: 12, half: 6, third: 4, twoThirds: 8, quarter: 3, threeQuarters: 9, label: 3, input: 9, small: 2, medium: 4, large: 8, auto: 0, // ์ž๋™ ๊ณ„์‚ฐ ์‹œ 0 }; /** * ์ปฌ๋Ÿผ ์ŠคํŒฌ ํ”„๋ฆฌ์…‹ ์ •๋ณด */ export interface ColumnSpanPresetInfo { value: number; label: string; percentage: string; class: string; description?: string; } /** * ์ปฌ๋Ÿผ ์ŠคํŒฌ ํ”„๋ฆฌ์…‹ ์ƒ์„ธ ์ •๋ณด */ export const COLUMN_SPAN_PRESETS: Record = { full: { value: 12, label: "์ „์ฒด", percentage: "100%", class: "col-span-12", description: "์ „์ฒด ๋„ˆ๋น„ (ํ…Œ์ด๋ธ”, ์ œ๋ชฉ ๋“ฑ)", }, half: { value: 6, label: "์ ˆ๋ฐ˜", percentage: "50%", class: "col-span-6", description: "2๋ถ„ํ•  ๋ ˆ์ด์•„์›ƒ", }, third: { value: 4, label: "1/3", percentage: "33%", class: "col-span-4", description: "3๋ถ„ํ•  ๋ ˆ์ด์•„์›ƒ", }, twoThirds: { value: 8, label: "2/3", percentage: "67%", class: "col-span-8", description: "ํฐ ์ปดํฌ๋„ŒํŠธ", }, quarter: { value: 3, label: "1/4", percentage: "25%", class: "col-span-3", description: "4๋ถ„ํ•  ๋ ˆ์ด์•„์›ƒ", }, threeQuarters: { value: 9, label: "3/4", percentage: "75%", class: "col-span-9", description: "์ž…๋ ฅ ํ•„๋“œ", }, label: { value: 3, label: "๋ผ๋ฒจ์šฉ", percentage: "25%", class: "col-span-3", description: "ํผ ๋ผ๋ฒจ ์ „์šฉ", }, input: { value: 9, label: "์ž…๋ ฅ์šฉ", percentage: "75%", class: "col-span-9", description: "ํผ ์ž…๋ ฅ ์ „์šฉ", }, small: { value: 2, label: "์ž‘๊ฒŒ", percentage: "17%", class: "col-span-2", description: "์•„์ด์ฝ˜, ์ฒดํฌ๋ฐ•์Šค", }, medium: { value: 4, label: "๋ณดํ†ต", percentage: "33%", class: "col-span-4", description: "๋ณดํ†ต ํฌ๊ธฐ ์ปดํฌ๋„ŒํŠธ", }, large: { value: 8, label: "ํฌ๊ฒŒ", percentage: "67%", class: "col-span-8", description: "ํฐ ์ปดํฌ๋„ŒํŠธ", }, auto: { value: 0, label: "์ž๋™", percentage: "auto", class: "", description: "์ž๋™ ๊ณ„์‚ฐ", }, }; /** * Gap/Spacing ํ”„๋ฆฌ์…‹ ํƒ€์ž… */ export type GapPreset = "none" | "xs" | "sm" | "md" | "lg" | "xl"; /** * Gap ํ”„๋ฆฌ์…‹ ์ •๋ณด */ export interface GapPresetInfo { value: number; label: string; pixels: string; class: string; } /** * Gap ํ”„๋ฆฌ์…‹ ์ƒ์„ธ ์ •๋ณด */ export const GAP_PRESETS: Record = { none: { value: 0, label: "์—†์Œ", pixels: "0px", class: "gap-0", }, xs: { value: 2, label: "๋งค์šฐ ์ž‘๊ฒŒ", pixels: "8px", class: "gap-2", }, sm: { value: 4, label: "์ž‘๊ฒŒ", pixels: "16px", class: "gap-4", }, md: { value: 6, label: "๋ณดํ†ต", pixels: "24px", class: "gap-6", }, lg: { value: 8, label: "ํฌ๊ฒŒ", pixels: "32px", class: "gap-8", }, xl: { value: 12, label: "๋งค์šฐ ํฌ๊ฒŒ", pixels: "48px", class: "gap-12", }, }; /** * ์ปฌ๋Ÿผ ์ŠคํŒฌ ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ */ export function isValidColumnSpan(value: string): value is ColumnSpanPreset { return value in COLUMN_SPAN_VALUES; } /** * ์ปฌ๋Ÿผ ์ŠคํŒฌ ๊ฐ’ ๊ฐ€์ ธ์˜ค๊ธฐ */ export function getColumnSpanValue(preset: ColumnSpanPreset): number { return COLUMN_SPAN_VALUES[preset]; } /** * Tailwind ๊ทธ๋ฆฌ๋“œ ํด๋ž˜์Šค ์ƒ์„ฑ */ export function getColumnSpanClass(preset: ColumnSpanPreset): string { return COLUMN_SPAN_PRESETS[preset].class; } /** * ์ปฌ๋Ÿผ ์‹œ์ž‘ ์œ„์น˜ ํด๋ž˜์Šค ์ƒ์„ฑ */ export function getColumnStartClass(start: number): string { if (start < 1 || start > 12) { console.warn(`Invalid column start: ${start}. Must be between 1 and 12.`); return ""; } return `col-start-${start}`; } /** * ์ „์ฒด ๊ทธ๋ฆฌ๋“œ ํด๋ž˜์Šค ์กฐํ•ฉ */ export function buildGridClasses(columnSpan: ColumnSpanPreset, columnStart?: number): string { const classes: string[] = []; // ์ปฌ๋Ÿผ ์ŠคํŒฌ const spanClass = getColumnSpanClass(columnSpan); if (spanClass) { classes.push(spanClass); } // ์‹œ์ž‘ ์œ„์น˜ if (columnStart !== undefined && columnStart > 0) { classes.push(getColumnStartClass(columnStart)); } return classes.join(" "); } /** * Gap ํด๋ž˜์Šค ์ƒ์„ฑ */ export function getGapClass(preset: GapPreset): string { return GAP_PRESETS[preset].class; } /** * Padding ํด๋ž˜์Šค ์ƒ์„ฑ (gap ํด๋ž˜์Šค๋ฅผ padding์œผ๋กœ ๋ณ€ํ™˜) */ export function getPaddingClass(preset: GapPreset): string { return GAP_PRESETS[preset].class.replace("gap-", "p-"); }