portfolio_leptos/src/components/timeline/TimelineElement.tsx

31 lines
755 B
TypeScript
Raw Normal View History

2023-06-03 15:56:14 +02:00
import './TimelineElement.scss'
2023-06-03 18:26:08 +02:00
import react, {Children, ReactNode} from 'react'
2023-06-04 16:02:45 +02:00
import TimelineLabel from './TimelineLabel'
2023-06-03 13:19:46 +02:00
type TimelineElementProps = {
2023-06-03 18:32:35 +02:00
children: react.ReactElement<any, react.JSXElementConstructor<any>>[]
2023-06-03 13:19:46 +02:00
}
2023-06-03 18:26:08 +02:00
function TimelineElement({ children } : TimelineElementProps) {
let labels : ReactNode[] = []
let cards : ReactNode[] = []
Children.forEach(children, (c) => {
2023-06-04 16:02:45 +02:00
if (c.type === TimelineLabel) {
2023-06-03 18:26:08 +02:00
labels.push(c)
} else {
cards.push(c)
}
});
2023-06-03 13:19:46 +02:00
return (
2023-06-03 15:56:14 +02:00
<li className='timeline-element'>
<div className='timeline-element__category'>
2023-06-03 18:26:08 +02:00
{ labels }
2023-06-03 15:56:14 +02:00
</div>
<div className='timeline-element__info'>
2023-06-03 18:26:08 +02:00
{ cards }
2023-06-03 15:56:14 +02:00
</div>
2023-06-03 13:19:46 +02:00
</li>
)
}
export default TimelineElement