-
Notifications
You must be signed in to change notification settings - Fork 87
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
fix(v2): responsive layouts based on width of drawer #4836
fix(v2): responsive layouts based on width of drawer #4836
Conversation
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.
hook is fine, approach makes sense. thanks, lgtm.
...ilder-and-design/BuilderAndDesignDrawer/EditFieldDrawer/edit-fieldtype/EditDate/EditDate.tsx
Outdated
Show resolved
Hide resolved
6e964c9
to
4e5fd5c
Compare
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.
Looking good, one minor comment to save on an unnecessary function call.
const { useMeasureDrawer } = useCreatePageSidebar() | ||
const [drawerRef] = useMeasureDrawer | ||
|
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 can probably be merged into line 25 instead:
const { activeTab, isDrawerOpen, useMeasureDrawer: [drawerRef] } = useCreatePageSidebar()
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.
tunnel vision got me, fixed. kept it as 2 lines as its a tad more readable imo
4e5fd5c
to
69eb381
Compare
@@ -151,6 +154,8 @@ export const useCreatePageSidebarContext = | |||
setPendingTab(undefined) | |||
}, [isMobile, pendingTab, setFieldsToInactive]) | |||
|
|||
const useMeasureDrawer = useMeasure() |
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.
nit: we should not prefix non-hooks with use
keyword, causes unnecessary confusion. should we call this drawerDimensions
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.
seems like we only need the drawer width too; suggest just returning drawerWidth
from this hook instead of the entire dimensions.
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.
agree on both points
69eb381
to
681869c
Compare
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.
lgtm
Problem
breakpoints might not be flexible enough as the current layout allows a split drawer and content up to minimum width of 768px which means each column can get very narrow. Since breakpoints are based on the width of the entire page, it can't account for the split panels. This mainly affects the custom date range input in form builder.
Solution
Most scenarios can be satisfied by simply setting breakpoints at
lg
instead ofmd
, as per #4835. This PR adds a hook that watches the width of the drawer container then layouts can be changed at any arbitrary width.Pros:
More flexible
Cons:
Not the cleanest code
Room for improvement:
hook could probably be optimised to give it more structure as opposed to returning the raw width?
Before & After Screenshots
BEFORE
WITH BREAKPOINTS
WITH ARBITRARY WIDTH