-
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 #1 from aki-0517/feat/user-list
add Card component
- Loading branch information
Showing
5 changed files
with
425 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import type { NextPage } from "next"; | ||
import { CardList } from "~~/components/CardList"; | ||
|
||
const UserListPage: NextPage = () => { | ||
const cards = [ | ||
{ | ||
title: "引換券", | ||
issueDate: "2024.12.05", | ||
amount: 7000, | ||
expiryDate: "2025.06.30", | ||
usageScope: "店舗全体", | ||
}, | ||
{ | ||
title: "引換券", | ||
issueDate: "2024.12.05", | ||
amount: 7000, | ||
expiryDate: "2025.06.30", | ||
usageScope: "店舗全体", | ||
}, | ||
{ | ||
title: "引換券", | ||
issueDate: "2024.12.05", | ||
amount: 7000, | ||
expiryDate: "2025.06.30", | ||
usageScope: "店舗全体", | ||
}, | ||
{ | ||
title: "引換券", | ||
issueDate: "2024.12.05", | ||
amount: 7000, | ||
expiryDate: "2025.06.30", | ||
usageScope: "店舗全体", | ||
}, | ||
]; | ||
|
||
return <CardList cards={cards} />; | ||
}; | ||
|
||
export default UserListPage; |
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,65 @@ | ||
"use client"; | ||
|
||
import React from "react"; | ||
import { Box, CardContent, Card as MuiCard, Typography } from "@mui/material"; | ||
|
||
type CardProps = { | ||
title: string; // タイトル | ||
issueDate: string; // 発行日 | ||
amount: number; // 金額 | ||
expiryDate: string; // 有効期限 | ||
usageScope: string; // 使用範囲 | ||
}; | ||
|
||
export const Card = ({ title, issueDate, amount, expiryDate, usageScope }: CardProps) => { | ||
return ( | ||
<MuiCard | ||
sx={{ | ||
width: 300, | ||
borderRadius: 2, | ||
boxShadow: 3, | ||
backgroundColor: "#f9f9f9", | ||
}} | ||
> | ||
<CardContent> | ||
<Typography variant="h4" sx={{ fontWeight: "bold", marginBottom: 3, textAlign: "center" }}> | ||
{title} | ||
</Typography> | ||
|
||
<Typography variant="body2" color="text.secondary" sx={{ textAlign: "right", marginBottom: 2 }}> | ||
{issueDate} 発行 | ||
</Typography> | ||
|
||
<Box | ||
sx={{ | ||
fontSize: "24px", | ||
fontWeight: "bold", | ||
textAlign: "center", | ||
color: "#000", | ||
marginBottom: 3, | ||
}} | ||
> | ||
{amount}円 | ||
</Box> | ||
|
||
<Box | ||
sx={{ | ||
display: "flex", | ||
justifyContent: "space-between", | ||
fontSize: "14px", | ||
color: "text.secondary", | ||
marginBottom: 2, | ||
}} | ||
> | ||
<Typography variant="body2" color="text.secondary"> | ||
有効期限: {expiryDate} | ||
</Typography> | ||
</Box> | ||
|
||
<Typography variant="body2" color="text.secondary"> | ||
使用範囲: {usageScope} | ||
</Typography> | ||
</CardContent> | ||
</MuiCard> | ||
); | ||
}; |
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,41 @@ | ||
import React from "react"; | ||
import { Card } from "~~/components/Card"; | ||
|
||
type CardData = { | ||
title: string; | ||
issueDate: string; | ||
amount: number; | ||
expiryDate: string; | ||
usageScope: string; | ||
}; | ||
|
||
type CardListProps = { | ||
cards: CardData[]; | ||
}; | ||
|
||
export const CardList = ({ cards }: CardListProps) => { | ||
return ( | ||
<div | ||
style={{ | ||
display: "grid", | ||
gridTemplateColumns: "repeat(auto-fit, minmax(300px, 1fr))", | ||
gap: "16px", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
width: "70%", | ||
margin: "100px auto", | ||
}} | ||
> | ||
{cards.map((card, index) => ( | ||
<Card | ||
key={index} | ||
title={card.title} | ||
issueDate={card.issueDate} | ||
amount={card.amount} | ||
expiryDate={card.expiryDate} | ||
usageScope={card.usageScope} | ||
/> | ||
))} | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.