Skip to main content

Gallery

A gallery Node that renders connected Views.

Features used in this example:

  • Example on how to use Viewports and the web-view[] datatype.

Example

A gallery node that renders a connected View without using any external libraries.

 

manifest.yaml
name: Gallery
description: A gallery node that renders connected View.
properties.yaml
view:
datatype: web-view
slot:
datatype: web-view[]
src/main.jsx
import { For, Show } from "@nodes-js/components";

// This render function simply renders each connected View
// in a staggered way
function render() {
return (
<Show
when={context.getExtended('slot').length > 0}
fallback={<div>No Views connected to slot!</div>}
>
<div style={{ position: 'relative' }}>
<For each={context.getExtended('slot')}>
{(view, index) => (
<>
<div>{context.data?.()}</div>
</>
)}
</For>
</div>
</Show>
);
}

// Bind a function that returns JSX
context.set('view', render);