-
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 #30 from canisterism/search
- Loading branch information
Showing
17 changed files
with
460 additions
and
281 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,19 @@ | ||
import Image from "next/image"; | ||
type Props = { | ||
imageUrl: string | undefined; | ||
title: string; | ||
}; | ||
|
||
export default function GameImage({ imageUrl, title }: Props) { | ||
return ( | ||
<div className="aspect-h-4 aspect-w-3 overflow-hidden rounded-lg bg-gray-200 "> | ||
<Image | ||
src={imageUrl ? `${imageUrl}` : "https://placeimg.com/320/400/any"} | ||
alt={`${title}`} | ||
className="h-full w-full object-cover object-center" | ||
layout="fill" | ||
objectFit="cover" | ||
/> | ||
</div> | ||
); | ||
} |
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,31 @@ | ||
import { classNames } from "@/lib/classNames"; | ||
import { StarIcon } from "@heroicons/react/20/solid"; | ||
|
||
export default function RatingStars({ | ||
rating, | ||
size = "md", | ||
}: { | ||
rating: number; | ||
size: "sm" | "md" | "lg"; | ||
}) { | ||
const sizeClass = { | ||
sm: "h-5 w-5", | ||
md: "h-6 w-6", | ||
lg: "h-9 w-9", | ||
}[size]; | ||
|
||
return ( | ||
<div className="flex items-start"> | ||
{[0, 1, 2, 3, 4].map((n) => ( | ||
<StarIcon | ||
key={n} | ||
className={classNames( | ||
Math.floor(rating) > n ? "text-yellow-400" : "text-gray-100", | ||
`${sizeClass} flex-shrink-0` | ||
)} | ||
aria-hidden="true" | ||
/> | ||
))} | ||
</div> | ||
); | ||
} |
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,81 @@ | ||
import RatingStars from "@/components/Game/RatingStars"; | ||
import { FragmentType, graphql, useFragment } from "@/graphql/generated"; | ||
import { format } from "date-fns"; | ||
import Image from "next/image"; | ||
import Link from "next/link"; | ||
|
||
export const ReviewListItemFragment = graphql(` | ||
fragment ReviewListItemFragment on Review { | ||
id | ||
body | ||
rating | ||
createdAt | ||
profile { | ||
id | ||
displayName | ||
photoUrl | ||
} | ||
} | ||
`); | ||
|
||
type Props = { | ||
review: FragmentType<typeof ReviewListItemFragment>; | ||
}; | ||
|
||
export function ReviewListItem(props: Props) { | ||
const review = useFragment(ReviewListItemFragment, props.review); | ||
console.log({ review }); | ||
return ( | ||
<div | ||
key={review.id} | ||
className="text-gray-100 flex flex-col gap-2 p-4 bg-gray-800 rounded-md border border-gray-600" | ||
> | ||
<div className="flex"> | ||
<ProfileHeading {...review.profile} /> | ||
<div className="flex-grow" aria-hidden></div> | ||
</div> | ||
<div className="flex items-center gap-2"> | ||
<RatingStars rating={review.rating} size="md" /> | ||
<span className="text-xl font-semibold flex "> | ||
{review.rating.toFixed(1)} | ||
</span> | ||
</div> | ||
<div className="gap-1"> | ||
<p>{review.body}</p> | ||
<span className="text-gray-400 text-sm"> | ||
投稿日:{format(new Date(review.createdAt), "yyyy-MM-dd")} | ||
</span> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
function ProfileHeading({ | ||
id, | ||
photoUrl, | ||
displayName, | ||
}: { | ||
id: string; | ||
photoUrl: string | null | undefined; | ||
displayName: string | null | undefined; | ||
}) { | ||
return ( | ||
<Link href={`/users/${id}`} passHref> | ||
<a> | ||
<div className="flex gap-4"> | ||
<Image | ||
className="h-8 w-8 rounded-full bg-gray-50" | ||
src={photoUrl ?? ""} | ||
alt="profile icon" | ||
width="40" | ||
height="40" | ||
/> | ||
|
||
<span className="text-lg font-semibold text-gray-300 flex items-center"> | ||
{displayName ?? "退会済みユーザー"} | ||
</span> | ||
</div> | ||
</a> | ||
</Link> | ||
); | ||
} |
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,23 @@ | ||
type Props = { | ||
icon?: React.ReactNode; | ||
label: string; | ||
stat: string; | ||
onClick?: () => void; | ||
}; | ||
|
||
export default function StatButton({ icon, label, stat, onClick }: Props) { | ||
return ( | ||
<button | ||
className="isolate inline-flex rounded-md shadow-sm" | ||
onClick={onClick} | ||
> | ||
<div className="relative inline-flex items-center gap-x-1.5 rounded-l-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus:z-10"> | ||
{icon} | ||
{label} | ||
</div> | ||
<div className="relative -ml-px inline-flex items-center rounded-r-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus:z-10"> | ||
{stat} | ||
</div> | ||
</button> | ||
); | ||
} |
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
Oops, something went wrong.