Skip to content

Commit ee3a6f6

Browse files
authored
Merge pull request #367 from bigvictoh/feature/273-faq-accordion
feat: add reusable FAQ Accordion component for help pages and course …
2 parents 2a3768e + 80ec327 commit ee3a6f6

5 files changed

Lines changed: 1567 additions & 0 deletions

File tree

Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
2+
import { FAQAccordion } from './FAQAccordion';
3+
4+
const meta: Meta<typeof FAQAccordion> = {
5+
title: 'Common/FAQAccordion',
6+
component: FAQAccordion,
7+
tags: ['autodocs'],
8+
parameters: {
9+
layout: 'centered',
10+
docs: {
11+
description: {
12+
component: 'A reusable FAQ accordion component with keyboard accessibility, smooth animations, and support for multiple open items.',
13+
},
14+
},
15+
},
16+
argTypes: {
17+
items: {
18+
description: 'Array of FAQ items with id, question, and answer',
19+
control: 'object',
20+
},
21+
allowMultipleOpen: {
22+
description: 'Allow multiple accordion items to be open simultaneously',
23+
control: 'boolean',
24+
},
25+
defaultOpenIds: {
26+
description: 'IDs of items that should be open by default',
27+
control: 'object',
28+
},
29+
onItemToggle: {
30+
description: 'Callback fired when an item is toggled',
31+
control: false,
32+
},
33+
className: {
34+
description: 'Additional CSS class names',
35+
control: 'text',
36+
},
37+
},
38+
};
39+
40+
export default meta;
41+
type Story = StoryObj<typeof meta>;
42+
43+
const sampleFAQs = [
44+
{
45+
id: 'faq-1',
46+
question: 'What is Gatheraa?',
47+
answer:
48+
'Gatheraa is a decentralized event management platform that leverages blockchain technology to create transparent, secure, and efficient event experiences. Our platform enables event creators to manage tickets, attendees, and funds with complete transparency.',
49+
},
50+
{
51+
id: 'faq-2',
52+
question: 'How do I create an event?',
53+
answer:
54+
'Creating an event on Gatheraa is simple. First, connect your wallet, then navigate to "Create Event" and fill in the event details including name, description, date, location, and ticket information. Once submitted, your event will be live on the platform.',
55+
},
56+
{
57+
id: 'faq-3',
58+
question: 'What blockchain networks does Gatheraa support?',
59+
answer:
60+
'Gatheraa currently supports Ethereum mainnet, Polygon, Arbitrum, and Optimism. We are continuously working on adding support for additional networks based on community feedback and demand.',
61+
},
62+
{
63+
id: 'faq-4',
64+
question: 'How are transaction fees calculated?',
65+
answer:
66+
'Transaction fees on Gatheraa include smart contract execution fees, which vary based on network congestion. Our platform aims to minimize fees while ensuring security. You can always see the estimated gas fees before confirming any transaction.',
67+
},
68+
{
69+
id: 'faq-5',
70+
question: 'Is my data secure?',
71+
answer:
72+
'Yes. All event data and transactions are secured by the blockchain. Personal information is encrypted and only accessible to authorized parties. We follow industry-standard security practices and regularly audit our smart contracts.',
73+
},
74+
];
75+
76+
/**
77+
* Default FAQ Accordion with single open item
78+
*/
79+
export const Default: Story = {
80+
args: {
81+
items: sampleFAQs,
82+
allowMultipleOpen: false,
83+
},
84+
};
85+
86+
/**
87+
* FAQ Accordion with multiple items open at once
88+
*/
89+
export const MultipleOpen: Story = {
90+
args: {
91+
items: sampleFAQs,
92+
allowMultipleOpen: true,
93+
defaultOpenIds: ['faq-1', 'faq-2'],
94+
},
95+
};
96+
97+
/**
98+
* FAQ Accordion with default open items
99+
*/
100+
export const WithdefaultOpen: Story = {
101+
args: {
102+
items: sampleFAQs,
103+
allowMultipleOpen: false,
104+
defaultOpenIds: ['faq-1'],
105+
},
106+
};
107+
108+
/**
109+
* FAQ Accordion with fewer items (Help section)
110+
*/
111+
export const HelpSection: Story = {
112+
args: {
113+
items: [
114+
{
115+
id: 'help-1',
116+
question: 'How do I reset my password?',
117+
answer:
118+
'Click "Forgot Password" on the login page, enter your email, and follow the instructions sent to your inbox. The reset link will be valid for 24 hours.',
119+
},
120+
{
121+
id: 'help-2',
122+
question: 'How do I contact support?',
123+
answer:
124+
'You can reach our support team via email at support@gatheraa.com or through the help chat widget in the bottom right corner of the application.',
125+
},
126+
{
127+
id: 'help-3',
128+
question: 'What payment methods are accepted?',
129+
answer:
130+
'We accept payments in major cryptocurrencies including ETH, USDC, USDT, and DAI. All transactions are processed through secure smart contracts.',
131+
},
132+
],
133+
allowMultipleOpen: false,
134+
},
135+
};
136+
137+
/**
138+
* FAQ Accordion with callback to track state
139+
*/
140+
export const WithCallback: Story = {
141+
args: {
142+
items: sampleFAQs.slice(0, 3),
143+
allowMultipleOpen: true,
144+
onItemToggle: (id: string, isOpen: boolean) => {
145+
console.log(`Item ${id} is now ${isOpen ? 'open' : 'closed'}`);
146+
},
147+
},
148+
};
149+
150+
/**
151+
* Large FAQ list (course guide)
152+
*/
153+
export const CourseGuide: Story = {
154+
args: {
155+
items: [
156+
{
157+
id: 'course-1',
158+
question: 'Module 1: Introduction to Blockchain',
159+
answer:
160+
'This module covers the fundamental concepts of blockchain technology, including distributed ledgers, consensus mechanisms, and cryptography. Duration: 2 hours',
161+
},
162+
{
163+
id: 'course-2',
164+
question: 'Module 2: Smart Contracts Basics',
165+
answer:
166+
'Learn how to write, deploy, and interact with smart contracts. We cover Solidity, contract deployment, and testing strategies. Prerequisites: Module 1. Duration: 3 hours',
167+
},
168+
{
169+
id: 'course-3',
170+
question: 'Module 3: Web3 Integration',
171+
answer:
172+
'Integrate Web3 functionality into your applications. Learn about wallet connections, contract interactions, and transaction management. Prerequisites: Module 2. Duration: 2.5 hours',
173+
},
174+
{
175+
id: 'course-4',
176+
question: 'Module 4: Dapp Development',
177+
answer:
178+
'Build complete decentralized applications. This module combines all previous concepts into practical project work. Prerequisites: Modules 1-3. Duration: 4 hours',
179+
},
180+
{
181+
id: 'course-5',
182+
question: 'Module 5: Security Best Practices',
183+
answer:
184+
'Understand smart contract security, common vulnerabilities, and best practices. Learn about audits and security testing. Duration: 2 hours',
185+
},
186+
{
187+
id: 'course-6',
188+
question: 'Module 6: Advanced Patterns',
189+
answer:
190+
'Explore advanced design patterns, gas optimization, and scalability solutions. Duration: 3 hours',
191+
},
192+
],
193+
allowMultipleOpen: true,
194+
},
195+
};

0 commit comments

Comments
 (0)