diff --git a/pkg/server/startup.go b/pkg/server/startup.go
index 6df4bbe..f465083 100644
--- a/pkg/server/startup.go
+++ b/pkg/server/startup.go
@@ -1,7 +1,7 @@
package server
import (
- "code.smartsheep.studio/hydrogen/identity/pkg/view"
+ "code.smartsheep.studio/hydrogen/identity/pkg/views"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/cache"
"github.com/gofiber/fiber/v2/middleware/cors"
@@ -92,7 +92,7 @@ func NewServer() {
Expiration: 24 * time.Hour,
CacheControl: true,
}), filesystem.New(filesystem.Config{
- Root: http.FS(view.FS),
+ Root: http.FS(views.FS),
PathPrefix: "dist",
Index: "index.html",
NotFoundFile: "dist/index.html",
diff --git a/pkg/view/bun.lockb b/pkg/view/bun.lockb
deleted file mode 100755
index 4f36ee3..0000000
Binary files a/pkg/view/bun.lockb and /dev/null differ
diff --git a/pkg/view/src/components/AppShell.tsx b/pkg/view/src/components/AppShell.tsx
deleted file mode 100644
index 1184bcc..0000000
--- a/pkg/view/src/components/AppShell.tsx
+++ /dev/null
@@ -1,136 +0,0 @@
-import {
- Slide,
- Toolbar,
- Typography,
- AppBar as MuiAppBar,
- AppBarProps as MuiAppBarProps,
- useScrollTrigger,
- IconButton,
- styled,
- Box,
- useMediaQuery,
-} from "@mui/material";
-import { ReactElement, ReactNode, useEffect, useState } from "react";
-import { SITE_NAME } from "@/consts";
-import { Link } from "react-router-dom";
-import NavigationDrawer, { DRAWER_WIDTH, AppNavigationHeader, isMobileQuery } from "@/components/NavigationDrawer";
-import MenuIcon from "@mui/icons-material/Menu";
-
-function HideOnScroll(props: { window?: () => Window; children: ReactElement }) {
- const { children, window } = props;
- const trigger = useScrollTrigger({
- target: window ? window() : undefined,
- });
-
- return (
-
- {children}
-
- );
-}
-
-interface AppBarProps extends MuiAppBarProps {
- open?: boolean;
-}
-
-const ShellAppBar = styled(MuiAppBar, {
- shouldForwardProp: (prop) => prop !== "open",
-})(({ theme, open }) => {
- const isMobile = useMediaQuery(isMobileQuery);
-
- return {
- transition: theme.transitions.create(["margin", "width"], {
- easing: theme.transitions.easing.sharp,
- duration: theme.transitions.duration.leavingScreen,
- }),
- ...(!isMobile &&
- open && {
- width: `calc(100% - ${DRAWER_WIDTH}px)`,
- transition: theme.transitions.create(["margin", "width"], {
- easing: theme.transitions.easing.easeOut,
- duration: theme.transitions.duration.enteringScreen,
- }),
- marginRight: DRAWER_WIDTH,
- }),
- };
-});
-
-const AppMain = styled("main", { shouldForwardProp: (prop) => prop !== "open" })<{
- open?: boolean;
-}>(({ theme, open }) => {
- const isMobile = useMediaQuery(isMobileQuery);
-
- return {
- flexGrow: 1,
- transition: theme.transitions.create("margin", {
- easing: theme.transitions.easing.sharp,
- duration: theme.transitions.duration.leavingScreen,
- }),
- marginRight: -DRAWER_WIDTH,
- ...(!isMobile &&
- open && {
- transition: theme.transitions.create("margin", {
- easing: theme.transitions.easing.easeOut,
- duration: theme.transitions.duration.enteringScreen,
- }),
- marginRight: 0,
- }),
- position: "relative",
- };
-});
-
-export default function AppShell({ children }: { children: ReactNode }) {
- let documentWindow: Window;
-
- const isMobile = useMediaQuery(isMobileQuery);
- const [open, setOpen] = useState(false);
-
- useEffect(() => {
- documentWindow = window;
- });
-
- return (
- <>
- documentWindow}>
-
-
-
-
-
-
-
- {SITE_NAME}
-
-
- setOpen(true)}
- sx={{ width: 64, mr: 1, display: !isMobile && open ? "none" : "block" }}
- >
-
-
-
-
-
-
-
-
-
-
- {children}
-
-
- setOpen(false)} />
-
- >
- );
-}
diff --git a/pkg/view/.eslintrc.cjs b/pkg/views/.eslintrc.cjs
similarity index 100%
rename from pkg/view/.eslintrc.cjs
rename to pkg/views/.eslintrc.cjs
diff --git a/pkg/view/.gitignore b/pkg/views/.gitignore
similarity index 100%
rename from pkg/view/.gitignore
rename to pkg/views/.gitignore
diff --git a/pkg/view/README.md b/pkg/views/README.md
similarity index 100%
rename from pkg/view/README.md
rename to pkg/views/README.md
diff --git a/pkg/views/bun.lockb b/pkg/views/bun.lockb
new file mode 100755
index 0000000..20e87a6
Binary files /dev/null and b/pkg/views/bun.lockb differ
diff --git a/pkg/view/embed.go b/pkg/views/embed.go
similarity index 79%
rename from pkg/view/embed.go
rename to pkg/views/embed.go
index ec34587..bc04fa4 100644
--- a/pkg/view/embed.go
+++ b/pkg/views/embed.go
@@ -1,4 +1,4 @@
-package view
+package views
import "embed"
diff --git a/pkg/view/index.html b/pkg/views/index.html
similarity index 100%
rename from pkg/view/index.html
rename to pkg/views/index.html
diff --git a/pkg/view/package.json b/pkg/views/package.json
similarity index 100%
rename from pkg/view/package.json
rename to pkg/views/package.json
diff --git a/pkg/view/public/favicon.svg b/pkg/views/public/favicon.svg
similarity index 100%
rename from pkg/view/public/favicon.svg
rename to pkg/views/public/favicon.svg
diff --git a/pkg/view/src/components/AppLoader.tsx b/pkg/views/src/components/AppLoader.tsx
similarity index 100%
rename from pkg/view/src/components/AppLoader.tsx
rename to pkg/views/src/components/AppLoader.tsx
diff --git a/pkg/views/src/components/AppShell.tsx b/pkg/views/src/components/AppShell.tsx
new file mode 100644
index 0000000..e232f91
--- /dev/null
+++ b/pkg/views/src/components/AppShell.tsx
@@ -0,0 +1,95 @@
+import {
+ AppBar,
+ Avatar,
+ Box,
+ IconButton,
+ Slide,
+ Toolbar,
+ Typography,
+ useMediaQuery,
+ useScrollTrigger
+} from "@mui/material";
+import { ReactElement, ReactNode, useEffect, useRef, useState } from "react";
+import { SITE_NAME } from "@/consts";
+import { Link } from "react-router-dom";
+import NavigationMenu, { AppNavigationHeader, isMobileQuery } from "@/components/NavigationMenu.tsx";
+import AccountCircleIcon from "@mui/icons-material/AccountCircleOutlined";
+import { useUserinfo } from "@/stores/userinfo.tsx";
+
+function HideOnScroll(props: { window?: () => Window; children: ReactElement }) {
+ const { children, window } = props;
+ const trigger = useScrollTrigger({
+ target: window ? window() : undefined
+ });
+
+ return (
+
+ {children}
+
+ );
+}
+
+export default function AppShell({ children }: { children: ReactNode }) {
+ let documentWindow: Window;
+
+ const { userinfo } = useUserinfo();
+
+ const isMobile = useMediaQuery(isMobileQuery);
+ const [open, setOpen] = useState(false);
+
+ useEffect(() => {
+ documentWindow = window;
+ }, []);
+
+ const container = useRef(null);
+
+ return (
+ <>
+ documentWindow}>
+
+
+
+
+
+
+
+ {SITE_NAME}
+
+
+ setOpen(true)}
+ sx={{ mr: 1 }}
+ >
+
+
+
+
+
+
+
+
+
+
+
+ {children}
+
+
+ setOpen(false)} />
+ >
+ );
+}
diff --git a/pkg/view/src/components/NavigationDrawer.tsx b/pkg/views/src/components/NavigationMenu.tsx
similarity index 50%
rename from pkg/view/src/components/NavigationDrawer.tsx
rename to pkg/views/src/components/NavigationMenu.tsx
index 34a128f..b00a387 100644
--- a/pkg/view/src/components/NavigationDrawer.tsx
+++ b/pkg/views/src/components/NavigationMenu.tsx
@@ -1,27 +1,15 @@
-import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
-import ChevronRightIcon from "@mui/icons-material/ChevronRight";
-import {
- Box,
- Collapse,
- Divider,
- Drawer,
- IconButton,
- List,
- ListItemButton,
- ListItemIcon,
- ListItemText,
- styled,
- useMediaQuery
-} from "@mui/material";
+import { Collapse, Divider, ListItemIcon, ListItemText, Menu, MenuItem, styled } from "@mui/material";
import { theme } from "@/theme";
import { Fragment, ReactNode, useState } from "react";
import HowToRegIcon from "@mui/icons-material/HowToReg";
import LoginIcon from "@mui/icons-material/Login";
import FaceIcon from "@mui/icons-material/Face";
-import LogoutIcon from "@mui/icons-material/Logout";
+import LogoutIcon from "@mui/icons-material/ExitToApp";
import ExpandLess from "@mui/icons-material/ExpandLess";
import ExpandMore from "@mui/icons-material/ExpandMore";
import { useUserinfo } from "@/stores/userinfo.tsx";
+import { PopoverProps } from "@mui/material/Popover";
+import { Link } from "react-router-dom";
export interface NavigationItem {
icon?: ReactNode;
@@ -51,32 +39,30 @@ export function AppNavigationSection({ items, depth }: { items: NavigationItem[]
} else if (item.children) {
return (
- setOpen(!open)} sx={{ pl: 2 + (depth ?? 0) * 2 }}>
+
+
-
-
-
+
);
} else {
return (
-
-
+
+
-
+
+
);
}
});
}
-export function AppNavigation({ showClose, onClose }: { showClose?: boolean; onClose: () => void }) {
+export function AppNavigation() {
const { checkLoggedIn } = useUserinfo();
const nav: NavigationItem[] = [
@@ -94,61 +80,19 @@ export function AppNavigation({ showClose, onClose }: { showClose?: boolean; onC
)
];
- return (
- <>
-
- {showClose && (
-
- {theme.direction === "rtl" ? : }
-
- )}
-
-
-
-
-
- >
- );
+ return ;
}
export const isMobileQuery = theme.breakpoints.down("md");
-export default function NavigationDrawer({ open, onClose }: { open: boolean; onClose: () => void }) {
- const isMobile = useMediaQuery(isMobileQuery);
-
- return isMobile ? (
- <>
-
-
-
-
- >
- ) : (
-
-
-
+export default function NavigationMenu({ anchorEl, open, onClose }: {
+ anchorEl: PopoverProps["anchorEl"];
+ open: boolean;
+ onClose: () => void
+}) {
+ return (
+
);
}
diff --git a/pkg/view/src/consts.tsx b/pkg/views/src/consts.tsx
similarity index 100%
rename from pkg/view/src/consts.tsx
rename to pkg/views/src/consts.tsx
diff --git a/pkg/view/src/error.tsx b/pkg/views/src/error.tsx
similarity index 100%
rename from pkg/view/src/error.tsx
rename to pkg/views/src/error.tsx
diff --git a/pkg/view/src/index.css b/pkg/views/src/index.css
similarity index 100%
rename from pkg/view/src/index.css
rename to pkg/views/src/index.css
diff --git a/pkg/view/src/main.tsx b/pkg/views/src/main.tsx
similarity index 100%
rename from pkg/view/src/main.tsx
rename to pkg/views/src/main.tsx
diff --git a/pkg/view/src/pages/auth/sign-in.tsx b/pkg/views/src/pages/auth/sign-in.tsx
similarity index 100%
rename from pkg/view/src/pages/auth/sign-in.tsx
rename to pkg/views/src/pages/auth/sign-in.tsx
diff --git a/pkg/view/src/pages/auth/sign-up.tsx b/pkg/views/src/pages/auth/sign-up.tsx
similarity index 100%
rename from pkg/view/src/pages/auth/sign-up.tsx
rename to pkg/views/src/pages/auth/sign-up.tsx
diff --git a/pkg/view/src/pages/landing.tsx b/pkg/views/src/pages/landing.tsx
similarity index 100%
rename from pkg/view/src/pages/landing.tsx
rename to pkg/views/src/pages/landing.tsx
diff --git a/pkg/view/src/scripts/request.ts b/pkg/views/src/scripts/request.ts
similarity index 100%
rename from pkg/view/src/scripts/request.ts
rename to pkg/views/src/scripts/request.ts
diff --git a/pkg/view/src/stores/userinfo.tsx b/pkg/views/src/stores/userinfo.tsx
similarity index 100%
rename from pkg/view/src/stores/userinfo.tsx
rename to pkg/views/src/stores/userinfo.tsx
diff --git a/pkg/view/src/stores/wellKnown.tsx b/pkg/views/src/stores/wellKnown.tsx
similarity index 100%
rename from pkg/view/src/stores/wellKnown.tsx
rename to pkg/views/src/stores/wellKnown.tsx
diff --git a/pkg/view/src/theme.ts b/pkg/views/src/theme.ts
similarity index 100%
rename from pkg/view/src/theme.ts
rename to pkg/views/src/theme.ts
diff --git a/pkg/view/src/vite-env.d.ts b/pkg/views/src/vite-env.d.ts
similarity index 100%
rename from pkg/view/src/vite-env.d.ts
rename to pkg/views/src/vite-env.d.ts
diff --git a/pkg/view/tsconfig.json b/pkg/views/tsconfig.json
similarity index 100%
rename from pkg/view/tsconfig.json
rename to pkg/views/tsconfig.json
diff --git a/pkg/view/tsconfig.node.json b/pkg/views/tsconfig.node.json
similarity index 100%
rename from pkg/view/tsconfig.node.json
rename to pkg/views/tsconfig.node.json
diff --git a/pkg/view/uno.config.ts b/pkg/views/uno.config.ts
similarity index 100%
rename from pkg/view/uno.config.ts
rename to pkg/views/uno.config.ts
diff --git a/pkg/view/vite.config.ts b/pkg/views/vite.config.ts
similarity index 100%
rename from pkg/view/vite.config.ts
rename to pkg/views/vite.config.ts