portfolio_leptos/src_old/components/timeline/TimelineCard.tsx

30 lines
No EOL
711 B
TypeScript

import react, {Children, ReactNode} from 'react'
import TimelineCardSummary from './TimelineCardSummary'
import { FaCaretDown } from 'react-icons/fa'
type TimelineCardProps = {
children: react.ReactElement<any, react.JSXElementConstructor<any>>[]
}
function TimelineCard({ children } : TimelineCardProps) {
let titles : ReactNode[] = []
let childrens : ReactNode[] = []
Children.forEach(children, (c) => {
if (c.type === TimelineCardSummary) {
titles.push(c)
} else {
childrens.push(c)
}
});
return (
<details>
<summary>
{titles}
<i><FaCaretDown/></i>
</summary>
<div>{childrens}</div>
</details>
)
}
export default TimelineCard