-
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.
- Loading branch information
1 parent
89c25bc
commit 1faac24
Showing
6 changed files
with
467 additions
and
293 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { useEffect, useState } from 'react' | ||
import { v4 as uuid } from 'uuid' | ||
|
||
interface DetailsProps { | ||
children: React.ReactNode | ||
summary?: string | ||
} | ||
|
||
export const Details = ({ summary = 'Title', children }: DetailsProps) => { | ||
const [detailsOpen, setDetailsOpen] = useState(false) | ||
const [detailsId, setDetailsId] = useState('') | ||
|
||
useEffect(() => setDetailsId(uuid()), []) | ||
|
||
useEffect(() => { | ||
const details = document.querySelector(`details[data-details-id="${detailsId}"]`) as HTMLDetailsElement | ||
if (!details) return | ||
|
||
const handleToggle = () => setDetailsOpen(details.open) | ||
details.addEventListener('toggle', handleToggle) | ||
|
||
return () => details.removeEventListener('toggle', handleToggle) | ||
}, [detailsId]) | ||
|
||
return ( | ||
<details data-details-id={detailsId} open={detailsOpen} className='cursor-pointer'> | ||
<summary className={`bg-gray-800 ${detailsOpen ? 'rounded-t-lg' : 'rounded-lg'} px-4 py-1`}> | ||
{summary} | ||
</summary> | ||
<div className='bg-gray-700 rounded-b-lg px-4 py-1'> | ||
{children} | ||
</div> | ||
</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
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.
1faac24
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
boletim-escolar – ./
boletim-escolar-git-main-nyctibiusvii.vercel.app
boletim-escolar.vercel.app
boletim-escolar-nyctibiusvii.vercel.app