-
Notifications
You must be signed in to change notification settings - Fork 1
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 #107 from su-its/fix/header/usercard-width
Fix/header/usercard width
- Loading branch information
Showing
2 changed files
with
19 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,42 @@ | ||
import React from "react"; | ||
import { Avatar, Box, Text, HStack, VStack } from "@chakra-ui/react"; | ||
import { Avatar, Text, HStack, VStack, Spacer } from "@chakra-ui/react"; | ||
import type { StackProps } from "@chakra-ui/react"; | ||
import { getCurrentUser } from "@/app/actions"; | ||
import type { User } from "@/types/user"; | ||
|
||
interface UserCardPresenterProps { | ||
interface UserCardPresenterProps extends StackProps { | ||
user?: User; | ||
} | ||
|
||
export const UserCardPresenter = ({ user }: UserCardPresenterProps) => { | ||
export const UserCardPresenter = ({ user, ...rest }: UserCardPresenterProps) => { | ||
const props: StackProps = { | ||
width: rest?.width ?? "18%", | ||
...rest, | ||
}; | ||
|
||
return ( | ||
<HStack spacing={4} bg="blue.600"> | ||
<HStack spacing={4} bg="blue.600" {...props}> | ||
<Avatar | ||
src={"https://www.shizuoka.ac.jp/cms/files/shizudai/MASTER/0100/uISrbYCb_VL033_r03.png"} | ||
boxSize="100px" | ||
borderRadius="0" | ||
/> | ||
<VStack align="start" paddingRight="8px"> | ||
<Text fontSize="lg" fontWeight="bold" color="white"> | ||
<Spacer /> | ||
<VStack align="start" overflow="hidden"> | ||
<Text fontSize="lg" fontWeight="bold" color="white" isTruncated width="90%"> | ||
名前: {user ? user.handleName : "ログインしていません"} | ||
</Text> | ||
<Text color="white">学籍番号: {user ? user.studentNumber : "未ログイン"}</Text> | ||
<Text color="white" width="90%" isTruncated> | ||
学籍番号: {user ? user.studentNumber : "未ログイン"} | ||
</Text> | ||
</VStack> | ||
</HStack> | ||
); | ||
}; | ||
|
||
const UserCard = async () => { | ||
const UserCard = async (props?: StackProps) => { | ||
const user = await getCurrentUser(); | ||
return <UserCardPresenter user={user} />; | ||
return <UserCardPresenter user={user} {...props} />; | ||
}; | ||
|
||
export default UserCard; |
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