-
-
Notifications
You must be signed in to change notification settings - Fork 47
feat: Add navigation bar #2490
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
base: dev
Are you sure you want to change the base?
feat: Add navigation bar #2490
Changes from all commits
6b1ce6a
6c864a8
89b1795
5a5657c
de954ba
518db44
c0e394d
40735d9
9e114a2
de08e2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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. We need mobile support (Burger Icon or similar) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
"use client"; | ||
|
||
import Link from "next/link"; | ||
import { usePathname } from "next/navigation"; | ||
import { Group, NavLink } from "@mantine/core"; | ||
|
||
import { clientApi } from "@homarr/api/client"; | ||
|
||
export const NavigationBar = () => { | ||
const { data: boards = [] } = clientApi.board.getAllBoards.useQuery(undefined, { | ||
refetchOnMount: false, | ||
refetchOnWindowFocus: false, | ||
}); | ||
const pathname = usePathname(); | ||
|
||
// Filter boards that should be shown in navigation | ||
const navigationBoards = boards.filter((board) => board.showInNavigation); | ||
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. Create a new route that returns only those from the navigation bar 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. Also I would suggest, that we fetch this data on the server and pass it down to this component, then it does not need to make a roundtrip. THen we define it as initialData so we still can invalidate the values when adding one |
||
|
||
if (navigationBoards.length === 0) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Group gap="xs" wrap="nowrap" style={{ overflow: 'auto', maxWidth: '100%' }}> | ||
{navigationBoards.map((board) => { | ||
const boardUrl = `/boards/${board.name}`; | ||
const isActive = pathname === boardUrl; | ||
|
||
return ( | ||
<NavLink | ||
key={board.id} | ||
component={Link} | ||
href={boardUrl} | ||
label={board.name} | ||
active={isActive} | ||
variant="subtle" | ||
style={{ | ||
borderRadius: 5, | ||
padding: '0 10px', | ||
}} | ||
/> | ||
); | ||
})} | ||
</Group> | ||
); | ||
Comment on lines
+23
to
+45
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. We currently don't handle the overflow of them, so if you add to many links or you shrink your screen it looks not good |
||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE `board` ADD COLUMN `show_in_navigation` boolean DEFAULT false NOT NULL; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"version": "5", | ||
"dialect": "mysql", | ||
"id": "0032_add_show_in_navigation", | ||
"name": "add_show_in_navigation", | ||
"statements": [ | ||
{ | ||
"type": "alter_table", | ||
"name": "board", | ||
"operation": { | ||
"type": "add_column", | ||
"column": { | ||
"name": "show_in_navigation", | ||
"type": "boolean", | ||
"default": { | ||
"type": "literal", | ||
"value": false | ||
}, | ||
"not_null": true | ||
} | ||
} | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE `board` ADD `show_in_navigation` integer DEFAULT 0 NOT NULL; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"version": "6", | ||
"dialect": "sqlite", | ||
"id": "0032_add_show_in_navigation", | ||
"name": "add_show_in_navigation", | ||
"statements": [ | ||
{ | ||
"type": "alter_table", | ||
"name": "board", | ||
"operation": { | ||
"type": "add_column", | ||
"column": { | ||
"name": "show_in_navigation", | ||
"type": "integer", | ||
"default": { | ||
"type": "literal", | ||
"value": 0 | ||
}, | ||
"not_null": true | ||
} | ||
} | ||
} | ||
] | ||
} |
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.
The goal was to still have the search input at the same position when no navigation items are selected