Skip to content

Commit

Permalink
feat: add custom accordion component
Browse files Browse the repository at this point in the history
  • Loading branch information
Prajwalism committed Jul 2, 2024
1 parent dcf84d5 commit a5e9ea5
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/frontend/src/components/common/Accordion/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { useState } from 'react';
import { FlexRow } from '../Layouts';
import Icon from '../Icon';

interface IAccordionProps {
open: boolean;
title: string;
description: string;
}

export default function Accordion({
open = false,
title,
description,
}: IAccordionProps) {
const [isOpen, setIsOpen] = useState(open);
return (
<div className="naxatw-border-b naxatw-border-b-[#A9A9A9] naxatw-py-8">
<FlexRow className="naxatw-items-center naxatw-justify-between">
<p className="naxatw-text-[1.5rem] naxatw-leading-[2rem] md:naxatw-text-[2rem] md:naxatw-leading-[40px]">
{title}
</p>
<button type="button" onClick={() => setIsOpen(!isOpen)}>
{!isOpen ? (
<Icon name="add_circle_outline" />
) : (
<Icon name="remove_circle_outline" />
)}
</button>
</FlexRow>
{isOpen && (
<p className="naxatw-mt-4 naxatw-text-[1rem] md:naxatw-text-xl md:naxatw-leading-[33px]">
{description}
</p>
)}
</div>
);
}

0 comments on commit a5e9ea5

Please sign in to comment.