Skip to content

Instantly share code, notes, and snippets.

@PatrickJS
Last active January 29, 2024 19:33
Show Gist options
  • Select an option

  • Save PatrickJS/b2287ca3184eda0e2243ff993d7249b7 to your computer and use it in GitHub Desktop.

Select an option

Save PatrickJS/b2287ca3184eda0e2243ff993d7249b7 to your computer and use it in GitHub Desktop.
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