-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement flippable card in main own organization section
- Loading branch information
1 parent
f3872a3
commit 4a6f244
Showing
9 changed files
with
237 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React from 'react'; | ||
import useBooleanState from '@src/hooks/useBooleanState'; | ||
import * as S from './style'; | ||
|
||
type FlippableCardProps = { | ||
frontContent: React.ReactNode; | ||
backContent: React.ReactNode; | ||
}; | ||
|
||
function FlippableCard({ frontContent, backContent }: FlippableCardProps) { | ||
const [isFlipped, setIsFlipped, setIsUnflipped] = useBooleanState(false); | ||
|
||
const variants = { | ||
front: { rotateY: 0 }, | ||
back: { rotateY: 180 }, | ||
}; | ||
|
||
return ( | ||
<div onMouseEnter={setIsFlipped} onMouseLeave={setIsUnflipped}> | ||
<S.CardWrapper | ||
animate={isFlipped ? 'back' : 'front'} | ||
variants={variants} | ||
transition={{ duration: 0.2 }} | ||
> | ||
<S.FrontSideCardWrapper>{frontContent}</S.FrontSideCardWrapper> | ||
<S.BackSideCardWrapper>{backContent}</S.BackSideCardWrapper> | ||
</S.CardWrapper> | ||
</div> | ||
); | ||
} | ||
|
||
export default FlippableCard; |
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,20 @@ | ||
import styled from '@emotion/styled'; | ||
import { motion } from 'framer-motion'; | ||
|
||
export const CardWrapper = styled(motion.div)` | ||
transition: 0.2s; | ||
display: inline-grid; | ||
transform: perspective(800px) rotateY(0deg); | ||
transform-style: preserve-3d; | ||
`; | ||
|
||
export const SideCardWrapper = styled.div` | ||
grid-area: 1 / 1 / 1 / 1; | ||
backface-visibility: hidden; | ||
`; | ||
|
||
export const FrontSideCardWrapper = styled(SideCardWrapper)``; | ||
|
||
export const BackSideCardWrapper = styled(SideCardWrapper)` | ||
transform: rotateY(180deg); | ||
`; |
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
44 changes: 44 additions & 0 deletions
44
src/views/MainPage/components/OwnOrganization/Card/index.tsx
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,44 @@ | ||
import FlippableCard from '@src/components/common/FlippableCard'; | ||
import { TextWeightType } from '@src/lib/types/universal'; | ||
import * as S from './style'; | ||
|
||
type OwnOrganizationCardProps = { | ||
nameKor: string; | ||
nameEng: string; | ||
description: TextWeightType[]; | ||
frontSideBg: string; | ||
backSideBg: string; | ||
}; | ||
|
||
function Footer(props: Pick<OwnOrganizationCardProps, 'nameKor' | 'nameEng'>) { | ||
return ( | ||
<S.FooterWrapper> | ||
<S.FooterKorName>{props.nameKor}</S.FooterKorName> | ||
<S.FooterEngName>{props.nameEng}</S.FooterEngName> | ||
</S.FooterWrapper> | ||
); | ||
} | ||
|
||
export default function OwnOrganizationCard(props: OwnOrganizationCardProps) { | ||
return ( | ||
<FlippableCard | ||
frontContent={ | ||
<S.CardWrapper background={`url(${props.frontSideBg}) center`}> | ||
<Footer nameKor={props.nameKor} nameEng={props.nameEng} /> | ||
</S.CardWrapper> | ||
} | ||
backContent={ | ||
<S.CardWrapper background={props.backSideBg}> | ||
<S.ContentWrapper> | ||
{props.description.map((textNode, index) => ( | ||
<S.TextWrapper key={index} weight={textNode.weight}> | ||
{textNode.content} | ||
</S.TextWrapper> | ||
))} | ||
</S.ContentWrapper> | ||
<Footer nameKor={props.nameKor} nameEng={props.nameEng} /> | ||
</S.CardWrapper> | ||
} | ||
/> | ||
); | ||
} |
63 changes: 63 additions & 0 deletions
63
src/views/MainPage/components/OwnOrganization/Card/style.ts
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,63 @@ | ||
import styled from '@emotion/styled'; | ||
import { colors } from '@sopt-makers/colors'; | ||
|
||
export const CardWrapper = styled.div<{ background: string }>` | ||
background: ${({ background }) => background}; | ||
border-radius: 19px; | ||
padding: 39px 0; | ||
width: 712px; | ||
height: 380px; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: flex-end; | ||
`; | ||
|
||
export const FooterKorName = styled.div` | ||
width: 144px; | ||
text-align: center; | ||
padding: 16px 0; | ||
color: ${colors.white}; | ||
border: 1px solid rgba(255, 255, 255, 0.5); | ||
background: rgba(117, 97, 79, 0.33); | ||
backdrop-filter: blur(2.949289321899414px); | ||
border-radius: 14px; | ||
color: #fff; | ||
font-size: 22px; | ||
font-weight: 600; | ||
line-height: 28px; | ||
letter-spacing: -0.904px; | ||
`; | ||
|
||
export const FooterEngName = styled.div` | ||
color: rgba(255, 255, 255, 0.7); | ||
font-family: SUIT; | ||
font-size: 20px; | ||
font-style: normal; | ||
font-weight: 400; | ||
line-height: 28.288px; /* 138.027% */ | ||
letter-spacing: -1.025px; | ||
padding-bottom: 4px; | ||
`; | ||
|
||
export const FooterWrapper = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: flex-end; | ||
padding-left: 30px; | ||
padding-right: 42px; | ||
`; | ||
|
||
export const ContentWrapper = styled.div` | ||
padding: 0 41px; | ||
flex: 1; | ||
word-break: keep-all; | ||
`; | ||
|
||
export const TextWrapper = styled.span<{ weight: 'normal' | 'bold' }>` | ||
font-size: 20px; | ||
color: ${colors.white}; | ||
font-weight: ${({ weight }) => weight}; | ||
line-height: 35px; /* 175% */ | ||
letter-spacing: -0.8px; | ||
`; |
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,13 @@ | ||
import { OWN_ORGANIZATION_LIST } from '@src/lib/constants/main'; | ||
import OwnOrganizationCard from './Card'; | ||
import * as S from './style'; | ||
|
||
export default function OwnOrganization() { | ||
return ( | ||
<S.Wrapper> | ||
{OWN_ORGANIZATION_LIST.map((organization) => ( | ||
<OwnOrganizationCard key={organization.nameEng} {...organization} /> | ||
))} | ||
</S.Wrapper> | ||
); | ||
} |
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,6 @@ | ||
import styled from '@emotion/styled'; | ||
|
||
export const Wrapper = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
`; |