-
Notifications
You must be signed in to change notification settings - Fork 86
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
LF-4627 [Nice to have] Implement Add to Map redesign #3715
Changes from 13 commits
b95ff09
dad66be
05a04f2
cab9ede
438e513
431258e
33f48be
698b9ed
f653e66
49f7f66
bb1593d
5558b0b
6d1166a
ba2de86
da2ac46
9d8c503
9475217
f59ab3b
863e453
96017ce
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 |
---|---|---|
|
@@ -33,13 +33,16 @@ interface DrawerProps { | |
buttonGroup?: React.ReactNode; | ||
fullHeight?: boolean; | ||
desktopVariant?: DesktopDrawerVariants; | ||
sideDrawerDirection?: 'left' | 'right'; | ||
isCompactSideMenu?: boolean; // only needed for left side drawer placement | ||
addBackdrop?: boolean; | ||
classes?: { | ||
modal?: string; | ||
drawerBackdrop?: string; | ||
drawerHeader?: string; | ||
drawerContent?: string; | ||
drawerContainer?: string; | ||
drawerContainer?: string; // applied to all drawers | ||
sideDrawerContainer?: string; // side drawer only | ||
}; | ||
} | ||
|
||
|
@@ -58,11 +61,15 @@ const Drawer = ({ | |
}, | ||
fullHeight, | ||
desktopVariant = DesktopDrawerVariants.MODAL, | ||
sideDrawerDirection = 'right', | ||
isCompactSideMenu, | ||
addBackdrop = true, | ||
}: DrawerProps) => { | ||
const theme = useTheme(); | ||
const isDesktop = useMediaQuery(theme.breakpoints.up('sm')); | ||
|
||
const isSideDrawer = isDesktop && desktopVariant === DesktopDrawerVariants.SIDE_DRAWER; | ||
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. Same here, maybe it'd be more explicit as 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. I guess my original question was a bit unclear here -- I was worried if the need to add 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. I'm not sure, perhaps in the future every desktop variant can have its own props and we can pass them in an object that's called something like 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. That's a really nice idea actually! I'll go for the union types for now since they are most of what we need, but I think that would have been better. |
||
|
||
return isDesktop && desktopVariant === DesktopDrawerVariants.MODAL && isOpen ? ( | ||
<ModalComponent | ||
className={classes.modal} | ||
|
@@ -88,13 +95,17 @@ const Drawer = ({ | |
<div | ||
className={clsx( | ||
styles.drawer, | ||
isDesktop && desktopVariant === DesktopDrawerVariants.SIDE_DRAWER | ||
? styles.sideDrawer | ||
: styles.bottomDrawer, | ||
isSideDrawer ? styles.sideDrawer : styles.bottomDrawer, | ||
isSideDrawer && styles[sideDrawerDirection], | ||
sideDrawerDirection === 'left' && isCompactSideMenu | ||
? styles.withCompactSideMenu | ||
: styles.withExpandedSideMenu, | ||
fullHeight && styles.fullHeight, | ||
isOpen ? styles.openD : '', | ||
classes.drawerContainer, | ||
isSideDrawer && classes.sideDrawerContainer, | ||
)} | ||
inert={!isOpen ? '' : null} | ||
> | ||
<div className={clsx(styles.header, classes.drawerHeader)}> | ||
<div className={styles.title}>{title}</div> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ export function CancelButton({ onCancel, showConfirmCancelModal, setShowConfirmC | |
); | ||
} | ||
|
||
CancelButton.PropTypes = { | ||
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. Completely unrelated but this was my typo from #3710 in two files that was causing a console warning: ![]() |
||
CancelButton.propTypes = { | ||
onCancel: PropTypes.func, | ||
showConfirmCancelModal: PropTypes.bool, | ||
setShowConfirmCancelModal: PropTypes.func, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,3 +53,7 @@ | |
.content { | ||
height: 100%; | ||
} | ||
|
||
.sideDrawerContainer { | ||
min-width: 416px; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,6 +111,7 @@ export default function Map({ history, isCompactSideMenu }) { | |
} | ||
return () => { | ||
dispatch(canShowSuccessHeader(false)); | ||
dispatch(setMapAddDrawerHide(farm_id)); | ||
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. This hides the Add to Map Drawer when unmounting Map (i.e. when navigating away). There was no previous need to do so since the backdrop of the modal was basically a click away listener that would close if you clicked on, e.g., the side menu. Actually -- and I think this is a lowkey bug -- you can see on beta that if you start the "add area" action, which hides the backdrop and modal, and then navigate to a different part of app, the modal is re-opened when you return to Map because the 'showModal' redux state was never touched. I think resetting that state when leaving Map makes more sense! |
||
}; | ||
}, []); | ||
|
||
|
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.
This only affects the styles applied in desktop, right? Should this be
desktopSideDrawerDirection
instead?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.
@antsgar Correct, because mobile has no variants! I'm definitely on board with rename but I just want to make sure it's not suggesting there is something like a
mobileSideDrawer
-- do you think that's clear enough from the props if this change is made?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.
Maybe
sideDrawerDesktopVariantDirection
would be clearer? Although perhaps too long 🤔It might also be good to make the typing more explicit so that setting the direction to left or right is only applicable if the right desktop variant is selected. Something like this could work
and then a TS error would show up if you try to set up the direction but forgot to set up the right variant.
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.
Ah I really did want to split up types (for
isCompactSideMenu
actually) but I removed it because I thought the union type was so much harder to read and the import was in a JS file anyway. This union syntax I like more though!But the code above isn't working for me like this (even in .tsx files):
Did it work for you? Instead I only get an error in the valid case of passing neither
desktopVariant
norsideDrawer
, and I haven't been able to resolve this... 😓 (or actually that one can be resolved bysideDrawerDirection?: never;
but then for sure I don't think it would be possible to flag supplying a direction but not a variant)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.
Does it work like this?
I'm getting an error if I try to pass a direction without a variant, and no error if I pass neither.
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.
So strange! I don't get an error if I omit a variant -- only if I intentionally set the wrong one. I thought the default setting to
DesktopDrawerVariants.MODAL
had something to do with it? 🤔 This could also be fixed by requiring a variant, too, but most of the app uses the default (and is in JSX anyway)In any case I still like the union types as a form of documentation, so I'll put them in!