Spaces:
Runtime error
Runtime error
File size: 2,110 Bytes
f46b416 |
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 |
import React, { ReactNode, useState } from "react";
import { Layout, Menu } from "antd";
import './index.css';
import {
PieChartOutlined,
FundOutlined,
InfoCircleOutlined,
RobotOutlined,
} from '@ant-design/icons';
import { pageUrlAbout, pageUrlDashboard, pageUrlModels, pageUrlMonitor, pageUrlRoot } from "../../router/pages";
import { Link } from "react-router-dom";
const { Header, Content, Footer, Sider } = Layout;
interface Props {
children: ReactNode;
}
const headerStyle: React.CSSProperties = {
position: 'sticky',
color: '#7dbcea',
backgroundColor: '#fff',
zIndex: 1,
alignItems: 'center',
display: 'flex'
};
const sideBarMenuItems= [
{
name: 'Dashboard',
url: pageUrlDashboard,
icon: <PieChartOutlined />
},
{
name: 'Monitor',
url: pageUrlMonitor,
icon: <FundOutlined />
},
{
name: 'Models',
url: pageUrlModels,
icon: <RobotOutlined />
},
{
name: 'About',
url: pageUrlAbout,
icon: <InfoCircleOutlined />
}
].map(entry => {
return {
label: <Link to={entry.url}>{entry.name}</Link>,
key: entry.name,
icon: entry.icon
}
})
const defaultSelectedKey = 'Dashboard'
export function withLayout(elem: ReactNode) {
return <MyLayout>
{elem}
</MyLayout>
}
export const MyLayout: React.FC<Props> = ({ children }) => {
const [collapsed, setCollapsed] = useState(false);
return (
<Layout style={{ minHeight: '100vh' }}>
<Sider collapsible collapsed={collapsed} onCollapse={setCollapsed}>
<div className="logo" />
<Menu theme="dark" defaultSelectedKeys={[defaultSelectedKey]} items={sideBarMenuItems} mode="inline">
</Menu>
</Sider>
<Layout className="site-layout">
<Header style={headerStyle}>
<Link to={pageUrlRoot}> Guard AI</Link>
</Header>
<Content style={{ padding: '16px' }}>
<div className="site-layout-content">{children}</div>
</Content>
<Footer style={{ textAlign: 'center' }}>
Guard AI - Demo use only!
</Footer>
</Layout>
</Layout>
);
} |