Skip to content

Commit

Permalink
refactor(controller/MenuItems): extract constant
Browse files Browse the repository at this point in the history
  • Loading branch information
exuanbo committed Dec 4, 2023
1 parent b72b0cf commit 997ecbf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/features/controller/MenuItems.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { ReactNode, RefCallback } from 'react'

const BORDER_WIDTH = 1

const className = 'divide-y border bg-gray-50 shadow fixed'

interface Props {
Expand All @@ -13,7 +15,7 @@ const MenuItems = ({ menuElement, children }: Props): JSX.Element => {
return
}
const { bottom: menuBottom, left: menuLeft } = menuElement.getBoundingClientRect()
element.style.top = `${menuBottom - /* border: */ 1}px`
element.style.top = `${menuBottom - BORDER_WIDTH}px`
element.style.left = `${menuLeft}px`
}

Expand All @@ -38,7 +40,7 @@ const Expanded = ({ innerRef, menuItemElement, children }: ExpandedProps): JSX.E
}
const { top: menuItemTop, right: menuItemRight } = menuItemElement.getBoundingClientRect()
const isParentFirstChild = menuItemElement.offsetTop === 0
element.style.top = `${menuItemTop - (isParentFirstChild ? /* border: */ 1 : 0)}px`
element.style.top = `${menuItemTop - (isParentFirstChild ? BORDER_WIDTH : 0)}px`
element.style.left = `${menuItemRight}px`
}

Expand Down

0 comments on commit 997ecbf

Please sign in to comment.