1
0
mirror of https://github.com/kamranahmedse/developer-roadmap.git synced 2025-09-02 22:02:39 +02:00
This commit is contained in:
Arik Chakma
2025-06-27 02:33:39 +06:00
parent dc240fa5d3
commit fc0480d919

View File

@@ -65,6 +65,8 @@ export function CourseFeatures() {
}, },
]; ];
const [expandedFeatureIndex, setExpandedFeatureIndex] = useState<number>(0);
return ( return (
<div> <div>
<SectionHeader <SectionHeader
@@ -77,7 +79,8 @@ export function CourseFeatures() {
<CourseFeature <CourseFeature
key={feature.title} key={feature.title}
{...feature} {...feature}
isExpanded={index === 0} isExpanded={expandedFeatureIndex === index}
onExpand={() => setExpandedFeatureIndex(index)}
/> />
))} ))}
</div> </div>
@@ -87,6 +90,7 @@ export function CourseFeatures() {
type CourseFeatureProps = Feature & { type CourseFeatureProps = Feature & {
isExpanded?: boolean; isExpanded?: boolean;
onExpand?: () => void;
}; };
function CourseFeature(props: CourseFeatureProps) { function CourseFeature(props: CourseFeatureProps) {
@@ -95,11 +99,10 @@ function CourseFeature(props: CourseFeatureProps) {
description, description,
icon: Icon, icon: Icon,
imgUrl, imgUrl,
isExpanded: isDefaultExpanded = false, isExpanded,
onExpand,
} = props; } = props;
const [isExpanded, setIsExpanded] = useState(isDefaultExpanded);
return ( return (
<div> <div>
<div <div
@@ -115,16 +118,14 @@ function CourseFeature(props: CourseFeatureProps) {
</h3> </h3>
</div> </div>
<button {!isExpanded && (
className="text-zinc-400 hover:text-zinc-300" <button
onClick={() => setIsExpanded(!isExpanded)} className="text-zinc-400 hover:text-zinc-300"
> onClick={onExpand}
{isExpanded ? ( >
<MinusIcon className="h-5 w-5" />
) : (
<PlusIcon className="h-5 w-5" /> <PlusIcon className="h-5 w-5" />
)} </button>
</button> )}
</div> </div>
{isExpanded && ( {isExpanded && (