generated from mateusfg7/nextjs-setup
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(post): create Spoiler component
- Loading branch information
Showing
2 changed files
with
35 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use client' | ||
|
||
import { EyeSlash } from '@phosphor-icons/react/dist/ssr' | ||
import { ComponentProps, useState } from 'react' | ||
|
||
export function Spoiler({ children, ...rest }: ComponentProps<'div'>) { | ||
const [hide, setHide] = useState(true) | ||
|
||
return ( | ||
<div {...rest} className="relative w-full"> | ||
<div data-hide={hide} className="w-full data-[hide='true']:blur-lg"> | ||
{children} | ||
</div> | ||
<div | ||
data-hide={hide} | ||
className="absolute inset-0 flex items-center justify-center data-[hide='false']:hidden" | ||
> | ||
<div className="divide-y divide-neutral-200 text-center dark:divide-neutral-500"> | ||
<div className="flex justify-center py-2 text-3xl"> | ||
<EyeSlash size="1em" /> | ||
</div> | ||
<button | ||
className="py-2 hover:underline" | ||
onClick={() => setHide(false)} | ||
> | ||
Show content | ||
</button> | ||
</div> | ||
</div> | ||
</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