-
Notifications
You must be signed in to change notification settings - Fork 6
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
Showing
195 changed files
with
10,826 additions
and
925 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
48 changes: 48 additions & 0 deletions
48
apps/swirl-docs/src/components/Documentation/Expandable.tsx
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,48 @@ | ||
import { ReactNode, useState } from "react"; | ||
import { SwirlIconAdd, SwirlIconRemove } from "@getflip/swirl-components-react"; | ||
import { AnimatePresence, motion } from "framer-motion"; | ||
|
||
interface ExpandableProps { | ||
children: ReactNode; | ||
} | ||
|
||
export function Expandable({ children }: ExpandableProps) { | ||
const [isExpanded, setIsExpanded] = useState(false); | ||
|
||
function toggle() { | ||
setIsExpanded((expanded) => !expanded); | ||
} | ||
|
||
return ( | ||
<div className="mt-space-8 empty:mt-0"> | ||
<button | ||
className="inline-flex items-center gap-space-4 font-medium text-font-size-sm text-interactive-primary-default" | ||
onClick={toggle} | ||
type="button" | ||
> | ||
{!isExpanded && ( | ||
<> | ||
<SwirlIconAdd size={20}/> Expand | ||
</> | ||
)} | ||
{isExpanded && ( | ||
<> | ||
<SwirlIconRemove size={20}/> Collapse | ||
</> | ||
)} | ||
</button> | ||
<AnimatePresence> | ||
{isExpanded && ( | ||
<motion.div | ||
initial={{height: 0, opacity: 0, marginTop: 0}} | ||
animate={{height: "auto", opacity: 1, marginTop: 16}} | ||
exit={{height: 0, opacity: 0, marginTop: 0}} | ||
style={{originY: 0, overflow: "hidden"}} | ||
> | ||
{children} | ||
</motion.div> | ||
)} | ||
</AnimatePresence> | ||
</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
Oops, something went wrong.