Last active
January 29, 2024 19:33
-
-
Save PatrickJS/b2287ca3184eda0e2243ff993d7249b7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { component$, type Signal, type JSXOutput } from "@builder.io/qwik"; | |
| export function Show(props: { | |
| when: boolean; | |
| "bind:when": Signal<boolean | undefined>; | |
| children?: JSXOutput; | |
| else?: JSXOutput; | |
| }) { | |
| if (props["bind:when"] !== undefined) { | |
| return props["bind:when"].value ? props.children : props.else; | |
| } | |
| return props.when ? props.children : props.else; | |
| } | |
| export function For<T>(props: { | |
| each?: T[]; | |
| "bind:each"?: Signal<T[] | undefined>; | |
| children: (item: T, index: number, collection: T[]) => JSXOutput; | |
| }) { | |
| if (props["bind:each"] !== undefined) { | |
| return props["bind:each"].value?.map(props.children); | |
| } | |
| return props.each?.map(props.children); | |
| } | |
| export const Repeat = component$(() => { | |
| return <></>; | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment