File size: 8,318 Bytes
1e92f2d |
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 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 |
// @flow
import * as React from "react";
import { NavLink, withRouter } from "react-router-dom";
import {
Site,
Nav,
Grid,
List,
Button,
RouterContextProvider,
} from "tabler-react";
import type { NotificationProps } from "tabler-react";
type Props = {|
+children: React.Node,
|};
type State = {|
notificationsObjects: Array<NotificationProps>,
|};
type subNavItem = {|
+value: string,
+to?: string,
+icon?: string,
+LinkComponent?: React.ElementType,
+useExact?: boolean,
|};
type navItem = {|
+value: string,
+to?: string,
+icon?: string,
+active?: boolean,
+LinkComponent?: React.ElementType,
+subItems?: Array<subNavItem>,
+useExact?: boolean,
|};
const navBarItems: Array<navItem> = [
{
value: "Home",
to: "/",
icon: "home",
LinkComponent: withRouter(NavLink),
useExact: true,
},
{
value: "Interface",
icon: "box",
subItems: [
{
value: "Cards Design",
to: "/cards",
LinkComponent: withRouter(NavLink),
},
{ value: "Charts", to: "/charts", LinkComponent: withRouter(NavLink) },
{
value: "Pricing Cards",
to: "/pricing-cards",
LinkComponent: withRouter(NavLink),
},
],
},
{
value: "Components",
icon: "calendar",
subItems: [
{ value: "Maps", to: "/maps", LinkComponent: withRouter(NavLink) },
{ value: "Icons", to: "/icons", LinkComponent: withRouter(NavLink) },
{ value: "Store", to: "/store", LinkComponent: withRouter(NavLink) },
{ value: "Blog", to: "/blog", LinkComponent: withRouter(NavLink) },
],
},
{
value: "Pages",
icon: "file",
subItems: [
{ value: "Profile", to: "/profile", LinkComponent: withRouter(NavLink) },
{ value: "Login", to: "/login", LinkComponent: withRouter(NavLink) },
{
value: "Register",
to: "/register",
LinkComponent: withRouter(NavLink),
},
{
value: "Forgot password",
to: "/forgot-password",
LinkComponent: withRouter(NavLink),
},
{ value: "400 error", to: "/400", LinkComponent: withRouter(NavLink) },
{ value: "401 error", to: "/401", LinkComponent: withRouter(NavLink) },
{ value: "403 error", to: "/403", LinkComponent: withRouter(NavLink) },
{ value: "404 error", to: "/404", LinkComponent: withRouter(NavLink) },
{ value: "500 error", to: "/500", LinkComponent: withRouter(NavLink) },
{ value: "503 error", to: "/503", LinkComponent: withRouter(NavLink) },
{ value: "Email", to: "/email", LinkComponent: withRouter(NavLink) },
{
value: "Empty page",
to: "/empty-page",
LinkComponent: withRouter(NavLink),
},
{ value: "RTL", to: "/rtl", LinkComponent: withRouter(NavLink) },
],
},
{
value: "Forms",
to: "/form-elements",
icon: "check-square",
LinkComponent: withRouter(NavLink),
},
{
value: "Gallery",
to: "/gallery",
icon: "image",
LinkComponent: withRouter(NavLink),
},
{
icon: "file-text",
value: "Documentation",
to:
process.env.NODE_ENV === "production"
? "https://tabler.github.io/tabler-react/documentation"
: "/documentation",
},
];
const accountDropdownProps = {
avatarURL: "./demo/faces/female/25.jpg",
name: "Jane Pearson",
description: "Administrator",
options: [
{ icon: "user", value: "Profile" },
{ icon: "settings", value: "Settings" },
{ icon: "mail", value: "Inbox", badge: "6" },
{ icon: "send", value: "Message" },
{ isDivider: true },
{ icon: "help-circle", value: "Need help?" },
{ icon: "log-out", value: "Sign out" },
],
};
class SiteWrapper extends React.Component<Props, State> {
state = {
notificationsObjects: [
{
unread: true,
avatarURL: "demo/faces/male/41.jpg",
message: (
<React.Fragment>
<strong>Nathan</strong> pushed new commit: Fix page load performance
issue.
</React.Fragment>
),
time: "10 minutes ago",
},
{
unread: true,
avatarURL: "demo/faces/female/1.jpg",
message: (
<React.Fragment>
<strong>Alice</strong> started new task: Tabler UI design.
</React.Fragment>
),
time: "1 hour ago",
},
{
unread: false,
avatarURL: "demo/faces/female/18.jpg",
message: (
<React.Fragment>
<strong>Rose</strong> deployed new version of NodeJS REST Api // V3
</React.Fragment>
),
time: "2 hours ago",
},
],
};
render(): React.Node {
const notificationsObjects = this.state.notificationsObjects || [];
const unreadCount = this.state.notificationsObjects.reduce(
(a, v) => a || v.unread,
false
);
return (
<Site.Wrapper
headerProps={{
href: "/",
alt: "Tabler React",
imageURL: "./demo/brand/tabler.svg",
navItems: (
<Nav.Item type="div" className="d-none d-md-flex">
<Button
href="https://github.com/tabler/tabler-react"
target="_blank"
outline
size="sm"
RootComponent="a"
color="primary"
>
Source code
</Button>
</Nav.Item>
),
notificationsTray: {
notificationsObjects,
markAllAsRead: () =>
this.setState(
() => ({
notificationsObjects: this.state.notificationsObjects.map(
v => ({ ...v, unread: false })
),
}),
() =>
setTimeout(
() =>
this.setState({
notificationsObjects: this.state.notificationsObjects.map(
v => ({ ...v, unread: true })
),
}),
5000
)
),
unread: unreadCount,
},
accountDropdown: accountDropdownProps,
}}
navProps={{ itemsObjects: navBarItems }}
routerContextComponentType={withRouter(RouterContextProvider)}
footerProps={{
links: [
<a href="#">First Link</a>,
<a href="#">Second Link</a>,
<a href="#">Third Link</a>,
<a href="#">Fourth Link</a>,
<a href="#">Five Link</a>,
<a href="#">Sixth Link</a>,
<a href="#">Seventh Link</a>,
<a href="#">Eigth Link</a>,
],
note:
"Premium and Open Source dashboard template with responsive and high quality UI. For Free!",
copyright: (
<React.Fragment>
Copyright © 2019
<a href="."> Tabler-react</a>. Theme by
<a
href="https://codecalm.net"
target="_blank"
rel="noopener noreferrer"
>
{" "}
codecalm.net
</a>{" "}
All rights reserved.
</React.Fragment>
),
nav: (
<React.Fragment>
<Grid.Col auto={true}>
<List className="list-inline list-inline-dots mb-0">
<List.Item className="list-inline-item">
<a href="./docs/index.html">Documentation</a>
</List.Item>
<List.Item className="list-inline-item">
<a href="./faq.html">FAQ</a>
</List.Item>
</List>
</Grid.Col>
<Grid.Col auto={true}>
<Button
href="https://github.com/tabler/tabler-react"
size="sm"
outline
color="primary"
RootComponent="a"
>
Source code
</Button>
</Grid.Col>
</React.Fragment>
),
}}
>
{this.props.children}
</Site.Wrapper>
);
}
}
export default SiteWrapper;
|