Spaces:
Running
Running
File size: 979 Bytes
fb19a97 70656b2 fb19a97 70656b2 fb19a97 70656b2 fb19a97 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | import React, { useState } from 'react';
import './ChartHelpButton.css';
interface Props {
title: string;
description: React.ReactNode;
inline?: boolean;
}
export default function ChartHelpButton({ title, description, inline = false }: Props) {
const [isOpen, setIsOpen] = useState(false);
return (
<div className={`chart-help-container ${inline ? 'inline' : 'absolute'}`}>
<button
className={`btn btn-sm chart-help-btn ${isOpen ? 'active' : ''}`}
onClick={() => setIsOpen(!isOpen)}
title="Toggle Explanation"
>
💡
</button>
{isOpen && (
<div className="chart-help-popup">
<div className="chart-help-header">
<h4>{title}</h4>
<button className="chart-help-close" onClick={() => setIsOpen(false)}>×</button>
</div>
<div className="chart-help-body">
{description}
</div>
</div>
)}
</div>
);
}
|