"use client"; import React, { useState } from "react"; import { Monitor, Tablet, Smartphone, Settings } from "lucide-react"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Button } from "@/components/ui/button"; import { ScreenResolution, SCREEN_RESOLUTIONS } from "@/types/screen"; interface ResolutionPanelProps { currentResolution: ScreenResolution; onResolutionChange: (resolution: ScreenResolution) => void; } const ResolutionPanel: React.FC = ({ currentResolution, onResolutionChange }) => { const [customWidth, setCustomWidth] = useState(currentResolution.width.toString()); const [customHeight, setCustomHeight] = useState(currentResolution.height.toString()); const [selectedPreset, setSelectedPreset] = useState( SCREEN_RESOLUTIONS.find((r) => r.width === currentResolution.width && r.height === currentResolution.height) ?.name || "custom", ); const handlePresetChange = (presetName: string) => { setSelectedPreset(presetName); if (presetName === "custom") { return; } const preset = SCREEN_RESOLUTIONS.find((r) => r.name === presetName); if (preset) { setCustomWidth(preset.width.toString()); setCustomHeight(preset.height.toString()); onResolutionChange(preset); } }; const handleCustomResolution = () => { const width = parseInt(customWidth); const height = parseInt(customHeight); if (width > 0 && height > 0) { const customResolution: ScreenResolution = { width, height, name: `사용자 정의 (${width}×${height})`, category: "custom", }; onResolutionChange(customResolution); setSelectedPreset("custom"); } }; const getCategoryIcon = (category: string) => { switch (category) { case "desktop": return ; case "tablet": return ; case "mobile": return ; default: return ; } }; const getCategoryColor = (category: string) => { switch (category) { case "desktop": return "text-primary"; case "tablet": return "text-green-600"; case "mobile": return "text-purple-600"; default: return "text-muted-foreground"; } }; return (
{/* 프리셋 선택 */}
{/* 사용자 정의 해상도 */} {selectedPreset === "custom" && (
setCustomWidth(e.target.value)} placeholder="1920" min="1" step="1" className="h-6 w-full px-2 py-0 text-xs" />
setCustomHeight(e.target.value)} placeholder="1080" min="1" step="1" className="h-6 w-full px-2 py-0 text-xs" />
)}
); }; export default ResolutionPanel;