Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

テーブル機能を実装 #6

Merged
merged 12 commits into from
May 2, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 45 additions & 18 deletions pages/users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,49 @@ const UsersPage = ({ users }: Props) => {
const [selectTypes, setSelectTypes] = useState<TableDataType[]>([]);
const onCheckFilter = (checked: boolean, type: TableDataType) => {
if (checked) setSelectTypes([...selectTypes, type]);
else setSelectTypes(selectTypes.filter(t => t !== type));
}
else setSelectTypes(selectTypes.filter((t) => t !== type));
};
return (
<div style={{ width: "100%" }} className="overflow-auto">
{allTableDataTypes.map(t => (
<div style={{ width: "90vw", margin: "auto" }} className="overflow-auto">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

左右に余白を作りたいのであれば、そもそもbootstrapのcontainerなりをしっかり利用してください。使い方などはDBのページを参考にしてください。

{allTableDataTypes.map((t) => (
<>
<input type="checkbox" key={t} onChange={(e) => { onCheckFilter(e.target.checked, t) }} />
<input
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

このまま標準の使いにくいinput使うんですか?Bootstrapのcheckboxを利用してください。

type="checkbox"
key={t}
onChange={(e) => {
onCheckFilter(e.target.checked, t);
}}
/>
{t}
</>
))}
<Table striped bordered hover style={{ tableLayout: "fixed" }}>
<Table
striped
bordered
hover
style={{ tableLayout: "fixed", overflow: "scroll" }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overflowはscrollだとX,Yどちらもスクロールが出てしまいます。autoにして必要な部分だけ表示されるようにしてください

>
<thead>
<tr>
{
// 幅は調整中。細かい調整は後ほど。
}
{selectTypes.indexOf("id") !== -1 ? <th style={{ width: 150 }}>ID</th> : <></>}

{/* 幅は調整中。細かい調整は後ほど。*/}
{selectTypes.indexOf("id") !== -1 ? (
<th style={{ width: 150 }}>ID</th>
) : (
<></>
)}
<th className="table-th-studentNumber">学籍番号</th>
<th className="table-th-username">ユーザー名</th>
<th style={{ width: 30 }}>学年</th>
<th style={{ width: 66 }}>アイコン</th>
<th style={{ width: 100 }}>Discord ID</th>
{selectTypes.indexOf("icon") !== -1 ? (
<th style={{ width: 66 }}>アイコン</th>
) : (
<></>
)}
{selectTypes.indexOf("discord") !== -1 ? (
<th style={{ width: 100 }}>Discord ID</th>
) : (
<></>
)}
<th style={{ width: 100 }}>有効期限</th>
<th style={{ width: 150 }}>自己紹介</th>
<th className="table-th-name">名字</th>
Expand All @@ -56,14 +76,21 @@ const UsersPage = ({ users }: Props) => {
{users.map((user) => (
<tr key={user.id}>
{selectTypes.indexOf("id") !== -1 ? <td>{user.id}</td> : <></>}

<td>{user.studentNumber}</td>
<td>{user.username}</td>
<td>{user.schoolGrade}</td>
<td>
<img src={user.iconUrl} alt="" style={{ width: "50px" }} />
</td>
<td>{user.discordUserId}</td>
{selectTypes.indexOf("icon") !== -1 ? (
<td>
<img src={user.iconUrl} alt="" style={{ width: "50px" }} />
</td>
) : (
<></>
)}
{selectTypes.indexOf("discord") !== -1 ? (
<td>{user.discordUserId}</td>
) : (
<></>
)}
<td>{user.activeLimit}</td>
<td>{user.shortIntroduction}</td>
<td>{user.firstName}</td>
Expand Down