From b099b46179245fa69f96b5bd6cbe836f0c77060c Mon Sep 17 00:00:00 2001 From: entrolEC Date: Wed, 13 Mar 2024 16:45:33 +0900 Subject: [PATCH] style: style with constant --- src/components/Sidebar/Pointer.tsx | 7 ++++--- src/components/Sidebar/Sidebar.tsx | 17 ++++++++++++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/components/Sidebar/Pointer.tsx b/src/components/Sidebar/Pointer.tsx index c0dc441..3d663a8 100644 --- a/src/components/Sidebar/Pointer.tsx +++ b/src/components/Sidebar/Pointer.tsx @@ -1,11 +1,12 @@ "use client"; import { motion } from "framer-motion"; +import { CSSProperties } from "react"; -const Pointer = ({ top }: { top: number }) => { +const Pointer = ({ top, style }: { top: number; style?: CSSProperties }) => { return ( diff --git a/src/components/Sidebar/Sidebar.tsx b/src/components/Sidebar/Sidebar.tsx index d6f9f54..76b01de 100644 --- a/src/components/Sidebar/Sidebar.tsx +++ b/src/components/Sidebar/Sidebar.tsx @@ -7,15 +7,22 @@ import Pointer from "@/components/Sidebar/Pointer"; type SidebarProps = { groups: (group & id)[]; }; + +const ASIDE_WIDTH = 80; +const ASIDE_PADDING = 16; +const GROUP_HEIGHT = ASIDE_WIDTH - ASIDE_PADDING * 2; // 48 +const GROUP_REDIUS = GROUP_HEIGHT / 2; // 24 +const POINTER_REDIUS = 4; + const Sidebar = ({ groups }: SidebarProps) => { const [selectedIdx, setSelectedIdx] = useState(0); - const height = groups.length * 80 + 80; - const pointerY = selectedIdx * 64 + 24 - 4; + const height = groups.length * (GROUP_HEIGHT + ASIDE_PADDING) + 80; + const pointerY = selectedIdx * (GROUP_HEIGHT + ASIDE_PADDING) + GROUP_REDIUS - POINTER_REDIUS; return (
-