-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feat] thumbnail(프로젝트, 세션) 컴포넌트 (#265)
* chore: storybook next image 설정 * feat: 썸네일 컴포넌트 개발 * feat: app.tsx에서 썸네일 컴포넌트 삭제
- Loading branch information
Showing
8 changed files
with
233 additions
and
3 deletions.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,39 @@ | ||
/* eslint-disable react-hooks/rules-of-hooks */ | ||
import { Meta } from '@storybook/react'; | ||
|
||
import { Thumbnail } from './index'; | ||
|
||
const meta: Meta<typeof Thumbnail> = { | ||
title: 'components/Thumbnail', | ||
}; | ||
|
||
export default meta; | ||
const PROJECT_DUMMY_IMG = '/images/project/13-1.png'; | ||
const SESSION_DUMMY_IMG = '/images/session/orientation.png'; | ||
|
||
export const Project = { | ||
render: () => ( | ||
<Thumbnail | ||
img={PROJECT_DUMMY_IMG} | ||
title="자린고비" | ||
subTitle="13기" | ||
description="거지들의 이야기로 쌓이는<br/>소비습관 개선 서비스" | ||
links={[ | ||
{ type: 'Behance', href: '' }, | ||
{ type: 'Github', href: '' }, | ||
{ type: 'Web', href: '' }, | ||
]} | ||
/> | ||
), | ||
}; | ||
|
||
export const Session = { | ||
render: () => ( | ||
<Thumbnail | ||
img={SESSION_DUMMY_IMG} | ||
title="오리엔테이션" | ||
subTitle="Orientation" | ||
description="디프만의 첫 시작, 서로를 알아갈 수 있는<br/>오리엔테이션에 모두가 함께 해요." | ||
/> | ||
), | ||
}; |
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,173 @@ | ||
import Image from 'next/image'; | ||
import { css } from '@emotion/react'; | ||
import { m, Variants } from 'framer-motion'; | ||
|
||
import { ArrowIcon } from '~/components/Icons'; | ||
import { colors } from '~/styles/colors'; | ||
|
||
type Link = { | ||
type: 'Behance' | 'Github' | 'Web' | 'App'; | ||
href: string; | ||
}; | ||
|
||
type ThumbnailProps = { | ||
title: string; | ||
subTitle: string; | ||
img: string; | ||
description: string; | ||
links?: Link[]; | ||
}; | ||
|
||
const defaultEasing = [0.6, -0.05, 0.01, 0.99]; | ||
|
||
export function Thumbnail({ title, subTitle, img, description, links }: ThumbnailProps) { | ||
return ( | ||
<m.article | ||
css={articleCss} | ||
initial="default" | ||
whileHover="hover" | ||
animate="default" | ||
variants={articleVariants} | ||
> | ||
<m.div css={imageCss} variants={imageVariants}> | ||
<Image src={img} alt={title} fill quality={100} /> | ||
</m.div> | ||
<m.div css={contentsCss}> | ||
<m.div> | ||
<m.p css={titleCss} variants={textVariants}> | ||
{title} | ||
</m.p> | ||
<m.p css={subTitleCss} variants={textVariants}> | ||
{subTitle} | ||
</m.p> | ||
</m.div> | ||
<m.p | ||
css={descriptionCss} | ||
variants={textVariants} | ||
dangerouslySetInnerHTML={{ __html: description }} | ||
/> | ||
{links && ( | ||
<m.div css={linkContainerCss}> | ||
{links.map(link => ( | ||
<m.span key={link.type} css={linkWrapperCss}> | ||
<m.a href={link.href} css={linkCss} variants={textVariants}> | ||
{link.type} | ||
</m.a> | ||
<m.span variants={textVariants}> | ||
<ArrowIcon direction={'right'} color={colors.blue400} width={16} height={16} /> | ||
</m.span> | ||
</m.span> | ||
))} | ||
</m.div> | ||
)} | ||
</m.div> | ||
</m.article> | ||
); | ||
} | ||
|
||
const articleCss = css` | ||
position: relative; | ||
width: 312px; | ||
height: 208px; | ||
padding: 24px; | ||
margin-top: 100px; | ||
`; | ||
|
||
const imageCss = css` | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
object-fit: cover; | ||
z-index: -1; | ||
width: 100%; | ||
height: 100%; | ||
`; | ||
|
||
const contentsCss = css` | ||
display: flex; | ||
flex-direction: column; | ||
height: 100%; | ||
justify-content: space-between; | ||
`; | ||
|
||
const linkContainerCss = css` | ||
display: flex; | ||
gap: 12px; | ||
align-items: center; | ||
`; | ||
|
||
const linkWrapperCss = css` | ||
display: flex; | ||
align-items: center; | ||
`; | ||
|
||
const linkCss = css` | ||
color: ${colors.blue400}; | ||
font-weight: 500; | ||
font-size: 1rem; | ||
line-height: 22px; | ||
letter-spacing: -0.16px; | ||
margin-right: 2px; | ||
`; | ||
|
||
const titleCss = css` | ||
position: relative; | ||
font-weight: 700; | ||
font-size: 1.25rem; | ||
line-height: 30px; | ||
color: ${colors.white}; | ||
z-index: 10; | ||
`; | ||
|
||
const subTitleCss = css` | ||
position: relative; | ||
font-weight: 500; | ||
font-size: 1rem; | ||
line-height: 22px; | ||
color: ${colors.gray100}; | ||
z-index: 10; | ||
`; | ||
|
||
const descriptionCss = css` | ||
position: relative; | ||
font-weight: 500; | ||
font-size: 1rem; | ||
line-height: 22px; | ||
color: ${colors.white}; | ||
z-index: 10; | ||
letter-spacing: -0.16px; | ||
white-space: pre-wrap; | ||
`; | ||
|
||
const textVariants: Variants = { | ||
default: { opacity: 0 }, | ||
hover: { | ||
opacity: 1, | ||
transition: { | ||
duration: 0.3, | ||
ease: defaultEasing, | ||
}, | ||
}, | ||
}; | ||
|
||
const articleVariants: Variants = { | ||
default: { background: 'transparent' }, | ||
hover: { | ||
background: 'rgba(19, 28, 40, 0.5)', | ||
transition: { | ||
duration: 0.3, | ||
ease: defaultEasing, | ||
}, | ||
}, | ||
}; | ||
|
||
const imageVariants: Variants = { | ||
default: { filter: 'blur(0px)' }, | ||
hover: { | ||
filter: 'blur(7px)', | ||
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 @@ | ||
export { Thumbnail } from './Thumbnail'; |
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