import { createWindowSize } from '@solid-primitives/resize-observer' import { ParentComponent, Show, children, createMemo } from 'solid-js' export const RenderInTwoColumns: ParentComponent = (props) => { const resolvedChildren = children(() => props.children) const windowSize = createWindowSize() // 640 is sm size in default tailwindcss breakpoint const showTwoColumns = createMemo(() => windowSize.width >= 640) const leftColumns = createMemo(() => resolvedChildren.toArray().filter((_, index) => index % 2 === 0), ) const rightColumns = createMemo(() => resolvedChildren.toArray().filter((_, index) => index % 2 === 1), ) return (
{leftColumns()}
{rightColumns()}
) }