1- import PropTypes from 'prop-types' ;
2- import { useState } from 'react' ;
3- import { FaGithub , FaLinkedin , FaXTwitter , FaYoutube } from 'react-icons/fa6' ;
1+ // component/FAQ.jsx
2+ import React , { useState } from 'react' ;
3+ import './FAQ.css' ; // Import the CSS file for styling
4+
5+ const FAQ = ( ) => {
6+ const [ activeIndex , setActiveIndex ] = useState ( null ) ;
7+
8+ const toggleAnswer = ( index ) => {
9+ setActiveIndex ( activeIndex === index ? null : index ) ;
10+ } ;
11+
12+ return (
13+ < div className = "faq-container" >
14+ < h1 > Frequently Asked Questions</ h1 >
15+ { faqData . map ( ( item , index ) => (
16+ < div key = { index } className = "faq-item" >
17+ < h2 onClick = { ( ) => toggleAnswer ( index ) } className = "faq-question" >
18+ { item . question }
19+ </ h2 >
20+ { activeIndex === index && < p className = "faq-answer" > { item . answer } </ p > }
21+ </ div >
22+ ) ) }
23+ </ div >
24+ ) ;
25+ } ;
426
5- // Sample FAQ data array
627const faqData = [
728 {
829 question : "What is BitBox?" ,
@@ -24,145 +45,7 @@ const faqData = [
2445 question : "How can I contact support if I need help?" ,
2546 answer : "You can reach out to support through the 'Contact Us' page or by emailing support@example.com." ,
2647 } ,
27- {
28- question : "What programming languages does BitBox support?" ,
29- answer : "BitBox supports a wide range of programming languages including Python, Java, JavaScript, and more." ,
30- } ,
31- {
32- question : "Are there any tutorials available for BitBox?" ,
33- answer : "Yes, we offer comprehensive tutorials and documentation to help users get the most out of BitBox." ,
34- } ,
35- {
36- question : "Can I use BitBox for open-source projects?" ,
37- answer : "Absolutely! BitBox is designed to support both open-source and private projects." ,
38- } ,
39- {
40- question : "What are the system requirements for using BitBox?" ,
41- answer : "BitBox is a web-based platform, so you only need a modern web browser and an internet connection." ,
42- } ,
43- {
44- question : "Is there a mobile app for BitBox?" ,
45- answer : "Currently, BitBox does not have a dedicated mobile app, but the platform is mobile-friendly and accessible via web browsers." ,
46- } ,
4748] ;
4849
49- function FAQ ( props ) {
50- const [ activeIndex , setActiveIndex ] = useState ( null ) ;
51- const [ visibleCount , setVisibleCount ] = useState ( 5 ) ;
52-
53- const toggleFAQ = ( index ) => {
54- setActiveIndex ( activeIndex === index ? null : index ) ;
55- } ;
56-
57- const loadMoreFAQs = ( ) => {
58- setVisibleCount ( ( prevCount ) => prevCount + 2 ) ;
59- } ;
60-
61- // Dynamic styles based on mode
62- const bgClass = props . mode === 'dark' ? 'bg-black' : 'bg-gray-100' ;
63- const textPrimary = props . mode === 'dark' ? 'text-gray-200' : 'text-gray-800' ;
64- const textSecondary = props . mode === 'dark' ? 'text-gray-400' : 'text-gray-600' ;
65- const borderClass = props . mode === 'dark' ? 'border-gray-600' : 'border-gray-300' ;
66- const buttonBg = props . mode === 'dark' ? 'bg-blue-600' : 'bg-blue-900' ;
67- const buttonHover = props . mode === 'dark' ? 'bg-blue-500' : 'bg-blue-800' ;
68-
69- return (
70- < div className = { `${ bgClass } p-8 mt-28` } >
71- < div className = "max-w-full mx-auto" >
72- { /* Header Section */ }
73- < div className = "flex flex-col md:flex-row items-center mb-8" >
74- < div className = "text-center md:text-left w-3/5 mb-4 md:mb-0 flex justify-center" >
75- < div className = 'w-1/2' data-aos = "fade-right" data-aos-duration = '1300' >
76- < h2 className = { `text-3xl font-bold ${ textPrimary } ` } > FAQs</ h2 >
77- < p className = { textSecondary } >
78- Have questions? Here you’ll find the answers most valued by our partners,
79- along with access to step-by-step instructions and support.
80- </ p >
81- </ div >
82- </ div >
83- < div className = "md:w-1/3" data-aos = "fade-left" data-aos-duration = '1300' >
84- < img
85- src = "https://img.freepik.com/free-vector/tiny-people-sitting-standing-near-giant-faq_74855-7879.jpg?t=st=1730230687~exp=1730234287~hmac=c4b0ded086432ac95ae1b1da544d08d153b0dc1de2436041fec87835dc56a0db& w = 1380 "
86- alt = "FAQ illustration"
87- className = "w-full max-w-[28rem] mx-auto"
88- />
89- </ div >
90- </ div >
91-
92- { /* FAQ List */ }
93- < div className = "grid grid-cols-1 md:grid-cols-3 gap-8 w-4/5 m-auto" >
94- { /* Sidebar Links */ }
95- < div className = "col-md-6 col-lg-5 col-12 ft-1 w-4/5" data-aos = "fade-up" data-aos-delay = "100" data-aos-duration = "1800" >
96- < h3 style = { { fontFamily : "medium" , fontSize : "2.5rem" } } className = { textPrimary } >
97- BIT< span className = 'code' style = { { color : "#0D92F4" } } > BOX</ span >
98- </ h3 >
99- < p className = { textSecondary } >
100- Empowering Developers,< br />
101- Where Projects Find Solutions Together
102- </ p >
103- < div className = "footer-icons" >
104- { /* Social media icons with links */ }
105- < a href = "https://github.com/bitboxcommunity" target = "_blank" rel = "noopener noreferrer" aria-label = "GitHub" >
106- < FaGithub color = { props . mode === 'dark' ? "#f0f0f0" : "#211F1F" } fontSize = "2rem" />
107- </ a >
108- < a href = "https://twitter.com/BITBOX688152" target = "_blank" rel = "noopener noreferrer" aria-label = "Twitter" >
109- < FaXTwitter color = { props . mode === 'dark' ? "#1da1f2" : "#1da1f2" } fontSize = "2rem" />
110- </ a >
111- < a href = "https://www.youtube.com/channel/UCXUTdcw27jaH_go9iyUjJnA" target = "_blank" rel = "noopener noreferrer" aria-label = "YouTube" >
112- < FaYoutube color = { props . mode === 'dark' ? "#FF0000" : "red" } fontSize = "2rem" />
113- </ a >
114- < a href = "https://www.linkedin.com/in/bit-box-community" target = "_blank" rel = "noopener noreferrer" aria-label = "LinkedIn" >
115- < FaLinkedin color = { props . mode === 'dark' ? "#0A66C2" : "#0077b5" } fontSize = "2rem" />
116- </ a >
117- </ div >
118- </ div >
119-
120- { /* FAQ Section */ }
121- < div className = "md:col-span-2" data-aos = "fade-up" data-aos-delay = "200" data-aos-duration = "1800" >
122- < h3 className = { `text-xl font-semibold ${ textPrimary } mb-4` } > About us</ h3 >
123- < div className = "space-y-4" >
124- { faqData . slice ( 0 , visibleCount ) . map ( ( faq , index ) => (
125- < div key = { index } className = { `border-b ${ borderClass } ` } >
126- < button
127- onClick = { ( ) => toggleFAQ ( index ) }
128- className = { `w-full text-left flex justify-between items-center py-4 focus:outline-none ${ textSecondary } ` }
129- >
130- < span className = { `font-medium ${ textPrimary } ` } > { faq . question } </ span >
131- < svg
132- className = { `w-5 h-5 transition-transform duration-200 ${ activeIndex === index ? 'rotate-180' : '' } ` }
133- fill = "none"
134- stroke = { props . mode === 'dark' ? 'white' : 'currentColor' }
135- viewBox = "0 0 24 24"
136- xmlns = "http://www.w3.org/2000/svg"
137- >
138- < path strokeLinecap = "round" strokeLinejoin = "round" strokeWidth = "2" d = "M19 9l-7 7-7-7" />
139- </ svg >
140- </ button >
141- { activeIndex === index && (
142- < div className = { textSecondary } >
143- { faq . answer }
144- </ div >
145- ) }
146- </ div >
147- ) ) }
148- </ div >
149- { visibleCount < faqData . length && (
150- < button
151- className = { `${ buttonBg } cursor-pointer text-white px-7 my-2 py-2 rounded-lg hover:${ buttonHover } ` }
152- onClick = { loadMoreFAQs }
153- >
154- View More
155- </ button >
156- ) }
157- </ div >
158- </ div >
159- </ div >
160- </ div >
161- ) ;
162- }
163-
164- FAQ . propTypes = {
165- mode : PropTypes . string . isRequired ,
166- } ;
16750
168- export default FAQ ;
51+ export default FAQ ;
0 commit comments