Skip to content
ui8kit

component / components

Product Gallery

Product Gallery component

Install

npx ui8kit add product-gallery

Pulls in: compose, grid, kit-box, media-frame, stack, utils

Preview

Code

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework svelte --dir src --registry-url https://registry.buildy.tw/svelte --strict-cdn
npx ui8kit add product-gallery
components/product-gallery.svelte
<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
  The gallery of a product page: the picture (the file of the product's featured media, a placeholder without
  one) and optional thumbnails below.
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";

  export type ProductGalleryProps = {
    name: string;
    image?: string;
    thumbs?: "none" | "below";
  };
</script>

<script lang="ts">
  import Grid from "../compose/Grid.svelte";
  import Stack from "../compose/Stack.svelte";
  import MediaFrame from "../components/media-frame.svelte";

  let { name, image, thumbs = "below" }: ProductGalleryProps = $props();
</script>

<Stack gap="4" align="stretch" data-slot="gallery">
  <MediaFrame alt={name} src={image} ratio="1/1" />
  {#if ((thumbs as string) === "below")}
    <Grid cols="3" class="gap-4" data-slot="thumbs">
      <MediaFrame alt={name} src={image} ratio="1/1" class="ring-2 ring-foreground" />
      <MediaFrame alt={name} ratio="1/1" />
      <MediaFrame alt={name} ratio="1/1" />
    </Grid>
  {/if}
</Stack>

Svelte registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework react --dir src --registry-url https://registry.buildy.tw/react --strict-cdn
npx ui8kit add product-gallery
components/product-gallery.tsx
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
 * The gallery of a product page: the picture (the file of the product's featured media, a placeholder without
 * one) and optional thumbnails below.
 */
import { type ReactNode } from "react";
import { Grid, Stack } from "../compose";
import { MediaFrame } from "../components/media-frame";

export type ProductGalleryProps = {
  name: string;
  image?: string;
  thumbs?: "none" | "below";
};

export function ProductGallery({ name, image, thumbs = "below" }: ProductGalleryProps) {
  return (
    <Stack gap="4" align="stretch" data-slot="gallery">
      <MediaFrame alt={name} src={image} ratio="1/1" />
      {((thumbs as string) === "below") ? (
        <Grid cols="3" className="gap-4" data-slot="thumbs">
          <MediaFrame alt={name} src={image} ratio="1/1" className="ring-2 ring-foreground" />
          <MediaFrame alt={name} ratio="1/1" />
          <MediaFrame alt={name} ratio="1/1" />
        </Grid>
      ) : null}
    </Stack>
  );
}

React registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework vue --dir src --registry-url https://registry.buildy.tw/vue --strict-cdn
npx ui8kit add product-gallery
components/product-gallery.vue
<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
  The gallery of a product page: the picture (the file of the product's featured media, a placeholder without
  one) and optional thumbnails below.
-->
<script lang="ts">
export type ProductGalleryProps = {
  name: string;
  image?: string;
  thumbs?: "none" | "below";
};
</script>

<script setup lang="ts">
import Grid from "../compose/Grid.vue";
import Stack from "../compose/Stack.vue";
import MediaFrame from "../components/media-frame.vue";

const { name, image, thumbs = "below" } = defineProps<ProductGalleryProps>();
</script>

<template>
  <Stack gap="4" align="stretch" data-slot="gallery">
    <MediaFrame :alt="name" :src="image" ratio="1/1" />
    <Grid v-if="((thumbs as string) === 'below')" cols="3" class="gap-4" data-slot="thumbs">
      <MediaFrame :alt="name" :src="image" ratio="1/1" class="ring-2 ring-foreground" />
      <MediaFrame :alt="name" ratio="1/1" />
      <MediaFrame :alt="name" ratio="1/1" />
    </Grid>
  </Stack>
</template>

Vue registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework solid --dir src --registry-url https://registry.buildy.tw/solid --strict-cdn
npx ui8kit add product-gallery
components/product-gallery.tsx
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
 * The gallery of a product page: the picture (the file of the product's featured media, a placeholder without
 * one) and optional thumbnails below.
 */
import { type JSX } from "solid-js";
import { Grid, Stack } from "../compose";
import { MediaFrame } from "../components/media-frame";

export type ProductGalleryProps = {
  name: string;
  image?: string;
  thumbs?: "none" | "below";
};

export function ProductGallery({ name, image, thumbs = "below" }: ProductGalleryProps) {
  return (
    <Stack gap="4" align="stretch" data-slot="gallery">
      <MediaFrame alt={name} src={image} ratio="1/1" />
      {((thumbs as string) === "below") ? (
        <Grid cols="3" class="gap-4" data-slot="thumbs">
          <MediaFrame alt={name} src={image} ratio="1/1" class="ring-2 ring-foreground" />
          <MediaFrame alt={name} ratio="1/1" />
          <MediaFrame alt={name} ratio="1/1" />
        </Grid>
      ) : null}
    </Stack>
  );
}

Solid registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework templ --dir src --registry-url https://registry.buildy.tw/templ --strict-cdn
npx ui8kit add product-gallery
blocks/product-gallery.templ
// Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
// Source: packages/compose-gen/specs/organisms/product-gallery.json

package blocks

import (
	"github.com/ui8kit/codegen/generated/templ/ui/box"
	"github.com/ui8kit/codegen/generated/templ/compose"
	uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)

// ProductGalleryProps are the props of ProductGallery; the values are the JSON shapes of the TypeScript props.
type ProductGalleryProps struct {
	Name any `json:"name"`
	Image any `json:"image"`
	Thumbs any `json:"thumbs"`
}

// The gallery of a product page: the picture (the file of the product's featured media, a placeholder without one) and optional thumbnails below.
templ ProductGallery(p ProductGalleryProps) {
	{{ vName := p.Name }}
	{{ vImage := p.Image }}
	{{ vThumbs := uiutils.Def(p.Thumbs, "below") }}
	@compose.Stack(compose.StackProps{Gap: "4", Align: "stretch", BoxProps: box.BoxProps{Attrs: uiutils.Attrs("data-slot", "gallery")}}) {
		@MediaFrame(MediaFrameProps{Alt: vName, Src: vImage, Ratio: "1/1"})
		if uiutils.Eq(vThumbs, "below") {
			@compose.Grid(compose.GridProps{Cols: "3", BoxProps: box.BoxProps{Class: "gap-4", Attrs: uiutils.Attrs("data-slot", "thumbs")}}) {
				@MediaFrame(MediaFrameProps{Alt: vName, Src: vImage, Ratio: "1/1", Class: uiutils.Cnv("ring-2 ring-foreground")})
				@MediaFrame(MediaFrameProps{Alt: vName, Ratio: "1/1"})
				@MediaFrame(MediaFrameProps{Alt: vName, Ratio: "1/1"})
			}
		}
	}
}

templ registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework twig --dir src --registry-url https://registry.buildy.tw/twig --strict-cdn
npx ui8kit add product-gallery
blocks/product-gallery.html.twig
{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
    Source: packages/compose-gen/specs/organisms/product-gallery.json
    The gallery of a product page: the picture (the file of the product's featured media, a placeholder without one) and optional thumbnails below.
    Props (p): name, image, thumbs. -#}
{%- set v_name = (p.name ?? null) -%}
{%- set v_image = (p.image ?? null) -%}
{%- set v_thumbs = (p.thumbs ?? 'below') -%}
{%- set c_2 -%}
  {{ include('blocks/media-frame.html.twig', {'p': {'alt': v_name, 'src': v_image, 'ratio': '1/1'}}, with_context = false) }}
  {%- if og_t(og_eq(v_thumbs, 'below')) %}
    {%- set c_1 -%}
      {{ include('blocks/media-frame.html.twig', {'p': {'alt': v_name, 'src': v_image, 'ratio': '1/1', 'className': og_cnv(['ring-2 ring-foreground'])}}, with_context = false) }}
      {{ include('blocks/media-frame.html.twig', {'p': {'alt': v_name, 'ratio': '1/1'}}, with_context = false) }}
      {{ include('blocks/media-frame.html.twig', {'p': {'alt': v_name, 'ratio': '1/1'}}, with_context = false) }}
    {%- endset -%}
    {{ include('compose/Grid.html.twig', {'cols': '3', 'class': 'gap-4', 'attrs': og_attrs(['data-slot', 'thumbs']), 'children': c_1}, with_context = false) }}
  {%- endif %}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '4', 'align': 'stretch', 'attrs': og_attrs(['data-slot', 'gallery']), 'children': c_2}, with_context = false) }}

Twig registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework latte --dir src --registry-url https://registry.buildy.tw/latte --strict-cdn
npx ui8kit add product-gallery
blocks/product-gallery.latte
{* Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
    Source: packages/compose-gen/specs/organisms/product-gallery.json
    The gallery of a product page: the picture (the file of the product's featured media, a placeholder without one) and optional thumbnails below.
    Props (p): name, image, thumbs. *}
{var $v_name = ($p['name'] ?? null)}
{var $v_image = ($p['image'] ?? null)}
{var $v_thumbs = ($p['thumbs'] ?? 'below')}
{capture $c_2}
  {=og_include('blocks/media-frame.latte', ['p' => ['alt' => $v_name, 'src' => $v_image, 'ratio' => '1/1']])|noescape}
  {if og_t(og_eq($v_thumbs, 'below'))}
    {capture $c_1}
      {=og_include('blocks/media-frame.latte', ['p' => ['alt' => $v_name, 'src' => $v_image, 'ratio' => '1/1', 'className' => og_cnv(['ring-2 ring-foreground'])]])|noescape}
      {=og_include('blocks/media-frame.latte', ['p' => ['alt' => $v_name, 'ratio' => '1/1']])|noescape}
      {=og_include('blocks/media-frame.latte', ['p' => ['alt' => $v_name, 'ratio' => '1/1']])|noescape}
    {/capture}
    {=og_include('compose/Grid.latte', ['cols' => '3', 'class' => 'gap-4', 'attrs' => og_attrs(['data-slot', 'thumbs']), 'children' => (string) $c_1])|noescape}
  {/if}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '4', 'align' => 'stretch', 'attrs' => og_attrs(['data-slot', 'gallery']), 'children' => (string) $c_2])|noescape}

Latte registry item (JSON)

Point the CLI at this runtime once, then add the item:

npx ui8kit init --yes --framework jinja2 --dir src --registry-url https://registry.buildy.tw/jinja2 --strict-cdn
npx ui8kit add product-gallery
blocks/product-gallery.html.j2
{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
    Source: packages/compose-gen/specs/organisms/product-gallery.json
    The gallery of a product page: the picture (the file of the product's featured media, a placeholder without one) and optional thumbnails below.
    Props (p): name, image, thumbs. -#}
{%- set v_name = og_def(p['name'], none) -%}
{%- set v_image = og_def(p['image'], none) -%}
{%- set v_thumbs = og_def(p['thumbs'], 'below') -%}
{%- set c_2 -%}
  {{ og_include('blocks/media-frame.html.j2', {'p': {'alt': v_name, 'src': v_image, 'ratio': '1/1'}}) }}
  {%- if og_t(og_eq(v_thumbs, 'below')) %}
    {%- set c_1 -%}
      {{ og_include('blocks/media-frame.html.j2', {'p': {'alt': v_name, 'src': v_image, 'ratio': '1/1', 'className': og_cnv(['ring-2 ring-foreground'])}}) }}
      {{ og_include('blocks/media-frame.html.j2', {'p': {'alt': v_name, 'ratio': '1/1'}}) }}
      {{ og_include('blocks/media-frame.html.j2', {'p': {'alt': v_name, 'ratio': '1/1'}}) }}
    {%- endset -%}
    {{ og_include('compose/grid.html.j2', {'p': {'Cols': '3', 'Class': 'gap-4', 'Attrs': og_attrs(['data-slot', 'thumbs'])}, 'children': c_1}) }}
  {%- endif %}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '4', 'Align': 'stretch', 'Attrs': og_attrs(['data-slot', 'gallery'])}, 'children': c_2}) }}

Jinja2 registry item (JSON)

Props

Names and types come from the xgen specs of the source. Standard HTML attributes (id, role, tabIndex, aria-*) pass through to the root element; the class prop is className in React.

The gallery of a product page: the picture (the file of the product's featured media, a placeholder without one) and optional thumbnails below.

Props of ProductGallery
PropTypeDefault Description
name (required)string-the product name: the alternative text
image string-the file of the featured media; none: the placeholder
thumbs "none" | "below""below"

Used in