-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
use lazy loading and admin pages (in dev)
1 parent
d5f9171
commit 5c08d04
Showing
14 changed files
with
180 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
@import "menu"; | ||
|
||
.admin-page { | ||
position: relative; | ||
display: flex; | ||
flex-direction: row; | ||
width: 100%; | ||
min-height: calc(100vh - 56px); | ||
height: max-content; | ||
} |
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,59 @@ | ||
.admin-menu { | ||
display: flex; | ||
flex-shrink: 0; | ||
flex-direction: column; | ||
width: 0; | ||
height: 100%; | ||
padding: 0; | ||
margin: 0; | ||
background: var(--background-sidebar); | ||
transition: 0.225s ease-in-out; | ||
min-height: calc(100vh - 56px); | ||
transition-property: width, background, box-shadow, opacity; | ||
border-right: 0; | ||
opacity: 0; | ||
|
||
&.close { | ||
display: none; | ||
} | ||
|
||
&.open { | ||
width: 260px; | ||
border-right: 1px solid hsl(var(--border)); | ||
opacity: 1; | ||
} | ||
|
||
.menu-item { | ||
display: flex; | ||
flex-direction: row; | ||
width: calc(100% - 1.5rem); | ||
height: max-content; | ||
padding: 0.75rem 1rem; | ||
align-items: center; | ||
background: var(--conversation-card); | ||
margin: 0.75rem 0.75rem -0.25rem; | ||
user-select: none; | ||
cursor: pointer; | ||
transition: 0.2s ease-in-out; | ||
border-radius: var(--radius); | ||
font-size: 16px; | ||
|
||
&:hover { | ||
background: var(--conversation-card-hover); | ||
} | ||
|
||
&.active { | ||
background: var(--conversation-card-hover); | ||
} | ||
|
||
& > * { | ||
flex-shrink: 0; | ||
} | ||
|
||
& svg { | ||
width: 1.5rem; | ||
height: 1.5rem; | ||
margin-right: 0.5rem; | ||
} | ||
} | ||
} |
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,50 @@ | ||
import {useSelector} from "react-redux"; | ||
import {selectMenu} from "@/store/menu.ts"; | ||
import React, {useEffect, useMemo, useState} from "react"; | ||
import {LayoutDashboard, Settings} from "lucide-react"; | ||
import router from "@/router.tsx"; | ||
import {useLocation} from "react-router-dom"; | ||
|
||
type MenuItemProps = { | ||
title: string; | ||
icon: React.ReactNode; | ||
path: string; | ||
} | ||
|
||
function MenuItem({ title, icon, path }: MenuItemProps) { | ||
const location = useLocation(); | ||
const active = useMemo(() => ( | ||
location.pathname === `/admin${path}` || (location.pathname + "/") === `/admin${path}` | ||
), [location.pathname, path]); | ||
|
||
return ( | ||
<div className={`menu-item ${active ? "active" : ""}`} | ||
onClick={() => router.navigate(`/admin${path}`)} | ||
> | ||
<div className={`menu-item-icon`}> | ||
{icon} | ||
</div> | ||
<div className={`menu-item-title`}> | ||
{title} | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
function MenuBar() { | ||
const open = useSelector(selectMenu); | ||
const [close, setClose] = useState(false); | ||
useEffect(() => { | ||
if (open) setClose(false); | ||
else setTimeout(() => setClose(true), 200); | ||
}, [open]); | ||
|
||
return ( | ||
<div className={`admin-menu ${open ? "open" : ""} ${close ? "close" : ""}`}> | ||
<MenuItem title={"Dashboard"} icon={<LayoutDashboard />} path={"/"} /> | ||
<MenuItem title={"Dashboard"} icon={<Settings />} path={"/config"} /> | ||
</div> | ||
) | ||
} | ||
|
||
export default MenuBar; |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,12 @@ | ||
import "@/assets/admin/all.less"; | ||
import MenuBar from "@/components/admin/MenuBar.tsx"; | ||
|
||
function Admin() { | ||
return ( | ||
<div className={`admin-page`}> | ||
<MenuBar /> | ||
</div> | ||
) | ||
} | ||
|
||
export default Admin; |
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