portfolio_leptos/src/components/timeline/TimelineCard.tsx

26 lines
620 B
TypeScript
Raw Normal View History

2023-06-03 18:26:08 +02:00
import react, {Children, ReactNode} from 'react'
2023-06-03 18:32:35 +02:00
import TimelineCardSummary from './TimelineCardSummary'
2023-06-03 18:26:08 +02:00
type TimelineCardProps = {
2023-06-03 18:32:35 +02:00
children: react.ReactElement<any, react.JSXElementConstructor<any>>[]
2023-06-03 18:26:08 +02:00
}
function TimelineCard({ children } : TimelineCardProps) {
let titles : ReactNode[] = []
let childrens : ReactNode[] = []
Children.forEach(children, (c) => {
2023-06-04 16:02:45 +02:00
if (c.type === TimelineCardSummary) {
2023-06-03 18:26:08 +02:00
titles.push(c)
} else {
childrens.push(c)
}
});
return (
<details>
<summary>{titles}</summary>
<div>{childrens}</div>
</details>
)
}
export default TimelineCard