This repository has been archived by the owner on Jan 3, 2025. It is now read-only.
-
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.
- Loading branch information
Huy Le Tien
committed
Apr 13, 2022
1 parent
44348b5
commit cd47a1f
Showing
16 changed files
with
314 additions
and
32 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
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,100 @@ | ||
import { Button, Menu } from "antd"; | ||
import { logout, selectUserSelector } from "containers/Auth/authSlice"; | ||
import { useMemo, useState } from "react"; | ||
import { | ||
RiGroupLine, | ||
RiHome3Line, | ||
RiMenuFoldLine, | ||
RiMenuUnfoldLine, | ||
RiUserLine, | ||
} from "react-icons/ri"; | ||
import { useDispatch, useSelector } from "react-redux"; | ||
import { Link, useLocation } from "react-router-dom"; | ||
|
||
import { | ||
StyledContent, | ||
StyledHeader, | ||
StyledLayout, | ||
StyledSider, | ||
} from "./style"; | ||
|
||
interface IProps { | ||
children?: any; | ||
} | ||
|
||
const Layout = (props: IProps) => { | ||
const [collapsed, setCollapsed] = useState(false); | ||
const user = useSelector(selectUserSelector); | ||
const dispatch = useDispatch(); | ||
const location = useLocation(); | ||
|
||
const toggle = () => { | ||
setCollapsed(!collapsed); | ||
}; | ||
|
||
const openKeys = useMemo(() => { | ||
const list = location.pathname.split("/").filter(Boolean); | ||
|
||
return list.map((item, index) => `${item}-submenu`); | ||
}, [location.pathname]); | ||
|
||
return ( | ||
<StyledLayout> | ||
<StyledSider | ||
theme="light" | ||
trigger={null} | ||
collapsible | ||
collapsed={collapsed} | ||
> | ||
<div className="logo" /> | ||
<Menu | ||
mode="inline" | ||
selectedKeys={[location.pathname]} | ||
defaultOpenKeys={openKeys} | ||
> | ||
<Menu.Item key="/" icon={<RiHome3Line size={18} />}> | ||
<Link to="/">Home</Link> | ||
</Menu.Item> | ||
<Menu.SubMenu | ||
key="users-submenu" | ||
icon={<RiUserLine size={18} />} | ||
title="Users" | ||
> | ||
<Menu.Item key="/users" icon={<RiUserLine size={18} />}> | ||
<Link to="/users">Users</Link> | ||
</Menu.Item> | ||
<Menu.Item key="/users/groups" icon={<RiGroupLine size={18} />}> | ||
<Link to="/users/groups">Groups</Link> | ||
</Menu.Item> | ||
</Menu.SubMenu> | ||
</Menu> | ||
</StyledSider> | ||
<StyledLayout> | ||
<StyledHeader style={{ padding: 0 }}> | ||
<Button | ||
type="link" | ||
onClick={toggle} | ||
icon={ | ||
collapsed ? ( | ||
<RiMenuUnfoldLine size={24} /> | ||
) : ( | ||
<RiMenuFoldLine size={24} /> | ||
) | ||
} | ||
/> | ||
<div className="flex flex-1 justify-end px-5"> | ||
<span> | ||
Hi, <b>{user?.username}</b> -{" "} | ||
<a href="#" onClick={() => dispatch(logout())}> | ||
Logout | ||
</a> | ||
</span> | ||
</div> | ||
</StyledHeader> | ||
<StyledContent>{props.children}</StyledContent> | ||
</StyledLayout> | ||
</StyledLayout> | ||
); | ||
}; | ||
|
||
export default Layout; |
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,24 @@ | ||
import styled from "styled-components"; | ||
import { Layout } from "antd"; | ||
|
||
export const StyledLayout = styled(Layout)` | ||
height: 100%; | ||
`; | ||
|
||
export const StyledContent = styled(Layout.Content)` | ||
padding: 20px; | ||
`; | ||
|
||
export const StyledHeader = styled(Layout.Header)` | ||
display: flex; | ||
background-color: #fff; | ||
align-items: center; | ||
`; | ||
|
||
export const StyledSider = styled(Layout.Sider)` | ||
.logo { | ||
height: 54px; | ||
margin: 10px; | ||
background-color: #ccc; | ||
} | ||
`; |
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 was deleted.
Oops, something went wrong.
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,54 @@ | ||
import { Breadcrumb, Button, Card, Form, Input, Modal, Table } from "antd"; | ||
import Layout from "components/Layout"; | ||
import withAuth from "helpers/withAuth"; | ||
import React from "react"; | ||
|
||
const columns = [ | ||
{ | ||
title: "Permission", | ||
}, | ||
{ | ||
title: "Read", | ||
}, | ||
{ | ||
title: "Write", | ||
}, | ||
]; | ||
|
||
function Group() { | ||
const [visible, setVisible] = React.useState(false); | ||
return ( | ||
<Layout> | ||
<Breadcrumb style={{ marginBottom: 10 }} separator=">"> | ||
<Breadcrumb.Item>Home</Breadcrumb.Item> | ||
<Breadcrumb.Item href="/users">Users</Breadcrumb.Item> | ||
<Breadcrumb.Item>Groups</Breadcrumb.Item> | ||
</Breadcrumb> | ||
<Card | ||
extra={ | ||
<Button type="primary" onClick={() => setVisible(true)}> | ||
Add Group | ||
</Button> | ||
} | ||
></Card> | ||
<Modal | ||
visible={visible} | ||
title="Add Group" | ||
okText="Save" | ||
onCancel={() => setVisible(false)} | ||
> | ||
<Form layout="vertical"> | ||
<Form.Item label="Group Name"> | ||
<Input /> | ||
</Form.Item> | ||
<Form.Item label="Group Description"> | ||
<Input /> | ||
</Form.Item> | ||
<Table columns={columns} /> | ||
</Form> | ||
</Modal> | ||
</Layout> | ||
); | ||
} | ||
|
||
export default withAuth(Group); |
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,9 @@ | ||
import Layout from "components/Layout"; | ||
import withAuth from "helpers/withAuth"; | ||
import React from "react"; | ||
|
||
function User() { | ||
return <Layout>User</Layout>; | ||
} | ||
|
||
export default withAuth(User); |
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,11 +1,29 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
@import "~antd/dist/antd.less"; | ||
|
||
@font-family: "Roboto", sans-serif; | ||
@padding-lg: 30px; | ||
@padding-md: 24px; | ||
// vertical paddings | ||
@padding-lg: 30px; // containers | ||
@padding-md: 24px; // small containers and buttons | ||
@padding-sm: 18px; // Form controls and items | ||
@padding-xs: 12px; // small items | ||
@padding-xss: 8px; // more small | ||
|
||
// vertical margins | ||
@margin-lg: 30px; // containers | ||
@margin-md: 24px; // small containers and buttons | ||
@margin-sm: 18px; // Form controls and items | ||
@margin-xs: 12px; // small items | ||
@margin-xss: 8px; // more small | ||
|
||
@border-radius-base: 5px; | ||
@primary-color: #1f6dff; | ||
@info-color: #20063b; | ||
@success-color: #4ebc5e; | ||
@warning-color: #ffb427; | ||
@error-color: #ff3341; | ||
@height-base: 40px; | ||
@height-lg: 42px; | ||
@height-sm: 32px; |
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 +1,6 @@ | ||
/// <reference types="react-scripts" /> | ||
declare module "react-dom/client" { | ||
// typing module default export as `any` will allow you to access its members without compiler warning | ||
var createRoot: any; | ||
export { createRoot }; | ||
} |
Oops, something went wrong.