-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🚀 refactor(drawer): adjust drawer styles and structure #647
base: master
Are you sure you want to change the base?
Changes from all commits
8c43a13
7dde687
c2745a8
aaabd78
857f8d5
764d2bb
4edeb87
42e85ca
5c68f0e
8a2a9c3
7cdc84a
c1c6ca1
a6e5320
7da4d63
f68cf04
dcce8d7
76a8e9e
d8ffac1
0e4b902
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,9 +3,8 @@ import { createPortal } from 'react-dom'; | |
import styled from 'styled-components'; | ||
import { func, bool, node, number, string } from 'prop-types'; | ||
|
||
import { Close } from '@gympass/yoga-icons'; | ||
import { usePortal, useCombinedRefs } from '../../hooks'; | ||
import { Button, Card, Box } from '../..'; | ||
import { Card } from '../..'; | ||
|
||
export const StyledDialog = styled(Card)` | ||
${({ | ||
|
@@ -54,13 +53,9 @@ const Overlay = styled.div` | |
`; | ||
|
||
const Dialog = React.forwardRef( | ||
( | ||
{ isOpen, hideCloseButton, children, dialogId, onClose, zIndex, ...props }, | ||
forwardedRef, | ||
) => { | ||
({ isOpen, children, dialogId, onClose, zIndex, ...props }, forwardedRef) => { | ||
const dialogRef = useCombinedRefs(forwardedRef); | ||
const dialogElement = usePortal(dialogId ?? 'dialog'); | ||
const isCloseButtonVisible = onClose && !hideCloseButton; | ||
|
||
const closeDialog = useCallback( | ||
e => { | ||
|
@@ -97,11 +92,6 @@ const Dialog = React.forwardRef( | |
zIndex={zIndex} | ||
> | ||
<StyledDialog onClose={onClose} {...props}> | ||
{isCloseButtonVisible && ( | ||
<Box d="flex" justifyContent="flex-end" w="100%"> | ||
<Button.Icon icon={Close} inverted onClick={onClose} /> | ||
</Box> | ||
)} | ||
{children} | ||
</StyledDialog> | ||
</Overlay>, | ||
|
@@ -118,18 +108,17 @@ Dialog.propTypes = { | |
dialogId: string, | ||
/** Control the dialog visibility. */ | ||
isOpen: bool, | ||
/** Hide the close button when onClose prop is defined. */ | ||
hideCloseButton: bool, | ||
Comment on lines
-121
to
-122
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you remove |
||
/** Function to close the dialog. */ | ||
onClose: func, | ||
backHandler: func, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Following the name convention of "onClose", WDYT of |
||
zIndex: number, | ||
children: node.isRequired, | ||
}; | ||
|
||
Dialog.defaultProps = { | ||
isOpen: false, | ||
hideCloseButton: false, | ||
onClose: undefined, | ||
backHandler: undefined, | ||
zIndex: 3, | ||
dialogId: undefined, | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should not assume these sizes. The box should be always 100% of
Drawer.Content
. andDrawer.Content
should be the one setting the spacing