-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add layout and additional pages
- Loading branch information
Showing
14 changed files
with
328 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Tooltip } from "antd"; | ||
import React from "react"; | ||
|
||
const withTooltip = (component: React.ReactNode, title: React.ReactNode) => { | ||
return <Tooltip title={title}>{component}</Tooltip>; | ||
}; | ||
|
||
export default withTooltip; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { colorConfig } from "@/themes/config"; | ||
import { LogoutOutlined, UserOutlined } from "@ant-design/icons"; | ||
import { Avatar as AvatarAntd, Dropdown, Space } from "antd"; | ||
import { ItemType } from "antd/es/menu/hooks/useItems"; | ||
import React from "react"; | ||
|
||
const Avatar: React.FC = () => { | ||
const items: ItemType[] = [ | ||
{ | ||
key: "profile", | ||
label: ( | ||
<Space> | ||
<UserOutlined style={{ color: colorConfig.neutral.gray }} /> | ||
Profile | ||
</Space> | ||
), | ||
}, | ||
{ | ||
key: "logout", | ||
label: ( | ||
<Space> | ||
<LogoutOutlined | ||
style={{ color: colorConfig.neutral.gray }} | ||
/> | ||
Logout | ||
</Space> | ||
), | ||
}, | ||
]; | ||
|
||
return ( | ||
<Dropdown | ||
placement="bottomRight" | ||
menu={{ | ||
items, | ||
}} | ||
> | ||
<AvatarAntd | ||
size={50} | ||
icon={<UserOutlined />} | ||
style={{ cursor: "pointer" }} | ||
/> | ||
</Dropdown> | ||
); | ||
}; | ||
|
||
export default Avatar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,5 @@ | |
} | ||
|
||
body{ | ||
background-color: rgb(242, 242, 242); | ||
background-color:#E7E7E7; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
import { Button, Grid, Layout, Menu, Row } from "antd"; | ||
import Sider from "antd/es/layout/Sider"; | ||
import { Content, Header } from "antd/es/layout/layout"; | ||
import React from "react"; | ||
import { | ||
DatabaseOutlined, | ||
LineChartOutlined, | ||
MenuFoldOutlined, | ||
MenuUnfoldOutlined, | ||
PieChartOutlined, | ||
} from "@ant-design/icons"; | ||
import { ItemType, MenuItemType } from "antd/es/menu/hooks/useItems"; | ||
import { colorConfig } from "@/themes/config"; | ||
import Avatar from "@/components/layout/Avatar"; | ||
import { useLocation, useNavigate } from "react-router-dom"; | ||
import { Routes } from "@/routes/routes"; | ||
|
||
interface IProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
const iconSidebarStyle = { | ||
fontSize: 20, | ||
color: colorConfig.neutral.lightGray, | ||
}; | ||
|
||
const menuKey = { | ||
Dashboard: Routes.Dashboard, | ||
VariableInput: Routes.VariableInputIndex, | ||
VariableOutput: Routes.VariableOutputIndex, | ||
Result: Routes.ResultIndex, | ||
}; | ||
|
||
const MainLayout: React.FC<IProps> = ({ children }) => { | ||
const [isSiderCollapsed, setIsSiderCollapsed] = React.useState(false); | ||
const { md } = Grid.useBreakpoint(); | ||
const navigate = useNavigate(); | ||
const location = useLocation(); | ||
|
||
const [activeMenuKey, setActiveMenuKey] = React.useState(null); | ||
|
||
const menuItems = React.useMemo<ItemType<MenuItemType>[]>( | ||
() => [ | ||
{ | ||
key: menuKey.Dashboard, | ||
label: "Dashboard", | ||
icon: <PieChartOutlined style={iconSidebarStyle} />, | ||
onClick: () => navigate(Routes.Dashboard), | ||
}, | ||
{ | ||
key: menuKey.VariableInput, | ||
label: "Variable Input", | ||
icon: <DatabaseOutlined style={iconSidebarStyle} />, | ||
onClick: () => navigate(Routes.VariableInputIndex), | ||
}, | ||
{ | ||
key: menuKey.VariableOutput, | ||
label: "Variable Output", | ||
icon: <DatabaseOutlined style={iconSidebarStyle} />, | ||
onClick: () => navigate(Routes.VariableOutputIndex), | ||
}, | ||
{ | ||
key: menuKey.Result, | ||
label: "Result Predict", | ||
icon: <LineChartOutlined style={iconSidebarStyle} />, | ||
onClick: () => navigate(Routes.ResultIndex), | ||
}, | ||
], | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
[] | ||
); | ||
|
||
React.useEffect(() => { | ||
setIsSiderCollapsed(!md); | ||
}, [md]); | ||
|
||
React.useEffect(() => { | ||
setActiveMenuKey(location.pathname); | ||
}, [location]); | ||
|
||
return ( | ||
<Layout hasSider> | ||
<Sider | ||
style={{ | ||
overflow: "auto", | ||
height: "100vh", | ||
position: "fixed", | ||
left: 0, | ||
top: 0, | ||
bottom: 0, | ||
padding: "1rem 0", | ||
}} | ||
trigger={null} | ||
collapsible | ||
collapsed={isSiderCollapsed} | ||
collapsedWidth={50} | ||
> | ||
<Row justify="center" style={{ marginBottom: "2rem" }}> | ||
<img src="/vite.svg" /> | ||
</Row> | ||
<Menu | ||
theme="dark" | ||
mode="inline" | ||
selectedKeys={[activeMenuKey]} | ||
items={menuItems} | ||
/> | ||
</Sider> | ||
<Layout> | ||
<Header | ||
style={{ | ||
background: colorConfig.neutral.white, | ||
display: "flex", | ||
alignItems: "center", | ||
}} | ||
> | ||
<Row | ||
justify="space-between" | ||
style={{ | ||
width: "100%", | ||
paddingLeft: isSiderCollapsed ? "1rem" : "10rem", | ||
}} | ||
align="middle" | ||
> | ||
<Button | ||
type="text" | ||
icon={ | ||
isSiderCollapsed ? ( | ||
<MenuUnfoldOutlined /> | ||
) : ( | ||
<MenuFoldOutlined /> | ||
) | ||
} | ||
onClick={() => | ||
setIsSiderCollapsed(!isSiderCollapsed) | ||
} | ||
/> | ||
<Avatar /> | ||
</Row> | ||
</Header> | ||
<Content | ||
style={{ | ||
backgroundColor: colorConfig.neutral.lightGray, | ||
padding: isSiderCollapsed | ||
? "2rem 2rem 2rem 5rem" | ||
: "2rem 2rem 2rem 14.5rem", | ||
}} | ||
> | ||
{children} | ||
</Content> | ||
</Layout> | ||
</Layout> | ||
); | ||
}; | ||
|
||
export default MainLayout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
import { useAuthContext } from "@/contexts/AuthContext"; | ||
import MainLayout from "@/layouts/MainLayout"; | ||
import { Card } from "antd"; | ||
import React from "react"; | ||
|
||
const Dashboard: React.FC = () => { | ||
const { user } = useAuthContext(); | ||
return JSON.stringify(user); | ||
return ( | ||
<MainLayout> | ||
<Card title="Dashboard"></Card> | ||
</MainLayout> | ||
); | ||
}; | ||
|
||
export default Dashboard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import MainLayout from "@/layouts/MainLayout"; | ||
import { Card } from "antd"; | ||
import React from "react"; | ||
|
||
const ResultIndex: React.FC = () => { | ||
return ( | ||
<MainLayout> | ||
<Card title="Result"></Card> | ||
</MainLayout> | ||
); | ||
}; | ||
|
||
export default ResultIndex; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import MainLayout from "@/layouts/MainLayout"; | ||
import { Card } from "antd"; | ||
import React from "react"; | ||
|
||
const VariableInputIndex: React.FC = () => { | ||
return ( | ||
<MainLayout> | ||
<Card title="Variable Input"></Card> | ||
</MainLayout> | ||
); | ||
}; | ||
|
||
export default VariableInputIndex; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import MainLayout from "@/layouts/MainLayout"; | ||
import { Card } from "antd"; | ||
import React from "react"; | ||
|
||
const VariableOutputIndex: React.FC = () => { | ||
return ( | ||
<MainLayout> | ||
<Card title="Variable Output"></Card> | ||
</MainLayout> | ||
); | ||
}; | ||
|
||
export default VariableOutputIndex; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.