File tree Expand file tree Collapse file tree 4 files changed +60
-10
lines changed
Expand file tree Collapse file tree 4 files changed +60
-10
lines changed Original file line number Diff line number Diff line change 1313 }
1414 ],
1515 " @babel/preset-typescript"
16- ]
16+ ],
17+ "ignore" : [" ./src/themes/**/*.bundle.js" ]
1718}
Original file line number Diff line number Diff line change 1+ import {
2+ Button ,
3+ DropDown ,
4+ DropDownItem ,
5+ DropDownMenu ,
6+ DropDownTrigger ,
7+ Icon ,
8+ NavigationElementWithChildrenProps ,
9+ } from '@adminjs/design-system' ;
10+ import { ReduxState , useNavigationResources } from 'adminjs' ;
11+ import React , { FC } from 'react' ;
12+ import { useSelector } from 'react-redux' ;
13+
14+ const NavigationComponent : FC = ( ) => {
15+ const resources = useSelector ( ( state : ReduxState ) => state . resources ) ;
16+ const navigatonElements = useNavigationResources ( resources ) ;
17+
18+ console . log ( navigatonElements ) ;
19+
20+ return (
21+ < >
22+ { navigatonElements . map ( element => (
23+ < DropDown key = { element . label } >
24+ < DropDownTrigger >
25+ < Button color = "text" >
26+ < Icon icon = { element . icon } />
27+ { element . label }
28+ </ Button >
29+ </ DropDownTrigger >
30+ < DropDownMenu >
31+ < NavigationElement key = { element . href } element = { element } />
32+ </ DropDownMenu >
33+ </ DropDown >
34+ ) ) }
35+ </ >
36+ ) ;
37+ } ;
38+
39+ const NavigationElement : FC < {
40+ element : NavigationElementWithChildrenProps ;
41+ } > = ( { element } ) => (
42+ < DropDownItem >
43+ < Icon icon = { element . icon } />
44+ { element . label }
45+ { element . elements && (
46+ < DropDownMenu >
47+ { element . elements . map ( nested => (
48+ < NavigationElement key = { nested . href } element = { nested } />
49+ ) ) }
50+ </ DropDownMenu >
51+ ) }
52+ </ DropDownItem >
53+ ) ;
54+
55+ export const Navigation = React . memo ( NavigationComponent ) ;
Original file line number Diff line number Diff line change @@ -13,16 +13,15 @@ import {
1313} from 'adminjs' ;
1414import React from 'react' ;
1515import { useSelector } from 'react-redux' ;
16+ import { Navigation } from '../assets/Navigation.jsx' ;
1617
1718const h = new ViewHelpers ( ) ;
1819
1920const TopBar : React . FC = ( ) => {
20- const resources = useSelector ( ( state : ReduxState ) => state . resources ) ;
2121 const session = useSelector ( ( state : ReduxState ) => state . session ) ;
2222 const branding = useSelector ( ( state : ReduxState ) => state . branding ) ;
2323 const { logo, companyName } = branding ;
2424
25- const elements = useNavigationResources ( resources ) ;
2625 const { tb } = useTranslation ( ) ;
2726
2827 const dropActions : CurrentUserNavProps [ 'dropActions' ] = [
@@ -40,12 +39,7 @@ const TopBar: React.FC = () => {
4039 < Box as = "a" href = { h . dashboardUrl ( ) } mx = "xl" >
4140 { logo ? < img src = { logo } alt = { companyName } /> : < h1 > { companyName } </ h1 > }
4241 </ Box >
43- { elements . map ( element => (
44- < Button as = "a" href = { element . href } color = "text" key = { element . href } >
45- < Icon icon = { element . icon } />
46- { element . label }
47- </ Button >
48- ) ) }
42+ < Navigation />
4943 < Box as = "div" flex flexGrow = { 1 } />
5044 { session && (
5145 < CurrentUserNav
You can’t perform that action at this time.
0 commit comments