-
-
Notifications
You must be signed in to change notification settings - Fork 287
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
Add app navigation sidebar #1819
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
38c3cd7
App navigation
apedroferreira 305c275
Merge remote-tracking branch 'origin/master' into add-app-navigation
apedroferreira 3ce2600
Fix tests, remove right-side preview, open current page from top, add…
apedroferreira fec9be8
Merge remote-tracking branch 'origin/master' into add-app-navigation
apedroferreira 2c34cf5
Fix navigation overlaying app content
apedroferreira 0d5cc96
Improve go to page test method
apedroferreira 37c008c
Merge remote-tracking branch 'origin/master' into add-app-navigation
apedroferreira b811615
Open respective page in editor from preview
apedroferreira f144507
unused import
apedroferreira d2926a2
Better fallback
apedroferreira 2297d2a
Merge remote-tracking branch 'origin/master' into add-app-navigation
apedroferreira 56f1685
Merge remote-tracking branch 'origin/master' into add-app-navigation
apedroferreira f5c481a
Merge remote-tracking branch 'origin/master' into add-app-navigation
apedroferreira 8345268
Add page parameter for default page display
apedroferreira 49b5c1c
Fixed default value
apedroferreira 7e69087
Keep display param between routes
apedroferreira 618d9b3
Set initial page display only
apedroferreira 96cc127
Merge remote-tracking branch 'origin/master' into add-app-navigation
apedroferreira 8332f20
Revert previous changes and rename defaultDisplay to display
apedroferreira 5de6db7
Not sure what happened here
apedroferreira 8d846cd
Remove uneeded URL params
apedroferreira 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
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
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,72 @@ | ||
import * as React from 'react'; | ||
import { | ||
Drawer, | ||
Box, | ||
List, | ||
ListSubheader, | ||
ListItem, | ||
ListItemButton, | ||
ListItemText, | ||
Toolbar, | ||
} from '@mui/material'; | ||
import { useNavigate, useLocation, useHref } from 'react-router-dom'; | ||
import * as appDom from '../appDom'; | ||
|
||
const DRAWER_WIDTH = 250; // px | ||
|
||
interface AppNavigationProps { | ||
pages: appDom.PageNode[]; | ||
isPreview?: boolean; | ||
} | ||
|
||
export default function AppNavigation({ pages, isPreview = false }: AppNavigationProps) { | ||
const navigate = useNavigate(); | ||
const location = useLocation(); | ||
const { search } = location; | ||
const href = useHref(''); | ||
|
||
const handlePageClick = React.useCallback( | ||
(page: appDom.PageNode) => () => { | ||
navigate(`pages/${page.id}${search}`); | ||
}, | ||
[navigate, search], | ||
); | ||
|
||
const activePagePath = location.pathname.replace(href, ''); | ||
|
||
const navListSubheaderId = React.useId(); | ||
|
||
return ( | ||
<Drawer | ||
variant="permanent" | ||
anchor="left" | ||
open | ||
sx={{ | ||
width: DRAWER_WIDTH, | ||
flexShrink: 0, | ||
[`& .MuiDrawer-paper`]: { width: DRAWER_WIDTH, boxSizing: 'border-box' }, | ||
}} | ||
> | ||
{isPreview ? <Toolbar /> : null} | ||
<Box> | ||
<List | ||
component="nav" | ||
subheader={ | ||
<ListSubheader id={navListSubheaderId} sx={{ px: 4 }}> | ||
Pages | ||
</ListSubheader> | ||
} | ||
aria-labelledby={navListSubheaderId} | ||
> | ||
{pages.map((page) => ( | ||
<ListItem key={page.id} onClick={handlePageClick(page)} disablePadding> | ||
<ListItemButton selected={activePagePath === `/pages/${page.id}`}> | ||
<ListItemText primary={page.name} sx={{ ml: 2 }} /> | ||
</ListItemButton> | ||
</ListItem> | ||
))} | ||
</List> | ||
</Box> | ||
</Drawer> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
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.
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.
Moved these to their own component so that we can use React Router hooks.