-
Notifications
You must be signed in to change notification settings - Fork 5
Feature: Global and App sidebar collapse update #2234
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
Merged
Merged
Changes from 11 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
5d903d1
task: add hamburger menu
finnar-bin 910bea5
task: updated instance menu spacing
finnar-bin 76f9f5a
task: adjust logo and hash spacing
finnar-bin a0a9f4e
task: updated onboarding call spacing
finnar-bin 10e1be5
task: change icon size
finnar-bin c7d6bdd
chore: comments
finnar-bin 00399ca
task: create reusable component for appsidebar button
finnar-bin 325dc5b
task: add appsidebar collapse state to redux
finnar-bin 8e4a99c
task: updated button pos in global sidebar
finnar-bin 62521cc
task: remove overflow and drag bar when collapsed
finnar-bin 57d50bb
chore: cleanup
finnar-bin 931bb31
task: button for global collapse
finnar-bin 32491dd
task: moved the button inside resizeable container
finnar-bin bba870c
task: removed redux data
finnar-bin 70186ec
task: delete appsidebarbutton component
finnar-bin 78030fd
task: fixed height
finnar-bin ad27a82
fix: wrap in themeprovider for consistency
finnar-bin a394ab0
Merge branch 'master' of github.com:zesty-io/manager-ui into feature/…
finnar-bin 08e19c3
task: vqa fixes
finnar-bin 81306c2
Merge branch 'master' of github.com:zesty-io/manager-ui into feature/…
finnar-bin 104f682
task: added tooltips
finnar-bin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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,115 @@ | ||
import { FC, useEffect } from "react"; | ||
import { Tooltip, IconButton, SvgIcon, SxProps } from "@mui/material"; | ||
import { | ||
KeyboardDoubleArrowLeft, | ||
KeyboardDoubleArrowRight, | ||
} from "@mui/icons-material"; | ||
import { useSelector, useDispatch } from "react-redux"; | ||
import { useLocation } from "react-router"; | ||
|
||
import { AppState } from "../../store/types"; | ||
import { actions } from "../../store/ui"; | ||
|
||
interface Props { | ||
inGlobalSidebar?: boolean; | ||
onToggleCollapse?: (collapse: boolean) => void; | ||
} | ||
export const AppSidebarButton: FC<Props> = ({ | ||
inGlobalSidebar = false, | ||
onToggleCollapse, | ||
}) => { | ||
const dispatch = useDispatch(); | ||
const location = useLocation(); | ||
const product = location.pathname.split("/")[1]; | ||
|
||
const { | ||
contentNavCollapsed, | ||
schemaNavCollapsed, | ||
mediaNavCollapsed, | ||
appsNavCollapsed, | ||
reportsNavCollapsed, | ||
} = useSelector((state: AppState) => state.ui); | ||
|
||
const state: Record<string, { collapsed: boolean; toggle: () => void }> = { | ||
content: { | ||
collapsed: contentNavCollapsed, | ||
toggle: () => dispatch(actions.toggleContentNav(!contentNavCollapsed)), | ||
}, | ||
schema: { | ||
collapsed: schemaNavCollapsed, | ||
toggle: () => dispatch(actions.toggleSchemaNav(!schemaNavCollapsed)), | ||
}, | ||
media: { | ||
collapsed: mediaNavCollapsed, | ||
toggle: () => dispatch(actions.toggleMediaNav(!mediaNavCollapsed)), | ||
}, | ||
apps: { | ||
collapsed: appsNavCollapsed, | ||
toggle: () => dispatch(actions.toggleAppsNav(!appsNavCollapsed)), | ||
}, | ||
reports: { | ||
collapsed: reportsNavCollapsed, | ||
toggle: () => dispatch(actions.toggleReportsNav(!reportsNavCollapsed)), | ||
}, | ||
}; | ||
|
||
useEffect(() => { | ||
onToggleCollapse && onToggleCollapse(state[product]?.collapsed); | ||
}, [state[product]?.collapsed]); | ||
|
||
if ( | ||
(inGlobalSidebar && !state[product]?.collapsed) || | ||
(!inGlobalSidebar && state[product]?.collapsed) | ||
) { | ||
return <></>; | ||
} | ||
|
||
return ( | ||
<Tooltip | ||
title={state[product]?.collapsed ? "Expand Sidebar" : "Collapse Sidebar"} | ||
placement="right-start" | ||
enterDelay={1000} | ||
enterNextDelay={1000} | ||
> | ||
<IconButton | ||
data-cy="collapseAppSideBar" | ||
onClick={() => state[product]?.toggle()} | ||
sx={{ | ||
borderRadius: "50%", | ||
borderColor: "grey.600", | ||
borderStyle: "solid", | ||
borderWidth: "1px", | ||
backgroundColor: "grey.900", | ||
|
||
width: "24px", | ||
height: "24px", | ||
|
||
position: "absolute", | ||
top: inGlobalSidebar ? "72px" : "32px", | ||
right: "-12px", | ||
zIndex: (theme) => theme.zIndex.appBar, | ||
|
||
"&:hover": { | ||
backgroundColor: "grey.900", | ||
|
||
".MuiSvgIcon-root": { | ||
color: "common.white", | ||
}, | ||
}, | ||
}} | ||
> | ||
<SvgIcon | ||
component={ | ||
state[product]?.collapsed | ||
? KeyboardDoubleArrowRight | ||
: KeyboardDoubleArrowLeft | ||
} | ||
fontSize="small" | ||
sx={{ | ||
color: "grey.500", | ||
}} | ||
/> | ||
</IconButton> | ||
</Tooltip> | ||
); | ||
}; |
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 want to keep this as a button for accessibility reasons. At the very least we need to give it role="button" and make sure it can be tabbed focused into