Update menu integration

This commit is contained in:
Arnaud 2024-10-23 10:41:16 +02:00
parent 3f34e61659
commit 999a823291
No known key found for this signature in database
GPG Key ID: 69D6CE281FCAE663
5 changed files with 42 additions and 32 deletions

View File

@ -1,6 +1,12 @@
export function Logo() { type Props = {
onClick?: () => void;
};
export function Logo({ onClick }: Props) {
return ( return (
<svg <svg
onClick={onClick}
className="logo"
width="30" width="30"
height="34" height="34"
viewBox="0 0 30 34" viewBox="0 0 30 34"

View File

@ -19,9 +19,6 @@ export type MenuItem =
| { | {
type: "space"; type: "space";
} }
| {
type: "empty";
}
| { | {
type: "item"; type: "item";
Component: ComponentType<MenuItemComponentProps>; Component: ComponentType<MenuItemComponentProps>;
@ -65,6 +62,12 @@ export function Menu({
} }
}, [expanded, onOpen]); }, [expanded, onOpen]);
const onLogoClick = () => {
if (!isExpanded) {
setIsExpanded(true);
}
};
const onExpandMenu = () => setIsExpanded(!isExpanded); const onExpandMenu = () => setIsExpanded(!isExpanded);
const renderItem = (i: MenuItem, index: number) => { const renderItem = (i: MenuItem, index: number) => {
@ -73,8 +76,6 @@ export function Menu({
return <hr className="menu-item-separator" key={index}></hr>; return <hr className="menu-item-separator" key={index}></hr>;
case "space": case "space":
return <div className="menu-space" key={index}></div>; return <div className="menu-space" key={index}></div>;
case "empty":
return <div className="menu-empty" key={index}></div>;
case "item": case "item":
return ( return (
<i.Component onClick={onClose} className="menu-item" key={index} /> <i.Component onClick={onClose} className="menu-item" key={index} />
@ -94,7 +95,7 @@ export function Menu({
{...attributes({ "aria-expanded": expanded })}> {...attributes({ "aria-expanded": expanded })}>
<div className="menu-container"> <div className="menu-container">
<div className="menu-header"> <div className="menu-header">
<Logo /> <Logo onClick={onLogoClick} />
<Logotype height={34} className={"menu-logotype"} /> <Logotype height={34} className={"menu-logotype"} />
<div className="menu-header-right"> <div className="menu-header-right">
<ExpandIcon onClick={onExpandMenu}></ExpandIcon> <ExpandIcon onClick={onExpandMenu}></ExpandIcon>

View File

@ -5,15 +5,22 @@
border-radius: var(--codex-border-radius); border-radius: var(--codex-border-radius);
transform: translatex(-500px); transform: translatex(-500px);
transition: transform 0.25s; transition: transform 0.25s;
position: fixed; position: sticky;
z-index: 10; z-index: 10;
view-transition-name: main-menu; view-transition-name: main-menu;
height: 100%; height: 100%;
top: 0; top: 0;
left: 0; width: 80px;
width: 75px;
transition: width 0.5s; transition: width 0.5s;
min-width: 75px; min-width: 0;
}
.logo {
cursor: pointer;
}
.menu--expanded .logo {
cursor: default;
} }
.menu--expanded { .menu--expanded {
@ -29,8 +36,10 @@
.menu-container { .menu-container {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
flex: 1;
padding: 12px; padding: 12px;
position: sticky;
top: 0;
height: calc(100vh - 24px);
} }
.menu-header-right { .menu-header-right {
@ -53,10 +62,11 @@
.menu-items { .menu-items {
border-top: 2px solid var(--codex-border-color); border-top: 2px solid var(--codex-border-color);
padding-top: 1.5rem; padding-top: 1.5rem;
flex: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
position: relative; position: relative;
height: 100%;
margin-bottom: 2.5rem;
} }
.menu[aria-expanded] { .menu[aria-expanded] {
@ -134,15 +144,15 @@
} }
.menu-items:has(.active:nth-child(14))::before { .menu-items:has(.active:nth-child(14))::before {
bottom: 133px; top: calc(100vh - 246px);
} }
.menu-items:has(.active:nth-child(15))::before { .menu-items:has(.active:nth-child(15))::before {
bottom: 90px; top: calc(100vh - 203px);
} }
.menu-items:has(.active:nth-child(16))::before { .menu-items:has(.active:nth-child(16))::before {
bottom: 47px; top: calc(100vh - 160px);
} }
.menu-item:not(:first-child) { .menu-item:not(:first-child) {
@ -150,7 +160,7 @@
} }
.menu-item { .menu-item {
padding: 8px 16px; padding: 8px 18px;
margin-bottom: 0; margin-bottom: 0;
text-decoration: none; text-decoration: none;
font-size: 14px; font-size: 14px;
@ -209,10 +219,6 @@
flex: 1; flex: 1;
} }
.menu-empty {
height: 40px;
}
.menu-icon { .menu-icon {
display: flex; display: flex;
align-items: center; align-items: center;
@ -225,6 +231,6 @@
@media (min-width: 1000px) { @media (min-width: 1000px) {
.menu { .menu {
transform: translatex(0px); transform: translatex(0px);
position: inherit; /* position: inherit; */
} }
} }

View File

@ -52,22 +52,22 @@ const Layout = () => {
{ {
type: "item", type: "item",
Component: (p: MenuItemComponentProps) => ( Component: (p: MenuItemComponentProps) => (
<Link to="/dashboard/nodes" {...p}> <Link to="/dashboard/files" {...p}>
<span className="menu-icon"> <span className="menu-icon">
<NodesIcon /> <FilesIcon />
</span> </span>
<span className="menu-text">Nodes</span> <span className="menu-text">Files</span>
</Link> </Link>
), ),
}, },
{ {
type: "item", type: "item",
Component: (p: MenuItemComponentProps) => ( Component: (p: MenuItemComponentProps) => (
<Link to="/dashboard/files" {...p}> <Link to="/dashboard/nodes" {...p}>
<span className="menu-icon"> <span className="menu-icon">
<FilesIcon /> <NodesIcon />
</span> </span>
<span className="menu-text">Files</span> <span className="menu-text">Nodes</span>
</Link> </Link>
), ),
}, },
@ -179,9 +179,6 @@ const Layout = () => {
</Link> </Link>
), ),
}, },
{
type: "empty",
},
] satisfies MenuItem[]; ] satisfies MenuItem[];
return ( return (

View File

@ -56,7 +56,7 @@ function Index() {
<div className="index-container"> <div className="index-container">
<div className="index-column"> <div className="index-column">
<div className="index-column-section"> <div className="index-column-section">
<Logotype /> <Logotype width={111} />
</div> </div>
{components[step]} {components[step]}