-
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
Showing
6 changed files
with
214 additions
and
37 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
import { | ||
Accordion, | ||
AccordionContent, | ||
AccordionItem, | ||
AccordionTrigger, | ||
} from './shadcn-ui/accordion'; | ||
import { methodTypes } from '@/utils/methodTypes'; | ||
|
||
const AccordionBase = ({ tag }: { tag: string }) => { | ||
const DM = methodTypes.filter((item) => item.tag === tag)[0].methods; | ||
return ( | ||
<Accordion className="flex flex-col gap-4" type="single" collapsible> | ||
{DM.map((method, index) => ( | ||
<AccordionItem | ||
key={method.title} | ||
className="rounded-[8px] bg-Green-50 px-S-12" | ||
value={`item-${index}`} | ||
> | ||
<AccordionTrigger className="text-Green-500 Title-Small"> | ||
{method.title} | ||
</AccordionTrigger> | ||
<AccordionContent className="text-Gray-600"> | ||
{method.descriptions.map((content, index) => ( | ||
<p | ||
key={`description-${index}`} | ||
className="text-Gray-600 Label-Large-Custom" | ||
> | ||
{content} | ||
</p> | ||
))} | ||
</AccordionContent> | ||
</AccordionItem> | ||
))} | ||
</Accordion> | ||
); | ||
}; | ||
|
||
export default AccordionBase; |
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,59 @@ | ||
'use client'; | ||
|
||
import * as React from 'react'; | ||
import * as AccordionPrimitive from '@radix-ui/react-accordion'; | ||
import { ChevronDown } from 'lucide-react'; | ||
|
||
import { cn } from '@/lib/utils'; | ||
import Down from '../icons/Down'; | ||
|
||
const Accordion = AccordionPrimitive.Root; | ||
|
||
const AccordionItem = React.forwardRef< | ||
React.ElementRef<typeof AccordionPrimitive.Item>, | ||
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item> | ||
>(({ className, ...props }, ref) => ( | ||
<AccordionPrimitive.Item | ||
ref={ref} | ||
className={cn('border-b', className)} | ||
{...props} | ||
/> | ||
)); | ||
AccordionItem.displayName = 'AccordionItem'; | ||
|
||
const AccordionTrigger = React.forwardRef< | ||
React.ElementRef<typeof AccordionPrimitive.Trigger>, | ||
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger> | ||
>(({ className, children, ...props }, ref) => ( | ||
<AccordionPrimitive.Header className="flex"> | ||
<AccordionPrimitive.Trigger | ||
ref={ref} | ||
className={cn( | ||
'flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180', | ||
className, | ||
)} | ||
{...props} | ||
> | ||
{children} | ||
<Down /> | ||
</AccordionPrimitive.Trigger> | ||
</AccordionPrimitive.Header> | ||
)); | ||
AccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName; | ||
|
||
const AccordionContent = React.forwardRef< | ||
React.ElementRef<typeof AccordionPrimitive.Content>, | ||
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content> | ||
>(({ className, children, ...props }, ref) => ( | ||
<AccordionPrimitive.Content | ||
ref={ref} | ||
className="overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down" | ||
{...props} | ||
> | ||
<div className={cn('pb-4 pt-0', className)}>{children}</div> | ||
</AccordionPrimitive.Content> | ||
)); | ||
|
||
AccordionContent.displayName = AccordionPrimitive.Content.displayName; | ||
|
||
export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }; |
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 |
---|---|---|
@@ -1,51 +1,43 @@ | ||
import { useState } from 'react'; | ||
import Down from '../icons/Down'; | ||
import Up from '../icons/Up'; | ||
import { methodTypes } from '@/utils/methodTypes'; | ||
import { | ||
Accordion, | ||
AccordionContent, | ||
AccordionItem, | ||
AccordionTrigger, | ||
} from '../shadcn-ui/accordion'; | ||
|
||
interface Props { | ||
tag: string; | ||
} | ||
|
||
export default function DiscardMethod({ tag }: Props) { | ||
const DM = methodTypes.filter((item) => item.tag === tag)[0].methods; | ||
const [openIndex, SetOpenIndex] = useState(-1); | ||
return ( | ||
<section className="flex flex-col gap-S-20 bg-white p-S-24"> | ||
<h5 className="text-Gray-700 Title-Small">배출 방법</h5> | ||
<div className="flex flex-col gap-S-14"> | ||
<Accordion className="flex flex-col gap-4" type="single" collapsible> | ||
{DM.map((method, index) => ( | ||
<div | ||
key={index} | ||
className="flex flex-col gap-S-16 rounded-[8px] bg-Green-50 p-S-16" | ||
<AccordionItem | ||
key={method.title} | ||
className="rounded-[8px] bg-Green-50 px-S-12" | ||
value={`item-${index}`} | ||
> | ||
<div className="flex justify-between"> | ||
<p className="text-Green-500 Title-Small">{method.title}</p> | ||
{openIndex !== index ? ( | ||
<span onClick={() => SetOpenIndex(index)}> | ||
<Down color="#45995E" /> | ||
</span> | ||
) : ( | ||
<span onClick={() => SetOpenIndex(-1)}> | ||
<Up color="#45995E" /> | ||
</span> | ||
)} | ||
</div> | ||
{openIndex === index && ( | ||
<div className="bg-transparent"> | ||
{method.descriptions.map((content, index) => ( | ||
<p | ||
key={`description-${index}`} | ||
className="text-Gray-600 Label-Large-Custom" | ||
> | ||
{content} | ||
</p> | ||
))} | ||
</div> | ||
)} | ||
</div> | ||
<AccordionTrigger className="text-Green-500 Title-Small"> | ||
{method.title} | ||
</AccordionTrigger> | ||
<AccordionContent className="text-Gray-600"> | ||
{method.descriptions.map((content, index) => ( | ||
<p | ||
key={`description-${index}`} | ||
className="text-Gray-600 Label-Large-Custom" | ||
> | ||
{content} | ||
</p> | ||
))} | ||
</AccordionContent> | ||
</AccordionItem> | ||
))} | ||
</div> | ||
</Accordion> | ||
</section> | ||
); | ||
} |