Skip to content

Commit

Permalink
feat: show content rating after tags
Browse files Browse the repository at this point in the history
  • Loading branch information
pikdum committed May 27, 2024
1 parent e1e2691 commit 5d43e49
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/components/PostDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const PostDetails = ({ post }: { post: BooruPost }) => {
};

return (
<div className="px-2 break-words text-white col-span-full text-center">
<div className="px-2 break-words col-span-full text-center">
{post.tags
?.map((e) => decode(e))
?.map((tag) => (
Expand All @@ -47,6 +47,20 @@ export const PostDetails = ({ post }: { post: BooruPost }) => {
{tag}
</button>
))}
<button
type="button"
className={classNames(
"text-white text-xs font-semibold p-1 px-3 m-1 rounded-full cursor-default",
{
"bg-green-500": post.rating === "general",
"bg-yellow-500": post.rating === "sensitive",
"bg-orange-500": post.rating === "questionable",
"bg-red-500": post.rating === "explicit",
},
)}
>
{post.rating}
</button>
</div>
);
};
2 changes: 2 additions & 0 deletions src/lib/booru/gelbooru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type GelbooruPost = {
file_url: string;
preview_url: string;
sample_url: string;
rating: string;
};

type GelbooruTag = {
Expand Down Expand Up @@ -78,6 +79,7 @@ export class Gelbooru {
sampleUrl: p.sample_url || null,
height: p.height,
width: p.width,
rating: p.rating,
})) || [],
hasNextPage: a.count > a.limit + a.offset,
};
Expand Down
1 change: 1 addition & 0 deletions src/lib/booru/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type BooruPost = {
sampleUrl: string | null;
height: number;
width: number;
rating: string;
};

export type BooruTag = {
Expand Down

0 comments on commit 5d43e49

Please sign in to comment.