-
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.
* feat(web): add header * refactor(web): load alert once * feat(web): add drawer
- Loading branch information
1 parent
4848fe6
commit d9e019e
Showing
14 changed files
with
197 additions
and
94 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { AlertProps, SnackbarProps } from '@mui/material'; | ||
import create from 'zustand'; | ||
|
||
export type AlertState = Pick<AlertProps, 'severity'> & | ||
Pick<SnackbarProps, 'open'> & { message: string }; | ||
|
||
export const useAlertStore = create<AlertState>(() => ({ message: '' })); |
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,6 @@ | ||
import { DrawerProps } from '@mui/material'; | ||
import create from 'zustand'; | ||
|
||
export type DrawerState = Pick<DrawerProps, 'open'>; | ||
|
||
export const useDrawerStore = create<DrawerState>(() => ({ open: false })); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 8 additions & 14 deletions
22
web/src/adapters/userInterface/components/atoms/alert/index.tsx
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
19 changes: 19 additions & 0 deletions
19
web/src/adapters/userInterface/components/organisms/drawer/index.tsx
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,19 @@ | ||
import React from 'react'; | ||
|
||
import { Box, Drawer as MUIDrawer } from '@mui/material'; | ||
|
||
import { DrawerState } from '../../../../stores/drawer'; | ||
|
||
type Props = DrawerState & { onClose: () => void }; | ||
|
||
export const DrawerContent = () => <Box>sidebar</Box>; | ||
|
||
export default function Drawer({ onClose, open }: Props) { | ||
return ( | ||
<MUIDrawer onClose={onClose} open={open}> | ||
<Box p={3}> | ||
<DrawerContent /> | ||
</Box> | ||
</MUIDrawer> | ||
); | ||
} |
33 changes: 33 additions & 0 deletions
33
web/src/adapters/userInterface/components/organisms/header/index.tsx
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,33 @@ | ||
import * as React from 'react'; | ||
|
||
import { Menu } from '@mui/icons-material'; | ||
import { AppBar, Box, Button, Container, IconButton, Toolbar } from '@mui/material'; | ||
|
||
import Logo from '../../../assets/logo/black.png'; | ||
|
||
type Props = { handleDrawerOpen: () => void; handleSignOut: () => void }; | ||
|
||
export default function Header({ handleDrawerOpen, handleSignOut }: Props) { | ||
return ( | ||
<AppBar color="secondary" position="static" sx={{ boxShadow: '0 0 64px 0 rgba(0, 0, 0, .15)' }}> | ||
<Container maxWidth="xl"> | ||
<Toolbar disableGutters> | ||
<IconButton | ||
aria-controls="menu-appbar" | ||
aria-haspopup="true" | ||
aria-label="account of current user" | ||
color="primary" | ||
onClick={handleDrawerOpen} | ||
size="large" | ||
sx={{ display: { xs: 'flex', md: 'none' } }} | ||
> | ||
<Menu /> | ||
</IconButton> | ||
<Box component="img" height={24} src={Logo} /> | ||
<Box flexGrow={1} /> | ||
<Button onClick={handleSignOut}>ログアウト</Button> | ||
</Toolbar> | ||
</Container> | ||
</AppBar> | ||
); | ||
} |
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 |
---|---|---|
@@ -1,28 +1,11 @@ | ||
import React, { useState } from 'react'; | ||
import React from 'react'; | ||
|
||
import { Box, Button, Typography } from '@mui/material'; | ||
|
||
import useUserUseCase from '../../../application/useCases/user'; | ||
import userRepository from '../../repositories/user'; | ||
import Alert, { AlertProps } from '../components/atoms/alert'; | ||
import { Box, Typography } from '@mui/material'; | ||
|
||
export default function Authenticated() { | ||
const [alertOptions, setAlertOptions] = useState<AlertProps['options']>(); | ||
const { signOut } = useUserUseCase(userRepository()); | ||
|
||
const handleSignOut = async () => { | ||
await signOut().catch(({ message }: Error) => setAlertOptions({ message, severity: 'error' })); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Alert onClose={() => setAlertOptions(undefined)} options={alertOptions} /> | ||
<Box> | ||
<Typography>signed in.</Typography> | ||
<Button onClick={handleSignOut} variant="outlined"> | ||
sign out | ||
</Button> | ||
</Box> | ||
</> | ||
<Box> | ||
<Typography>signed in.</Typography> | ||
</Box> | ||
); | ||
} |
Oops, something went wrong.