Skip to content

Commit

Permalink
add removing blur by click
Browse files Browse the repository at this point in the history
  • Loading branch information
olexh committed Mar 5, 2024
1 parent e6021eb commit 951dcd8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
'use client';

import React from 'react';
import IconamoonCommentFill from '~icons/iconamoon/comment-fill';
import MaterialSymbolsGridViewRounded from '~icons/material-symbols/grid-view-rounded';
import MaterialSymbolsMoreHoriz from '~icons/material-symbols/more-horiz';

import Link from 'next/link';
import { useRouter } from 'next/navigation';

import AnimeCard from '@/components/anime-card';
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
Expand All @@ -17,6 +20,9 @@ interface Props {
}

const Component = ({ collection }: Props) => {
const router = useRouter();
const [spoiler, setSpoiler] = React.useState(collection.spoiler);

return (
<div className="flex flex-col gap-4">
<div className={cn('flex gap-2')}>
Expand All @@ -34,17 +40,25 @@ const Component = ({ collection }: Props) => {
</Link>
<div className="flex flex-col gap-2">
<div className="flex gap-4 items-center">
<Label asChild className={cn('line-clamp-1')}>
<Link
className={cn(
collection.spoiler &&
'blur-sm hover:blur-none',
)}
href={`/collections/${collection.reference}`}
>
<button
className={cn('text-left', spoiler && 'blur-sm')}
onClick={(e) => {
if (collection.spoiler && spoiler) {
e.preventDefault();
setSpoiler(false);
return;
}

router.push(
`/collections/${collection.reference}`,
);
}}
>
<Label className={cn('line-clamp-1')}>
{collection.title}
</Link>
</Label>
</Label>
</button>

{collection.spoiler && (
<Badge variant="warning">Спойлери</Badge>
)}
Expand Down Expand Up @@ -73,18 +87,17 @@ const Component = ({ collection }: Props) => {
{collection.tags.map((tag) => (
<Badge
key={tag}
onClick={() => setSpoiler(false)}
variant="secondary"
className={cn(
collection.spoiler && 'blur-sm hover:blur-none',
)}
className={cn(spoiler && 'blur-sm cursor-pointer')}
>
{tag.toLowerCase()}
</Badge>
))}
</div>
)}
<div className="grid grid-cols-3 md:grid-cols-5 lg:grid-cols-7 gap-4 lg:gap-8 flex-nowrap">
{collection.collection.reverse().map((item, index) => (
{[...collection.collection].reverse().map((item, index) => (
<AnimeCard
containerClassName={cn(
collection.nsfw && 'blur-sm hover:blur-none',
Expand Down
2 changes: 1 addition & 1 deletion components/ui/label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { cn } from '@/utils';


const labelVariants = cva(
'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70',
'text-sm font-medium leading-tight peer-disabled:cursor-not-allowed peer-disabled:opacity-70',
);

const Label = React.forwardRef<
Expand Down

0 comments on commit 951dcd8

Please sign in to comment.