-
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.
feat(ui/react): Portal 단순화, ModalPortal, ModalContext 변경 및 개편 (#206)
* feat(ui/react/modal): ModalClose 컴포넌트 추가 * refactor(ui/react/modal): ModalOverlay style transform 활용하여 변경 * refactor(ui/react/modal): ModalContent 내부 ModalOverlay 제거 * refactor(ui/react/modal): ModalOverlay style inset으로 단축, recipe 제거 * feat(ui/react/modal): 변경된 style 반영, onOpenChange 속성 내부 추가 * feat(ui/react/portal): Portal 간소화, 종속되는 styles 제거 * feat(ui/react/modal): ModalPortal 추가 * refactor(ui/react/modal): ModalTitle style textAlign으로 변경, 적용 * feat(ui/react/icons): CloseIcon 추가 * feat(ui/react/modal): ModalTopbar 텍스트 아이콘으로 변경 * feat(ui/react/modal): ModalTrigger 추가 * feat(ui/react/modal): ModalContextValue 속성 단순화 * feat(ui/react/modal): ModalContext 반영, 내외부 onOpen, onOpenChange 속성 받게 추가
- Loading branch information
Showing
18 changed files
with
240 additions
and
177 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,10 @@ | ||
import { createIcon } from './icon'; | ||
|
||
export const CloseIcon = createIcon({ | ||
defaultProps: { | ||
width: '1em', | ||
height: '1em', | ||
fill: 'none', | ||
}, | ||
d: 'M10.0001 11.0628L6.58346 14.4795C6.43068 14.6323 6.25707 14.7052 6.06263 14.6982C5.86818 14.6913 5.69457 14.6114 5.54179 14.4587C5.38902 14.3059 5.31263 14.1288 5.31263 13.9274C5.31263 13.726 5.38902 13.5489 5.54179 13.3962L8.93763 10.0003L5.52096 6.58366C5.36818 6.43088 5.29527 6.2538 5.30221 6.05241C5.30916 5.85102 5.38902 5.67394 5.54179 5.52116C5.69457 5.36838 5.87166 5.29199 6.07304 5.29199C6.27443 5.29199 6.45152 5.36838 6.60429 5.52116L10.0001 8.93783L13.4168 5.52116C13.5696 5.36838 13.7467 5.29199 13.948 5.29199C14.1494 5.29199 14.3265 5.36838 14.4793 5.52116C14.6321 5.67394 14.7085 5.85102 14.7085 6.05241C14.7085 6.2538 14.6321 6.43088 14.4793 6.58366L11.0626 10.0003L14.4793 13.417C14.6321 13.5698 14.7085 13.7434 14.7085 13.9378C14.7085 14.1323 14.6321 14.3059 14.4793 14.4587C14.3265 14.6114 14.1494 14.6878 13.948 14.6878C13.7467 14.6878 13.5696 14.6114 13.4168 14.4587L10.0001 11.0628Z', | ||
}); |
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,31 @@ | ||
import { | ||
type HTMLFavolinkProps, | ||
favolink, | ||
forwardRef, | ||
} from '@favolink-ui/system'; | ||
import { cx, mergeFns } from '@favolink-ui/utils'; | ||
import { useModalContext } from './modal.context'; | ||
|
||
export type ModalCloseProps = HTMLFavolinkProps<'button'>; | ||
|
||
export const ModalClose = forwardRef<ModalCloseProps, 'button'>( | ||
function ModalClose(props, ref) { | ||
const { children, className, onClick, ...restProps } = props; | ||
|
||
const { onOpenChange } = useModalContext(); | ||
|
||
return ( | ||
<favolink.button | ||
{...restProps} | ||
asChild | ||
ref={ref} | ||
className={cx('favolink-modal__close', className)} | ||
onClick={mergeFns(onClick, () => { | ||
onOpenChange(false); | ||
})} | ||
> | ||
{children} | ||
</favolink.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
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
35 changes: 5 additions & 30 deletions
35
packages/ui/react/src/components/modal/modal-overlay.styles.css.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 |
---|---|---|
@@ -1,32 +1,7 @@ | ||
import { type RecipeVariants, recipe } from '@vanilla-extract/recipes'; | ||
import { style } from '@vanilla-extract/css'; | ||
|
||
export const modalOverlay = recipe({ | ||
base: { | ||
position: 'fixed', | ||
top: 0, | ||
left: 0, | ||
right: 0, | ||
bottom: 0, | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
}, | ||
|
||
variants: { | ||
variant: { | ||
original: { | ||
backgroundColor: 'rgba(0, 0, 0, 0.5)', | ||
zIndex: 96, | ||
}, | ||
withContent: { | ||
zIndex: 97, | ||
}, | ||
}, | ||
}, | ||
|
||
defaultVariants: { | ||
variant: 'original', | ||
}, | ||
export const modalOverlayBase = style({ | ||
position: 'fixed', | ||
inset: 0, | ||
backgroundColor: 'rgba(0, 0, 0, 0.5)', | ||
}); | ||
|
||
export type ModalOverlayVariants = RecipeVariants<typeof modalOverlay>; |
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,22 @@ | ||
import { Children } from 'react'; | ||
import { useModalContext } from './modal.context'; | ||
import { Portal, type PortalProps } from '../portal/'; | ||
|
||
export type ModalPortalProps = PortalProps; | ||
|
||
export function ModalPortal(props: ModalPortalProps) { | ||
const { children, ...restProps } = props; | ||
|
||
const { onOpen } = useModalContext(); | ||
|
||
return ( | ||
onOpen && | ||
Children.map(children, (child) => { | ||
return ( | ||
<Portal {...restProps} asChild> | ||
{child} | ||
</Portal> | ||
); | ||
}) | ||
); | ||
} |
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
Oops, something went wrong.