|
| 1 | +import React, { useState } from 'react' |
| 2 | +import styled, { keyframes } from 'styled-components' |
| 3 | +import { Helmet } from 'react-helmet' |
| 4 | +import { useLocalization } from '../contexts/Language/LanguageProvider' |
| 5 | +import SEO from './SEO' |
| 6 | +import SeeAlso from './SeeAlso' |
| 7 | + |
| 8 | +const fadeInUp = keyframes` |
| 9 | + from { opacity: 0; transform: translateY(20px); } |
| 10 | + to { opacity: 1; transform: translateY(0); } |
| 11 | +` |
| 12 | + |
| 13 | +const FAQ = () => { |
| 14 | + const { locals } = useLocalization() |
| 15 | + const [openIndex, setOpenIndex] = useState<number | null>(null) |
| 16 | + |
| 17 | + const toggle = (index: number) => { |
| 18 | + setOpenIndex(openIndex === index ? null : index) |
| 19 | + } |
| 20 | + |
| 21 | + const faqSchema = { |
| 22 | + '@context': 'https://schema.org', |
| 23 | + '@type': 'FAQPage', |
| 24 | + mainEntity: locals.faqItems.map(item => ({ |
| 25 | + '@type': 'Question', |
| 26 | + name: item.question, |
| 27 | + acceptedAnswer: { |
| 28 | + '@type': 'Answer', |
| 29 | + text: item.answer, |
| 30 | + }, |
| 31 | + })), |
| 32 | + } |
| 33 | + |
| 34 | + return ( |
| 35 | + <Container> |
| 36 | + <SEO |
| 37 | + title="FAQ | ShotClock Pro" |
| 38 | + description="Frequently asked questions about basketball shot clock rules, the 14-second reset, and how to use the ShotClock Pro training simulator." |
| 39 | + /> |
| 40 | + <Helmet> |
| 41 | + <script type="application/ld+json">{JSON.stringify(faqSchema)}</script> |
| 42 | + </Helmet> |
| 43 | + |
| 44 | + <AnimatedTitle>{locals.faqTitle}</AnimatedTitle> |
| 45 | + <Description>{locals.faqDescription}</Description> |
| 46 | + |
| 47 | + <FaqList> |
| 48 | + {locals.faqItems.map((item, index) => ( |
| 49 | + <FaqItem key={index} style={{ animationDelay: `${index * 0.05}s` }}> |
| 50 | + <Question onClick={() => toggle(index)} isOpen={openIndex === index}> |
| 51 | + <QuestionText>{item.question}</QuestionText> |
| 52 | + <Chevron isOpen={openIndex === index}>▾</Chevron> |
| 53 | + </Question> |
| 54 | + {openIndex === index && ( |
| 55 | + <Answer>{item.answer}</Answer> |
| 56 | + )} |
| 57 | + </FaqItem> |
| 58 | + ))} |
| 59 | + </FaqList> |
| 60 | + <SeeAlso exclude={['faq']} /> |
| 61 | + </Container> |
| 62 | + ) |
| 63 | +} |
| 64 | + |
| 65 | +const Container = styled.div` |
| 66 | + max-width: 860px; |
| 67 | + margin: 0 auto; |
| 68 | + @media (min-width: 768px) { |
| 69 | + padding: 2rem; |
| 70 | + } |
| 71 | +` |
| 72 | + |
| 73 | +const AnimatedTitle = styled.h1` |
| 74 | + font-size: 2.5rem; |
| 75 | + color: ${props => props.theme.titleColor}; |
| 76 | + margin-bottom: 1rem; |
| 77 | + text-align: center; |
| 78 | + font-weight: 700; |
| 79 | + font-family: 'Poppins', sans-serif; |
| 80 | + letter-spacing: -0.5px; |
| 81 | + animation: ${fadeInUp} 0.6s ease-out forwards; |
| 82 | +
|
| 83 | + @media (max-width: 768px) { |
| 84 | + font-size: 2rem; |
| 85 | + } |
| 86 | +` |
| 87 | + |
| 88 | +const Description = styled.p` |
| 89 | + text-align: center; |
| 90 | + color: ${props => props.theme.text}; |
| 91 | + font-size: 1.1rem; |
| 92 | + line-height: 1.6; |
| 93 | + margin-bottom: 3rem; |
| 94 | + animation: ${fadeInUp} 0.6s ease-out 0.1s forwards; |
| 95 | + opacity: 0; |
| 96 | + animation-fill-mode: forwards; |
| 97 | +` |
| 98 | + |
| 99 | +const FaqList = styled.div` |
| 100 | + display: flex; |
| 101 | + flex-direction: column; |
| 102 | + gap: 1rem; |
| 103 | +` |
| 104 | + |
| 105 | +const FaqItem = styled.div` |
| 106 | + background: rgba(0, 0, 0, 0.5); |
| 107 | + border-radius: 12px; |
| 108 | + border: 1px solid rgba(255, 255, 255, 0.1); |
| 109 | + overflow: hidden; |
| 110 | + animation: ${fadeInUp} 0.5s ease-out forwards; |
| 111 | + opacity: 0; |
| 112 | + transition: border-color 0.2s ease; |
| 113 | +
|
| 114 | + &:hover { |
| 115 | + border-color: rgba(255, 215, 0, 0.3); |
| 116 | + } |
| 117 | +` |
| 118 | + |
| 119 | +const Question = styled.button<{ isOpen: boolean }>` |
| 120 | + width: 100%; |
| 121 | + display: flex; |
| 122 | + justify-content: space-between; |
| 123 | + align-items: center; |
| 124 | + padding: 1.25rem 1.5rem; |
| 125 | + background: none; |
| 126 | + border: none; |
| 127 | + cursor: pointer; |
| 128 | + text-align: left; |
| 129 | + gap: 1rem; |
| 130 | + background: ${props => props.isOpen ? 'rgba(255, 215, 0, 0.08)' : 'transparent'}; |
| 131 | + transition: background 0.2s ease; |
| 132 | +
|
| 133 | + &:focus { |
| 134 | + outline: none; |
| 135 | + } |
| 136 | +` |
| 137 | + |
| 138 | +const QuestionText = styled.span` |
| 139 | + font-size: 1.05rem; |
| 140 | + font-weight: 600; |
| 141 | + color: ${props => props.theme.mainTextColor}; |
| 142 | + line-height: 1.4; |
| 143 | +` |
| 144 | + |
| 145 | +const Chevron = styled.span<{ isOpen: boolean }>` |
| 146 | + color: #ffd700; |
| 147 | + font-size: 1.3rem; |
| 148 | + flex-shrink: 0; |
| 149 | + transform: ${props => props.isOpen ? 'rotate(180deg)' : 'rotate(0deg)'}; |
| 150 | + transition: transform 0.25s ease; |
| 151 | + display: inline-block; |
| 152 | +` |
| 153 | + |
| 154 | +const Answer = styled.p` |
| 155 | + padding: 0 1.5rem 1.25rem; |
| 156 | + margin: 0; |
| 157 | + color: rgba(255, 255, 255, 0.85); |
| 158 | + font-size: 1rem; |
| 159 | + line-height: 1.7; |
| 160 | + border-top: 1px solid rgba(255, 255, 255, 0.07); |
| 161 | + padding-top: 1rem; |
| 162 | +` |
| 163 | + |
| 164 | +export default FAQ |
0 commit comments