Skip to content

Commit c6f924d

Browse files
committed
update: Faq component for latest conventions
Component Changes: - Renamed from FaqAccordion to Faq - Updated to use ui/accordion components instead of direct @radix-ui/react-accordion imports - Removed react-icons dependency - the ChevronNext icon is now handled by the ui/accordion components - Fixed import path from tailwind/ui/accordion to ui/accordion - Simplified component structure while maintaining custom styling Story Changes: - Renamed file from FaqAccordion.stories.tsx to Faq.stories.tsx - Updated all component references to use new names (Faq, FaqContent, FaqItem, FaqTrigger) - Changed story name from FaqAccordionStory to Faq following standard conventions. categorized in Molecules / Display Content / Faq
1 parent 66a732d commit c6f924d

File tree

2 files changed

+52
-71
lines changed

2 files changed

+52
-71
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,32 @@
11
import { Meta, StoryObj } from "@storybook/react"
22

3-
import {
4-
FaqAccordion,
5-
FaqAccordionContent,
6-
FaqAccordionItem,
7-
FaqAccordionTrigger,
8-
} from "."
3+
import { Faq as FaqComponent, FaqContent, FaqItem, FaqTrigger } from "."
94

105
const meta = {
11-
title: "FaqAccordion",
12-
component: FaqAccordion,
6+
title: "Molecules / Display Content / Faq",
7+
component: FaqComponent,
138
decorators: [
149
(Story) => (
1510
<div className="">
1611
<Story />
1712
</div>
1813
),
1914
],
20-
} satisfies Meta<typeof FaqAccordion>
15+
} satisfies Meta<typeof FaqComponent>
2116

2217
export default meta
2318

24-
export const FaqAccordionStory: StoryObj = {
19+
export const Faq: StoryObj = {
2520
render: () => (
26-
<FaqAccordion type="single" collapsible>
27-
<FaqAccordionItem value="item-1">
28-
<FaqAccordionTrigger>
21+
<FaqComponent type="single" collapsible>
22+
<FaqItem value="item-1">
23+
<FaqTrigger>
2924
<h2 className="text-start text-base md:text-xl">
3025
Why is there no &apos;official&apos; Ethereum L2?
3126
</h2>
32-
</FaqAccordionTrigger>
27+
</FaqTrigger>
3328

34-
<FaqAccordionContent>
29+
<FaqContent>
3530
Just as there is no &apos;official&apos; Ethereum client, there is no
3631
&apos;official&apos; Ethereum layer 2. Ethereum is permissionless -
3732
technically anyone can create a layer 2! Multiple teams will implement
@@ -40,15 +35,15 @@ export const FaqAccordionStory: StoryObj = {
4035
use cases. Much like we have multiple Ethereum clients developed by
4136
multiple teams in order to have diversity in the network, this too
4237
will be how layer 2s develop in the future.
43-
</FaqAccordionContent>
44-
</FaqAccordionItem>
45-
<FaqAccordionItem value="item-2">
46-
<FaqAccordionTrigger>
38+
</FaqContent>
39+
</FaqItem>
40+
<FaqItem value="item-2">
41+
<FaqTrigger>
4742
<h2 className="text-start text-base md:text-xl">
4843
Why is there no &apos;official&apos; Ethereum L2?
4944
</h2>
50-
</FaqAccordionTrigger>
51-
<FaqAccordionContent>
45+
</FaqTrigger>
46+
<FaqContent>
5247
Just as there is no &apos;official&apos; Ethereum client, there is no
5348
&apos;official&apos; Ethereum layer 2. Ethereum is permissionless -
5449
technically anyone can create a layer 2! Multiple teams will implement
@@ -57,8 +52,8 @@ export const FaqAccordionStory: StoryObj = {
5752
use cases. Much like we have multiple Ethereum clients developed by
5853
multiple teams in order to have diversity in the network, this too
5954
will be how layer 2s develop in the future.
60-
</FaqAccordionContent>
61-
</FaqAccordionItem>
62-
</FaqAccordion>
55+
</FaqContent>
56+
</FaqItem>
57+
</FaqComponent>
6358
),
6459
}

src/components/FaqAccordion/index.tsx

Lines changed: 33 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,41 @@
11
import React from "react"
2-
import { MdChevronRight } from "react-icons/md"
32
import * as AccordionPrimitive from "@radix-ui/react-accordion"
43

5-
import { cn } from "@/lib/utils/cn"
4+
import {
5+
Accordion,
6+
AccordionContent,
7+
AccordionItem,
8+
AccordionTrigger,
9+
} from "@/components/ui/accordion"
610

7-
import * as RootAccordion from "../../../tailwind/ui/accordion"
11+
import { cn } from "@/lib/utils/cn"
812

9-
const FaqAccordionTrigger = React.forwardRef<
13+
const FaqTrigger = React.forwardRef<
1014
React.ElementRef<typeof AccordionPrimitive.Trigger>,
1115
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Trigger>
1216
>(({ className, children, ...props }, ref) => (
13-
<AccordionPrimitive.Header>
14-
<AccordionPrimitive.Trigger
15-
ref={ref}
16-
className={cn(
17-
"w-full px-4 py-3 md:px-8 md:py-6",
18-
"flex flex-1 items-center justify-between gap-2",
19-
"border-t border-body-light",
20-
"focus-visible:outline-1 focus-visible:-outline-offset-1 focus-visible:outline-primary-hover",
21-
"group cursor-pointer text-start font-medium",
22-
"transition-all [&[data-state=open]>svg]:-rotate-90",
23-
className
24-
)}
25-
{...props}
26-
>
27-
{children}
28-
29-
<MdChevronRight
30-
className={cn(
31-
"size-[1em] shrink-0 p-1 text-2xl md:size-[1.25em]",
32-
"rounded-full border",
33-
"group-hover:border-primary group-hover:text-primary group-hover:shadow-md group-hover:shadow-primary-low-contrast",
34-
"transition-transform duration-200"
35-
)}
36-
/>
37-
</AccordionPrimitive.Trigger>
38-
</AccordionPrimitive.Header>
17+
<AccordionTrigger
18+
ref={ref}
19+
className={cn(
20+
"w-full px-4 py-3 md:px-8 md:py-6",
21+
"border-t border-body-light",
22+
"text-start font-medium",
23+
className
24+
)}
25+
{...props}
26+
>
27+
{children}
28+
</AccordionTrigger>
3929
))
40-
FaqAccordionTrigger.displayName = AccordionPrimitive.Trigger.displayName
30+
FaqTrigger.displayName = AccordionPrimitive.Trigger.displayName
4131

42-
const FaqAccordion = ({
32+
const Faq = ({
4333
children,
4434
type,
4535
...props
4636
}: AccordionPrimitive.AccordionSingleProps) => {
4737
return (
48-
<RootAccordion.Accordion
38+
<Accordion
4939
type={type}
5040
collapsible
5141
className={cn(
@@ -56,26 +46,27 @@ const FaqAccordion = ({
5646
{...props}
5747
>
5848
{children}
59-
</RootAccordion.Accordion>
49+
</Accordion>
6050
)
6151
}
62-
const FaqAccordionItem = React.forwardRef<
52+
53+
const FaqItem = React.forwardRef<
6354
React.ElementRef<typeof AccordionPrimitive.Item>,
6455
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Item>
6556
>(({ className, ...props }, ref) => (
66-
<AccordionPrimitive.Item
57+
<AccordionItem
6758
ref={ref}
6859
className={cn("hover:bg-background-highlight", className)}
6960
{...props}
7061
/>
7162
))
72-
FaqAccordionItem.displayName = "AccordionItem"
63+
FaqItem.displayName = "AccordionItem"
7364

74-
const FaqAccordionContent = React.forwardRef<
65+
const FaqContent = React.forwardRef<
7566
React.ElementRef<typeof AccordionPrimitive.Content>,
7667
React.ComponentPropsWithoutRef<typeof AccordionPrimitive.Content>
7768
>(({ className, children, ...props }, ref) => (
78-
<AccordionPrimitive.Content
69+
<AccordionContent
7970
ref={ref}
8071
className={cn(
8172
"w-full overflow-hidden px-4 text-sm md:px-8",
@@ -86,14 +77,9 @@ const FaqAccordionContent = React.forwardRef<
8677
<div className={cn("border-t border-body-light py-3 md:py-6", className)}>
8778
{children}
8879
</div>
89-
</AccordionPrimitive.Content>
80+
</AccordionContent>
9081
))
9182

92-
FaqAccordionContent.displayName = AccordionPrimitive.Content.displayName
83+
FaqContent.displayName = AccordionPrimitive.Content.displayName
9384

94-
export {
95-
FaqAccordion,
96-
FaqAccordionContent,
97-
FaqAccordionItem,
98-
FaqAccordionTrigger,
99-
}
85+
export { Faq, FaqContent, FaqItem, FaqTrigger }

0 commit comments

Comments
 (0)