-
Notifications
You must be signed in to change notification settings - Fork 60
/
sidebar.tsx
93 lines (88 loc) · 1.74 KB
/
sidebar.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
* ⚠ These are used just to render the Sidebar!
* You can include any link here, local or external.
*
*/
interface IRoute{
path?: string
icon?: string
name: string
routes?: IRoute[]
checkActive?(pathname: String, route: IRoute): boolean
exact?: boolean
}
export function routeIsActive (pathname: String, route: IRoute): boolean {
if (route.checkActive) {
return route.checkActive(pathname, route)
}
return route?.exact
? pathname == route?.path
: (route?.path ? pathname.indexOf(route.path) === 0 : false)
}
const routes: IRoute[] = [
{
path: '/example', // the url
icon: 'HomeIcon', // the component being exported from icons/index.js
name: 'Dashboard', // name that appear in Sidebar
exact: true,
},
{
path: '/example/forms',
icon: 'FormsIcon',
name: 'Forms',
},
{
path: '/example/cards',
icon: 'CardsIcon',
name: 'Cards',
},
{
path: '/example/charts',
icon: 'ChartsIcon',
name: 'Charts',
},
{
path: '/example/buttons',
icon: 'ButtonsIcon',
name: 'Buttons',
},
{
path: '/example/modals',
icon: 'ModalsIcon',
name: 'Modals',
},
{
path: '/example/tables',
icon: 'TablesIcon',
name: 'Tables',
},
{
icon: 'PagesIcon',
name: 'Pages',
routes: [
// submenu
{
path: '/example/login',
name: 'Login',
},
{
path: '/example/create-account',
name: 'Create account',
},
{
path: '/example/forgot-password',
name: 'Forgot password',
},
{
path: '/example/404',
name: '404',
},
{
path: '/example/blank',
name: 'Blank',
},
],
},
]
export type {IRoute}
export default routes