profile / src /components /Section.js
n0w0f's picture
Replace FastAPI with React portfolio
c990683
raw
history blame contribute delete
770 Bytes
import React, { useState } from 'react';
import { FaChevronDown, FaChevronUp } from 'react-icons/fa';
const Section = ({ title, icon, children, defaultExpanded = true }) => {
const [isExpanded, setIsExpanded] = useState(defaultExpanded);
return (
<div className="mb-8">
<div
className="flex items-center justify-between cursor-pointer mb-4"
onClick={() => setIsExpanded(!isExpanded)}
>
<h2 className="text-2xl font-bold flex items-center">
{icon}
<span className="ml-2">{title}</span>
</h2>
<div className="text-gray-500">
{isExpanded ? <FaChevronUp /> : <FaChevronDown />}
</div>
</div>
{isExpanded && children}
</div>
);
};
export default Section;