generated from jphacks/JP_sample
-
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.
Merge pull request #44 from jphacks/feat/40-user-number
Headerにユーザー数表示
- Loading branch information
Showing
12 changed files
with
200 additions
and
33 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Empty file.
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,32 @@ | ||
import React, { useState } from "react"; | ||
import UserListModal from "../UserListModal/UserListModal"; | ||
import styles from "./UserList.module.scss"; | ||
import { IconButton, Badge } from "@mui/material"; | ||
import PersonIcon from "@mui/icons-material/Person"; | ||
import { updateEventInterface } from "@/types/interface"; | ||
interface UserListProps { | ||
users: updateEventInterface[]; | ||
} | ||
export default function UserList({ users }: UserListProps) { | ||
const [open, setOpen] = useState(false); | ||
|
||
const handleClick = () => { | ||
setOpen(true); | ||
}; | ||
return ( | ||
<div className={styles.userListContainer}> | ||
<UserListModal | ||
userNames={users.map( | ||
(user) => user.name + " #" + user.addressHash.slice(0, 4) | ||
)} | ||
modalOpen={open} | ||
setModalOpen={setOpen} | ||
/> | ||
<IconButton onClick={handleClick} style={{ paddingTop: "13px" }}> | ||
<Badge badgeContent={users.length} color="secondary"> | ||
<PersonIcon /> | ||
</Badge> | ||
</IconButton> | ||
</div> | ||
); | ||
} |
15 changes: 15 additions & 0 deletions
15
frontend/src/components/Header/UserListModal/UserLIstModal.module.scss
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,15 @@ | ||
.modalBox { | ||
position: absolute; | ||
top: 50%; | ||
left: 50%; | ||
width: 400px; | ||
padding: 16px 32px 24px; | ||
background-color: #fff; | ||
border: 2px solid #000; | ||
box-shadow: 24px; | ||
transform: translate(-50%, -50%); | ||
} | ||
|
||
.modalButton { | ||
float: right; | ||
} |
75 changes: 75 additions & 0 deletions
75
frontend/src/components/Header/UserListModal/UserListModal.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,75 @@ | ||
import * as React from "react"; | ||
import { | ||
Modal, | ||
Box, | ||
Button, | ||
Typography, | ||
List, | ||
ListItem, | ||
ListItemAvatar, | ||
Avatar, | ||
ListItemText, | ||
} from "@mui/material"; | ||
|
||
import styles from "./UserListModal.module.scss"; | ||
|
||
interface UserListModalProps { | ||
userNames: string[]; | ||
modalOpen: boolean; | ||
setModalOpen: React.Dispatch<React.SetStateAction<boolean>>; | ||
} | ||
|
||
export default function UserListModal({ | ||
userNames, | ||
modalOpen, | ||
setModalOpen, | ||
}: UserListModalProps) { | ||
const handleClose = () => { | ||
setModalOpen(false); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Modal | ||
open={modalOpen} | ||
onClose={handleClose} | ||
aria-labelledby="parent-modal-title" | ||
aria-describedby="parent-modal-description" | ||
> | ||
<Box | ||
className={styles.modalBox} | ||
style={{ | ||
width: "min(90vw, 300px)", | ||
boxSizing: "border-box", | ||
padding: "16px 22px 15px", | ||
border: "none", | ||
borderRadius: "15px", | ||
backgroundColor: "white", | ||
margin: "auto", | ||
}} | ||
> | ||
<Typography variant="h6" id="user-list-modal-title"> | ||
ユーザーリスト | ||
</Typography> | ||
<List | ||
style={{ | ||
overflowWrap: "break-word", | ||
}} | ||
> | ||
{userNames.map((user, index) => ( | ||
<ListItem key={index} style={{ borderBottom: "1px solid #ccc" }}> | ||
<ListItemAvatar> | ||
<Avatar>{user.charAt(0)}</Avatar> | ||
</ListItemAvatar> | ||
<ListItemText primary={user} /> | ||
</ListItem> | ||
))} | ||
</List> | ||
<Button className={styles.modalButton} onClick={handleClose}> | ||
閉じる | ||
</Button> | ||
</Box> | ||
</Modal> | ||
</> | ||
); | ||
} |
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