-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore(ui): 라이브러리 버전 업데이트 * chore(ui): portal isopen prop 추가 * feat(ui): modal 컴포넌트 개발 * feat(ui): modal storybook 작성 * fix(ui): portal 버그 수정 * chore(ui): height 수정
- Loading branch information
1 parent
97f2436
commit e0baa84
Showing
10 changed files
with
1,695 additions
and
1,938 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
import { useState } from 'react'; | ||
import { Modal as ModalComponent } from '.'; | ||
|
||
type Modal = typeof ModalComponent; | ||
|
||
const meta: Meta<Modal> = { | ||
component: ModalComponent, | ||
title: 'Components/Modal', | ||
}; | ||
|
||
export default meta; | ||
|
||
export const Default: StoryObj<Modal> = { | ||
args: { | ||
isOpen: false, | ||
}, | ||
render: (args) => { | ||
// eslint-disable-next-line react-hooks/rules-of-hooks | ||
const [isOpen, setIsOpen] = useState(false); | ||
|
||
return ( | ||
<> | ||
<ModalComponent {...args} isOpen={isOpen}> | ||
<button | ||
type="button" | ||
onClick={() => { | ||
setIsOpen(false); | ||
}} | ||
> | ||
Close! | ||
</button> | ||
</ModalComponent> | ||
<button | ||
type="button" | ||
onClick={() => { | ||
setIsOpen(true); | ||
}} | ||
> | ||
Open! | ||
</button> | ||
</> | ||
); | ||
}, | ||
}; |
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,49 @@ | ||
import styled from '@emotion/styled'; | ||
import type { ForwardedRef, ReactNode } from 'react'; | ||
import { forwardRef } from 'react'; | ||
import Portal from '../Portal'; | ||
|
||
type ModalProps = { | ||
isOpen: boolean; | ||
width?: string; | ||
height?: string; | ||
children: ReactNode; | ||
}; | ||
|
||
export const Modal = forwardRef(function Modal( | ||
{ isOpen, width = '600px', height = 'auto', children, ...props }: ModalProps, | ||
ref: ForwardedRef<HTMLDivElement> | ||
) { | ||
return ( | ||
<Portal isOpen={isOpen}> | ||
<StyledDIM> | ||
<StyledModal ref={ref} width={width} height={height} {...props}> | ||
{children} | ||
</StyledModal> | ||
</StyledDIM> | ||
</Portal> | ||
); | ||
}); | ||
|
||
const StyledDIM = styled.div` | ||
position: fixed; | ||
z-index: 1; | ||
top: 0; | ||
left: 0; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
width: 100%; | ||
height: 100%; | ||
background-color: #d8e3ff99; | ||
backdrop-filter: blur(12.5px); | ||
`; | ||
|
||
const StyledModal = styled.div<{ width: string; height: string }>` | ||
width: ${({ width }) => width}; | ||
height: ${({ height }) => height}; | ||
min-height: 350px; | ||
background-color: ${({ theme }) => theme.colors.white}; | ||
padding: 36px; | ||
border-radius: 16px; | ||
`; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
export * from './Text'; | ||
export * from './Flex'; | ||
export * from './Button'; | ||
export * from './Portal'; | ||
export * from './Stack'; |
Oops, something went wrong.