-
Notifications
You must be signed in to change notification settings - Fork 6
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
홈 화면 - 추가 버튼 개발 #116
Merged
홈 화면 - 추가 버튼 개발 #116
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f9b6bde
feat: Floating 버튼 개발 및 애니메이션 적용
hyesungoh 7f2312a
fix: PortalWrapper 애니메이션 exit 적용
hyesungoh 2efd724
feat: Image, Link 아이콘 적용
hyesungoh 6f78a3d
design: reset anchor에 cursor 추가
hyesungoh 45a84ec
feat: Append button 개발
hyesungoh ec5de8d
feat: Append Tooltip 개발
hyesungoh 90cfee3
design: 버튼 동작 애니메이션 변경
hyesungoh 895fd53
Merge remote-tracking branch 'origin/main' into issue/112
hyesungoh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Svg, { SvgProps } from '~/components/common/Svg'; | ||
|
||
export function ImageIcon({ ...props }: SvgProps) { | ||
return ( | ||
<Svg viewBox={24} {...props}> | ||
<path d="M6 17H18L14.25 12L11.25 16L9 13ZM5 21Q4.175 21 3.587 20.413Q3 19.825 3 19V5Q3 4.175 3.587 3.587Q4.175 3 5 3H19Q19.825 3 20.413 3.587Q21 4.175 21 5V19Q21 19.825 20.413 20.413Q19.825 21 19 21Z" /> | ||
</Svg> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Svg, { SvgProps } from '~/components/common/Svg'; | ||
|
||
export function LinkIcon({ ...props }: SvgProps) { | ||
return ( | ||
<Svg viewBox={24} {...props}> | ||
<path d="M11 17H7Q4.925 17 3.463 15.537Q2 14.075 2 12Q2 9.925 3.463 8.462Q4.925 7 7 7H11V9H7Q5.75 9 4.875 9.875Q4 10.75 4 12Q4 13.25 4.875 14.125Q5.75 15 7 15H11ZM8 13V11H16V13ZM13 17V15H17Q18.25 15 19.125 14.125Q20 13.25 20 12Q20 10.75 19.125 9.875Q18.25 9 17 9H13V7H17Q19.075 7 20.538 8.462Q22 9.925 22 12Q22 14.075 20.538 15.537Q19.075 17 17 17Z" /> | ||
</Svg> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import { css, Theme } from '@emotion/react'; | ||
import { motion, Variants } from 'framer-motion'; | ||
|
||
import { PlusIcon } from '~/components/common/icons'; | ||
import PortalWrapper from '~/components/common/PortalWrapper'; | ||
import { defaultEasing, defaultFadeInVariants } from '~/constants/motions'; | ||
import useToggle from '~/hooks/common/useToggle'; | ||
|
||
import AppendTooltip from './AppendTooltip'; | ||
|
||
export default function AppendButton() { | ||
const [isShowing, toggleIsShowing] = useToggle(false); | ||
|
||
return ( | ||
<> | ||
<motion.button | ||
css={buttonCss} | ||
onClick={toggleIsShowing} | ||
variants={buttonRotateVariants} | ||
initial="initial" | ||
animate={isShowing ? 'true' : 'false'} | ||
whileTap={{ scale: 0.9 }} | ||
> | ||
<PlusIcon /> | ||
</motion.button> | ||
|
||
<PortalWrapper isShowing={isShowing}> | ||
<motion.div | ||
css={backdropCss} | ||
variants={defaultFadeInVariants} | ||
initial="initial" | ||
animate="animate" | ||
exit="exit" | ||
> | ||
<AppendTooltip /> | ||
</motion.div> | ||
</PortalWrapper> | ||
</> | ||
); | ||
} | ||
|
||
const buttonCss = (theme: Theme) => css` | ||
position: fixed; | ||
right: 16px; | ||
bottom: 70px; | ||
|
||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
width: 48px; | ||
height: 48px; | ||
background-color: ${theme.color.primary}; | ||
border-radius: 50%; | ||
color: ${theme.color.gray06}; | ||
z-index: 9999; | ||
`; | ||
|
||
const backdropCss = (theme: Theme) => css` | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
width: 100vw; | ||
height: 100vh; | ||
background-color: ${theme.color.dim03}; | ||
z-index: 1000; | ||
`; | ||
|
||
const buttonRotateVariants: Variants = { | ||
initial: { | ||
opacity: 0, | ||
y: 30, | ||
transition: { duration: 0.3, ease: defaultEasing }, | ||
}, | ||
false: { | ||
opacity: 1, | ||
y: 0, | ||
rotateZ: '0deg', | ||
transition: { duration: 0.3, ease: defaultEasing }, | ||
}, | ||
true: { | ||
opacity: 1, | ||
y: 0, | ||
rotateZ: '45deg', | ||
transition: { duration: 0.3, ease: defaultEasing }, | ||
}, | ||
exit: { | ||
opacity: 0, | ||
y: 30, | ||
transition: { duration: 0.3, ease: defaultEasing }, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
import { ReactNode } from 'react'; | ||
import { css, Theme } from '@emotion/react'; | ||
import { motion, Variants } from 'framer-motion'; | ||
|
||
import { EditIcon, ImageIcon, LinkIcon } from '~/components/common/icons'; | ||
import InternalLink from '~/components/common/InternalLink'; | ||
import { defaultEasing } from '~/constants/motions'; | ||
import { RouterPathType } from '~/hooks/common/useInternalRouter'; | ||
|
||
export default function AppendTooltip() { | ||
return ( | ||
<motion.div css={wrapperCss} variants={tooltipVariants}> | ||
<AnchorElement href="/add/text" icon={<EditIcon />} title="글" /> | ||
<AnchorElement href="/add/image" icon={<ImageIcon />} title="이미지" /> | ||
<AnchorElement href="/add/link" icon={<LinkIcon />} title="링크" /> | ||
</motion.div> | ||
); | ||
} | ||
|
||
const wrapperCss = (theme: Theme) => css` | ||
position: fixed; | ||
right: 16px; | ||
bottom: 134px; | ||
|
||
width: 128px; | ||
padding: 10px 8px; | ||
border-radius: 8px; | ||
display: flex; | ||
flex-direction: column; | ||
background-color: ${theme.color.background}; | ||
`; | ||
|
||
interface AnchorElementProps { | ||
href: RouterPathType; | ||
icon: ReactNode; | ||
title: string; | ||
} | ||
|
||
function AnchorElement({ href, icon, title }: AnchorElementProps) { | ||
return ( | ||
<InternalLink href={href}> | ||
<a css={anchorCss}> | ||
{icon} | ||
<span>{title}</span> | ||
</a> | ||
</InternalLink> | ||
); | ||
} | ||
|
||
const anchorCss = (theme: Theme) => css` | ||
width: 100%; | ||
height: 48px; | ||
padding: 0 4px; | ||
display: flex; | ||
align-items: center; | ||
gap: 12px; | ||
color: ${theme.color.gray05}; | ||
|
||
&:not(:last-child) { | ||
border-bottom: solid 1px ${theme.color.gray01}; | ||
} | ||
`; | ||
|
||
const tooltipVariants: Variants = { | ||
initial: { | ||
opacity: 0, | ||
y: 30, | ||
scale: 0.85, | ||
transition: { duration: 0.35, ease: defaultEasing }, | ||
willChange: 'opacity, transform', | ||
}, | ||
animate: { | ||
opacity: 1, | ||
y: 0, | ||
scale: 1, | ||
transition: { duration: 0.35, ease: defaultEasing }, | ||
willChange: 'opacity, transform', | ||
}, | ||
exit: { | ||
opacity: 0, | ||
y: 30, | ||
scale: 0.85, | ||
transition: { duration: 0.35, ease: defaultEasing }, | ||
willChange: 'opacity, transform', | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
아하!! 감사합니다 :)