-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
collapsible items in univ home page and chapter requests (#145)
* collapsible items in univ home page and chapter requests * Incorporate PR feedback --------- Co-authored-by: nickbar01234 <[email protected]>
- Loading branch information
1 parent
2ec1fc3
commit 8ab1f3e
Showing
3 changed files
with
121 additions
and
73 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,44 @@ | ||
"use client"; | ||
|
||
import React from "react"; | ||
import { faCaretDown, faCaretRight } from "@fortawesome/free-solid-svg-icons"; | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
|
||
interface DropDownContainerProps { | ||
classname?: string; | ||
title?: React.ReactNode; | ||
children?: React.ReactNode; | ||
} | ||
|
||
const DropDownContainer = (props: DropDownContainerProps) => { | ||
const [showItems, setShowItems] = React.useState(false); | ||
|
||
const handleClick = () => { | ||
setShowItems(!showItems); | ||
}; | ||
|
||
return ( | ||
<div className={props.classname ?? ""}> | ||
<div className="flex cursor-pointer" onClick={handleClick}> | ||
<div className="h-full pr-2"> | ||
<FontAwesomeIcon icon={showItems ? faCaretDown : faCaretRight} /> | ||
</div> | ||
{props.title} | ||
</div> | ||
<div | ||
className={`overflow-scroll ${ | ||
showItems ? "max-h-[512px] md:max-h-[1024px]" : "max-h-0" | ||
}`} | ||
style={ | ||
showItems | ||
? { transition: "max-height 1s ease" } | ||
: { transition: "max-height 0.3s ease" } | ||
} | ||
> | ||
{props.children} | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DropDownContainer; |