Skip to content

Commit 7847431

Browse files
authored
Improve FAQ item UI: better padding, alignment, and hover styling (#521)
* adjusted overflowing layout, navigation dropdown alignment * faq-item:improve padding & hover effects
1 parent 05c2651 commit 7847431

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/components/FAQItem.tsx

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@ const faqItemVariants = {
1313
};
1414

1515
const faqQuestionButtonVariants = {
16-
hover: { scale: 1.02 },
16+
initial: { backgroundColor: 'rgba(0,0,0,0)', y: 0 },
17+
hover: {
18+
scale: 1.02,
19+
backgroundColor: 'rgba(0,0,0,0.12)',
20+
y: -1,
21+
boxShadow: '0 4px 8px rgba(0,0,0,0.1)',
22+
transition: { type: 'spring' as const, stiffness: 300, damping: 15 },
23+
},
1724
};
1825

1926
const faqToggleIconVariants = (isOpen: boolean) => ({
@@ -44,17 +51,17 @@ const FAQItem = ({ index, question, answer }: FAQItemProps) => {
4451
animate="animate"
4552
>
4653
<motion.button
47-
className="w-full text-left py-4 text-lg font-medium flex justify-between items-center hover:cursor-pointer text-gray-900 dark:text-gray-100"
54+
className="w-full text-left py-4 px-4 text-lg font-medium flex justify-between items-center hover:cursor-pointer text-gray-900 dark:text-gray-100 rounded-md"
4855
onClick={toggleFAQ}
4956
whileHover="hover"
5057
variants={faqQuestionButtonVariants}
5158
>
52-
{question}
59+
<span className="flex-1">{question}</span>
5360
<motion.span
5461
variants={faqToggleIconVariants(isOpen)}
5562
initial="initial"
5663
animate="animate"
57-
className="text-gray-600 dark:text-gray-400"
64+
className="text-gray-600 dark:text-gray-400 ml-2"
5865
>
5966
{isOpen ? '-' : '+'}
6067
</motion.span>
@@ -65,7 +72,7 @@ const FAQItem = ({ index, question, answer }: FAQItemProps) => {
6572
animate="animate"
6673
style={{ overflow: 'hidden' }}
6774
>
68-
<p className="p-4 text-gray-700 dark:text-gray-300">{answer}</p>
75+
<p className="px-6 pb-4 text-gray-700 dark:text-gray-300">{answer}</p>
6976
</motion.div>
7077
</motion.div>
7178
);

0 commit comments

Comments
 (0)