Skip to content

Commit

Permalink
refactor: 디자인시스템 컴포넌트 개선에 의한 코드 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
dladncks1217 committed Jan 11, 2024
1 parent 4adf631 commit 7d24bc3
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 36 deletions.
38 changes: 15 additions & 23 deletions frontend/src/components/trips/TutorialModal/TutorialModal.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,25 @@ import { css } from '@emotion/react';

import { Theme } from 'hang-log-design-system';

export const boxStyling = css({
display: 'flex',
flexDirection: 'column',
alignItems: 'center',

width: '450px',
height: '500px',
marginTop: '30px',

'@media screen and (max-width: 600px)': {
width: '346px',
marginBottom: Theme.spacer.spacing6,
},
});

export const modalStyling = css({
paddingTop: Theme.spacer.spacing5,

'@media screen and (max-width: 600px)': {
width: `calc(100vw - ${Theme.spacer.spacing5})`,
height: `calc(100vh - ${Theme.spacer.spacing9})`,
},
});

export const carouselStyling = css({
width: '385px',
height: '412px',
});
export const buttonStyling = (isMobile: boolean) =>
css({
width: '100%',

export const buttonStyling = css({
width: '100%',
});
marginTop: isMobile ? 0 : 48,
});

export const ItemStyling = (width: number, height: number) =>
css({
'& > svg': {
width,
height,
},
});
45 changes: 32 additions & 13 deletions frontend/src/components/trips/TutorialModal/TutorialModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import { useEffect } from 'react';

import { useRecoilValue } from 'recoil';

import { SVGCarouselModal, useOverlay } from 'hang-log-design-system';
import { Button, GeneralCarousel, Modal, useOverlay } from 'hang-log-design-system';

import {
ItemStyling,
buttonStyling,
modalStyling,
} from '@components/trips/TutorialModal/TutorialModal.style';

import { mediaQueryMobileState } from '@store/mediaQuery';

Expand All @@ -14,24 +20,37 @@ import Tutorial4SVG from '@assets/svg/tutorial4.svg';
const TutorialModal = () => {
const { isOpen: isTutorialOpen, open: openTutorial, close: closeTutorial } = useOverlay();
const isMobile = useRecoilValue(mediaQueryMobileState);
const carouselImages = [Tutorial1SVG, Tutorial2SVG, Tutorial3SVG, Tutorial4SVG];

useEffect(() => {
openTutorial();
}, [openTutorial]);

return (
<SVGCarouselModal
modalWidth={isMobile ? window.innerWidth - 32 - 48 : 385}
modalHeight={isMobile ? window.innerWidth : 412}
isOpen={isTutorialOpen}
closeModal={closeTutorial}
carouselWidth={isMobile ? window.innerWidth - 32 - 48 : 385}
carouselHeight={isMobile ? window.innerWidth : 412}
carouselImages={[Tutorial1SVG, Tutorial2SVG, Tutorial3SVG, Tutorial4SVG]}
showArrows
showDots
buttonGap={isMobile ? 0 : 48}
/>
<Modal css={modalStyling} isOpen={isTutorialOpen} closeModal={closeTutorial}>
<GeneralCarousel
showNavigationOnHover={false}
width={isMobile ? window.innerWidth - 32 - 48 : 385}
height={isMobile ? window.innerWidth : 412}
length={4}
>
{carouselImages.map((Svg, index) => (
<GeneralCarousel.Item index={index} key={crypto.randomUUID()}>
<div
css={ItemStyling(
isMobile ? window.innerWidth - 32 - 48 : 385,
isMobile ? window.innerWidth : 412
)}
>
<Svg />
</div>
</GeneralCarousel.Item>
))}
</GeneralCarousel>
<Button type="button" variant="primary" css={buttonStyling(isMobile)} onClick={closeTutorial}>
닫기
</Button>
</Modal>
);
};

Expand Down

0 comments on commit 7d24bc3

Please sign in to comment.