-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#530] FloatingButton 컴포넌트 적용 #536
Changes from 5 commits
0a0652b
3eaa2bd
8f27b7c
20bb312
6b6f8f7
dfe2466
b47d42a
b3a877d
1e22566
ed1c8ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,47 @@ | ||
'use client'; | ||
|
||
import { useRouter } from 'next/navigation'; | ||
import { useEffect } from 'react'; | ||
import { useInView } from 'react-intersection-observer'; | ||
|
||
import SSRSafeSuspense from '@/components/SSRSafeSuspense'; | ||
import TopHeader from '@/v1/base/TopHeader'; | ||
import SearchGroupInput from '@/v1/bookGroup/SearchGroup'; | ||
import SimpleBookGroupCard, { | ||
SimpleBookGroupCardSkeleton, | ||
} from '@/v1/bookGroup/SimpleBookGroupCard'; | ||
import DetailBookGroupCard, { | ||
DetailBookGroupCardSkeleton, | ||
} from '@/v1/bookGroup/DetailBookGroupCard'; | ||
|
||
import useEntireGroupsQuery from '@/queries/group/useEntireGroupsQuery'; | ||
import useMyGroupsQuery from '@/queries/group/useMyGroupQuery'; | ||
import { useMyProfileId } from '@/queries/user/useMyProfileQuery'; | ||
import { checkAuthentication } from '@/utils/helpers'; | ||
|
||
import useMounted from '@/hooks/useMounted'; | ||
import { checkAuthentication } from '@/utils/helpers'; | ||
import useToast from '@/v1/base/Toast/useToast'; | ||
|
||
import FloatingButton from '@/v1/base/FloatingButton'; | ||
import Loading from '@/v1/base/Loading'; | ||
import TopHeader from '@/v1/base/TopHeader'; | ||
import DetailBookGroupCard, { | ||
DetailBookGroupCardSkeleton, | ||
} from '@/v1/bookGroup/DetailBookGroupCard'; | ||
import SearchGroupInput from '@/v1/bookGroup/SearchGroup'; | ||
import SimpleBookGroupCard, { | ||
SimpleBookGroupCardSkeleton, | ||
} from '@/v1/bookGroup/SimpleBookGroupCard'; | ||
|
||
const GroupPage = () => { | ||
const router = useRouter(); | ||
const { show: showToast } = useToast(); | ||
|
||
const isAuthenticated = checkAuthentication(); | ||
|
||
const handleSearchInputClick = () => { | ||
alert('아직 준비 중인 기능이에요.'); | ||
}; | ||
|
||
const handleCreateGroupClick = () => { | ||
isAuthenticated | ||
? router.push('/group/create') | ||
: showToast({ message: '로그인 후에 이용할 수 있어요!', type: 'normal' }); | ||
|
||
return; | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment; 유저 로그인 유무에 따라 Toast, Routing 기능을 적용하였습니다 더 자연스러운 토스트 메시지가 있다면 코멘트로 기재해주셔도 좋아요 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 지금 메세지 괜찮아요! 😲👍🏻 |
||
|
||
return ( | ||
<> | ||
<TopHeader text="Group" /> | ||
|
@@ -36,9 +52,10 @@ const GroupPage = () => { | |
<EntireBookGroupList /> | ||
</SSRSafeSuspense> | ||
</div> | ||
{/* <Link href={'/group/create'}> | ||
<FloatingButton position="bottom-right" /> | ||
</Link> */} | ||
<FloatingButton | ||
onClick={handleCreateGroupClick} | ||
position="bottom-right" | ||
/> | ||
</> | ||
); | ||
}; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,48 @@ | ||
import { IconPlus } from '@public/icons'; | ||
import { ComponentPropsWithoutRef } from 'react'; | ||
import { createPortal } from 'react-dom'; | ||
|
||
import { IconPlus } from '@public/icons'; | ||
|
||
import Portal from './Portal'; | ||
|
||
interface FloatingButtonProps extends ComponentPropsWithoutRef<'button'> { | ||
position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'; | ||
onClick?: () => void; | ||
} | ||
|
||
const getPositionClasses = (position: string) => { | ||
switch (position) { | ||
case 'top-left': { | ||
return 'top-[6.4rem] left-[1.2rem]'; | ||
return 'top-[1.3rem] left-[1.7rem]'; | ||
} | ||
case 'top-right': { | ||
return 'top-[6.4rem] right-[1.2rem]'; | ||
return 'top-[1.3rem] right-[1.7rem]'; | ||
} | ||
case 'bottom-left': { | ||
return 'bottom-[7.2rem] left-[1.2rem]'; | ||
return 'bottom-[8.3rem] left-[1.7rem]'; | ||
} | ||
case 'bottom-right': { | ||
return 'bottom-[7.2rem] right-[1.2rem]'; | ||
return 'bottom-[8.3rem] right-[1.7rem]'; | ||
} | ||
Comment on lines
-12
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment; 바뀐 BottomNavigation에 맞게 포지션 옵션을 수정했습니다 |
||
} | ||
}; | ||
|
||
const FloatingButton = ({ position, ...props }: FloatingButtonProps) => { | ||
const FloatingButton = ({ | ||
position, | ||
onClick, | ||
...props | ||
}: FloatingButtonProps) => { | ||
const positionClasses = getPositionClasses(position); | ||
|
||
return createPortal( | ||
<button | ||
className={`${positionClasses} fixed left-[50%] top-[50%] flex h-[5.1rem] w-[5.1rem] -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full bg-main-900`} | ||
{...props} | ||
> | ||
<IconPlus /> | ||
</button>, | ||
document.body | ||
return ( | ||
<Portal id="createBookGroupButton"> | ||
<button | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p3; html id 속성에 들어갈 값이라 기왕이면 |
||
className={`${positionClasses} absolute flex h-[5.1rem] w-[5.1rem] items-center justify-center rounded-full bg-main-900`} | ||
onClick={onClick} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. p3; shadow 스타일을 적용해야하는데.. 따로 config에 작성하기에는 불편해서 살펴보니, |
||
{...props} | ||
> | ||
<IconPlus className="fill-white" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment; body태그에
이후에 여유가 된다면 |
||
</button> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 혹시.. 제가 figma에서 floating button 디자인을 조금 수정해봤는데.. 반영해주실 수 있을까요?! 🥹🙇🏻♀️ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment; 그럼요 |
||
</Portal> | ||
); | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment;
삼항연산자보다 if else를 사용하는 편이 더 가독성 좋을 것 같아요! 😀