Skip to content

Commit

Permalink
♻️ : #488 - optionsPosition props로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
qkdl60 committed Mar 13, 2024
1 parent deebf04 commit 6d46c70
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/app/plans/[planId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default function PlanIdPage({ params }: { params: { planId: string } }) {
{isMyPlan && (
<div className="plans-page--share">
<h2>공유하기</h2>
<TooltipButton.Main>
<TooltipButton.Main optionsPosition="top">
<TooltipButton.Options>
<label className="font-size-xs" onClick={handleCopyLink}>
<Icon name="COPY" color="text-100" size="md" />
Expand Down
8 changes: 2 additions & 6 deletions src/components/TooltipButton/TooltipButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
ReactElement,
createContext,
useContext,
useEffect,
useRef,
useState,
} from 'react';
Expand All @@ -32,14 +31,11 @@ const TooltipButtonContext = createContext<{
interface MainProps {
className?: string; // 위치조정이이나, css 스탕일링을 위한 className
children: ReactElement[];
optionsPosition: Position;
}

const Main = ({ children, className }: MainProps) => {
const Main = ({ children, className, optionsPosition }: MainProps) => {
const [isOpen, setIsOpen] = useState<boolean>(false);
const [optionsPosition, setOptionsPosition] = useState<Position>('top');
useEffect(() => {
setOptionsPosition(children[0]?.type !== Options ? 'bottom' : 'top');
}, [children]);

const handleCloseTooltip = () => {
setIsOpen(false);
Expand Down

0 comments on commit 6d46c70

Please sign in to comment.