generated from SatooRu65536/tpl-remix-vite
-
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 #20 from /issues/17-feat-member-list-page
部員一覧画面を追加
- Loading branch information
Showing
16 changed files
with
382 additions
and
52 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,32 @@ | ||
import { styled } from 'restyle'; | ||
|
||
interface Props extends React.HTMLAttributes<HTMLDetailsElement> { | ||
title: string; | ||
children: React.ReactNode; | ||
open?: boolean; | ||
} | ||
|
||
const Details = styled('details', { | ||
padding: '10px 0', | ||
}); | ||
|
||
const Summary = styled('summary', { | ||
userSelect: 'none', | ||
cursor: 'pointer', | ||
}); | ||
|
||
const Title = styled('h2', { | ||
display: 'inline', | ||
}); | ||
|
||
export default function Accordion({ title, children, open, ...props }: Props) { | ||
return ( | ||
<Details open={open} {...props}> | ||
<Summary> | ||
<Title>{title}</Title> | ||
</Summary> | ||
|
||
{children} | ||
</Details> | ||
); | ||
} |
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,94 @@ | ||
import type { Member } from '@/types/member'; | ||
import { Text } from '@/components/basic'; | ||
import { Link } from '@remix-run/react'; | ||
import { useMemo } from 'react'; | ||
import { styled } from 'restyle'; | ||
|
||
interface Props { | ||
member: Member['public']; | ||
} | ||
|
||
const CardRoot = styled('article', { | ||
'width': '100%', | ||
'boxShadow': '0 0 1px var(--shadow-color)', | ||
'borderRadius': 'var(--radius-md)', | ||
'overflow': 'hidden', | ||
|
||
'@media (width <= 500px)': { | ||
display: 'grid', | ||
gridTemplateColumns: 'auto 1fr', | ||
}, | ||
}); | ||
|
||
const CardLink = styled(Link, { | ||
'textDecoration': 'none', | ||
'@media (width <= 500px)': { | ||
display: 'grid', | ||
gridTemplateColumns: 'subgrid', | ||
gridColumn: '1 / -1', | ||
}, | ||
}); | ||
|
||
const AspectRatioStyled = styled('div', { | ||
'overflow': 'hidden', | ||
|
||
'@media (width <= 500px)': { | ||
height: '150px', | ||
aspectRatio: '1/1', | ||
}, | ||
'@media (width > 500px)': { | ||
aspectRatio: '3/2', | ||
}, | ||
}); | ||
|
||
const CardThumbnail = styled('img', { | ||
width: '100%', | ||
height: '100%', | ||
objectFit: 'cover', | ||
}); | ||
|
||
const CardBody = styled('div', { | ||
'padding': 10, | ||
|
||
'@media (width <= 500px)': { | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}, | ||
}); | ||
|
||
export default function Card({ member }: Props) { | ||
const title = useMemo(() => { | ||
if (member.type === 'active' && member.position) { | ||
return `${member.lastName} ${member.firstName} (${member.position})`; | ||
} | ||
return `${member.lastName} ${member.firstName}`; | ||
}, [member]); | ||
|
||
const subTitle = useMemo(() => { | ||
if (member.type === 'active') { | ||
return `${member.studentId}`; | ||
} else if (member.type === 'alumni') { | ||
return `${member.graduationYear}年卒`; | ||
} else if (member.type === 'external') { | ||
return member.organization; | ||
} | ||
}, [member]); | ||
|
||
return ( | ||
<CardRoot> | ||
<CardLink to={`/member/${member.uuid}`}> | ||
<AspectRatioStyled> | ||
<CardThumbnail alt={member.slackDisplayName} src={member.iconUrl} /> | ||
</AspectRatioStyled> | ||
|
||
<CardBody> | ||
<div> | ||
<Text bold size="lg">{title}</Text> | ||
<Text nowrap overflow="hidden" textOverflow="ellipsis">{subTitle}</Text> | ||
</div> | ||
</CardBody> | ||
</CardLink> | ||
</CardRoot> | ||
); | ||
} |
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
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,43 @@ | ||
import type { Member } from '@/types/member'; | ||
import Accordion from '@/components/Accordion'; | ||
import Card from '@/components/Card'; | ||
import { GRADES } from '@/consts/member'; | ||
import { toTypeName } from '@/utils'; | ||
import { styled } from 'restyle'; | ||
|
||
interface Props { | ||
members: Record<string, Array<Member['public']>>; | ||
} | ||
|
||
const ORDER = [...GRADES, 'external', 'alumni']; | ||
|
||
const Container = styled('div', { | ||
padding: '50px 20px', | ||
}); | ||
|
||
const Grid = styled('div', { | ||
padding: '20px 20px', | ||
display: 'grid', | ||
gridTemplateColumns: 'repeat(auto-fill, minmax(200px, 1fr))', | ||
gap: 20, | ||
}); | ||
|
||
export default function MemberListPage({ members }: Props) { | ||
const sortedMembers = Object.entries(members).sort(([a], [b]) => ORDER.indexOf(a) - ORDER.indexOf(b)); | ||
|
||
return ( | ||
<Container> | ||
{ | ||
sortedMembers.map(([key, member]) => ( | ||
<Accordion key={key} open title={toTypeName(key) ?? key}> | ||
<Grid> | ||
{member.map((member) => ( | ||
<Card key={member.uuid} member={member} /> | ||
))} | ||
</Grid> | ||
</Accordion> | ||
)) | ||
} | ||
</Container> | ||
); | ||
} |
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
Oops, something went wrong.