Skip to content

Commit

Permalink
iroiro fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Simirall committed Sep 17, 2024
1 parent 627e414 commit 931dd9d
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 17 deletions.
4 changes: 4 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
},
"linter": {
"rules": {
"correctness": {
"noUnusedImports": "warn",
"noUnusedVariables": "warn"
},
"style": {
"noNonNullAssertion": "warn"
}
Expand Down
2 changes: 1 addition & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ReactDOM from "react-dom/client";
import { SWRConfig } from "swr";

import { Router } from "./Router";
import { theme, config } from "./theme/theme";
import { config, theme } from "./theme/theme";
import { fetcher } from "./utils/fetcher";

const injectThemeSchemeScript = () => {
Expand Down
24 changes: 22 additions & 2 deletions src/pages/-components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Link } from "@tanstack/react-router";
import { useMatchRoute, useNavigate } from "@tanstack/react-router";
import { Avatar, HStack, Heading } from "@yamada-ui/react";

import { HeaderMenu } from "./HeaderMenu";
Expand All @@ -8,6 +8,8 @@ import { useMySelfStore } from "@/store/user";

export const Header = () => {
const { mySelf } = useMySelfStore();
const navigate = useNavigate();
const matchRoute = useMatchRoute();

return (
<HStack
Expand All @@ -16,8 +18,26 @@ export const Header = () => {
py="2"
bg="bg"
color="darkText"
pos="sticky"
top="0"
zIndex="1"
>
<Heading size="lg" isTruncated fontWeight="light" as={Link} to="/">
<Heading
size="lg"
isTruncated
fontWeight="light"
cursor="pointer"
onClick={() => {
if (matchRoute({ to: "/" })) {
window.scroll({
top: 0,
behavior: "smooth",
});
} else {
navigate({ to: "/" });
}
}}
>
at Dusk.
</Heading>
{mySelf ? (
Expand Down
5 changes: 3 additions & 2 deletions src/pages/-components/HeaderMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Menu,
MenuButton,
MenuList,
VStack,
useDisclosure,
} from "@yamada-ui/react";

Expand All @@ -19,9 +20,9 @@ export const HeaderMenu = () => {
<DotsNine size={20} weight="bold" />
</MenuButton>

<MenuList alignItems="center" gap="md">
<MenuList as={VStack} px="2">
<LogoutButton />
<HStack>
<HStack justify="center">
<ToggleThemeButton />
<ToggleColorModeButton />
</HStack>
Expand Down
8 changes: 7 additions & 1 deletion src/pages/-components/LogoutDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Dialog } from "@yamada-ui/react";

import { useLoginStore } from "@/store/login";
import { useNavigate } from "@tanstack/react-router";

export const LogoutDialog = ({
isOpen,
Expand All @@ -10,12 +11,17 @@ export const LogoutDialog = ({
onClose: () => void;
}) => {
const { logout } = useLoginStore();
const navigate = useNavigate();

return (
<Dialog
isOpen={isOpen}
header="ログアウトしますか?"
success="する"
onSuccess={logout}
onSuccess={() => {
logout();
navigate({ to: "/login" });
}}
cancel="しない"
onCancel={onClose}
/>
Expand Down
83 changes: 74 additions & 9 deletions src/routeTree.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,80 @@ declare module "@tanstack/react-router" {

// Create and export the route tree

export const routeTree = rootRoute.addChildren({
IndexRoute,
LoginRoute: LoginRoute.addChildren({
LoginLayoutRoute: LoginLayoutRoute.addChildren({
LoginLayoutGetTokenRoute,
LoginLayoutIndexLazyRoute,
}),
}),
})
interface LoginLayoutRouteChildren {
LoginLayoutGetTokenRoute: typeof LoginLayoutGetTokenRoute
LoginLayoutIndexLazyRoute: typeof LoginLayoutIndexLazyRoute
}

const LoginLayoutRouteChildren: LoginLayoutRouteChildren = {
LoginLayoutGetTokenRoute: LoginLayoutGetTokenRoute,
LoginLayoutIndexLazyRoute: LoginLayoutIndexLazyRoute,
}

const LoginLayoutRouteWithChildren = LoginLayoutRoute._addFileChildren(
LoginLayoutRouteChildren,
)

interface LoginRouteChildren {
LoginLayoutRoute: typeof LoginLayoutRouteWithChildren
}

const LoginRouteChildren: LoginRouteChildren = {
LoginLayoutRoute: LoginLayoutRouteWithChildren,
}

const LoginRouteWithChildren = LoginRoute._addFileChildren(LoginRouteChildren)

export interface FileRoutesByFullPath {
"/": typeof IndexRoute
"/login": typeof LoginLayoutRouteWithChildren
"/login/getToken": typeof LoginLayoutGetTokenRoute
"/login/": typeof LoginLayoutIndexLazyRoute
}

export interface FileRoutesByTo {
"/": typeof IndexRoute
"/login": typeof LoginLayoutIndexLazyRoute
"/login/getToken": typeof LoginLayoutGetTokenRoute
}

export interface FileRoutesById {
__root__: typeof rootRoute
"/": typeof IndexRoute
"/login": typeof LoginRouteWithChildren
"/login/_layout": typeof LoginLayoutRouteWithChildren
"/login/_layout/getToken": typeof LoginLayoutGetTokenRoute
"/login/_layout/": typeof LoginLayoutIndexLazyRoute
}

export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath
fullPaths: "/" | "/login" | "/login/getToken" | "/login/"
fileRoutesByTo: FileRoutesByTo
to: "/" | "/login" | "/login/getToken"
id:
| "__root__"
| "/"
| "/login"
| "/login/_layout"
| "/login/_layout/getToken"
| "/login/_layout/"
fileRoutesById: FileRoutesById
}

export interface RootRouteChildren {
IndexRoute: typeof IndexRoute
LoginRoute: typeof LoginRouteWithChildren
}

const rootRouteChildren: RootRouteChildren = {
IndexRoute: IndexRoute,
LoginRoute: LoginRouteWithChildren,
}

export const routeTree = rootRoute
._addFileChildren(rootRouteChildren)
._addFileTypes<FileRouteTypes>()

/* prettier-ignore-end */

Expand Down
2 changes: 2 additions & 0 deletions src/store/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export const useLoginStore = create<LoginState & LoginActions>()(
logout: () => {
set(() => ({
isLogin: false,
token: undefined,
instance: undefined,
}));
useMySelfStore.setState({
mySelf: undefined,
Expand Down
11 changes: 9 additions & 2 deletions src/theme/components/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@ import { initialThemeScheme } from "../theme";

import type { ComponentMultiStyle, MenuProps } from "@yamada-ui/react";

const YmdMenu: ComponentMultiStyle<MenuProps> = defaultTheme.components.Menu;
const YmdMenu: ComponentMultiStyle<"Menu", MenuProps> =
defaultTheme.components.Menu;

export const Menu: ComponentMultiStyle<MenuProps> = {
export const Menu: ComponentMultiStyle<"Menu", MenuProps> = {
baseStyle: ({ theme, themeScheme, colorMode }) => ({
...YmdMenu.baseStyle,
content: {
// @ts-expect-error contentはあります!
...YmdMenu.baseStyle?.content,
minW: "unset",
},
list: {
// @ts-expect-error listはあります!
...YmdMenu.baseStyle?.list,
Expand Down

0 comments on commit 931dd9d

Please sign in to comment.