Photo Gallery
Photos in a grid, a masonry, a mosaic, a featured picture with thumbnails, or cards.
Install
npx ui8kit add photo-galleryPulls in: badge, box, button, compose, empty-state, figure-block, group, kit-box, kit-button, kit-text, lucide-icon, media-frame, section-frame, stack, text, utils
Preview
From the road
Places we worked from this year.
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-cdnnpx ui8kit add photo-gallery<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
Photos in a grid, a masonry of mixed heights, a mosaic with one big tile, a featured picture over a strip of
thumbnails, or cards with a title and a tag. Static markup: the featured layout's arrows are the page's. Axes:
layout (grid, masonry, mosaic, featured, cards), captions (show, hide), tone, density.
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
import type { Photo, PhotoLabels } from "./photo-gallery.types";
export type PhotoGalleryProps = {
id: string;
title: string;
lead?: string;
photos: Photo[];
empty?: string;
labels: PhotoLabels;
layout?: "grid" | "masonry" | "mosaic" | "featured" | "cards";
captions?: "show" | "hide";
tone?: "default" | "muted";
density?: "default" | "compact";
landmarkLabel?: string;
};
</script>
<script lang="ts">
import Badge from "../compose/Badge.svelte";
import Box from "../compose/Box.svelte";
import Button from "../compose/Button.svelte";
import Group from "../compose/Group.svelte";
import LucideIcon from "../icons/LucideIcon.svelte";
import Stack from "../compose/Stack.svelte";
import Text from "../compose/Text.svelte";
import EmptyState from "../components/empty-state.svelte";
import FigureBlock from "../components/figure-block.svelte";
import MediaFrame from "../components/media-frame.svelte";
import SectionFrame from "../components/section-frame.svelte";
import { cn, tpl } from "../utils";
let {
id,
title,
lead = "",
photos,
empty = "",
labels,
layout = "grid",
captions = "show",
tone = "default",
density = "default",
landmarkLabel,
}: PhotoGalleryProps = $props();
</script>
<SectionFrame id={id} title={title} lead={lead} tone={tone} density={density} landmarkLabel={landmarkLabel}>
{#if ((photos?.length ?? 0) === 0)}
<EmptyState icon="image" title={empty} />
{:else if ((layout as string) === "featured")}
<Stack gap="4" align="stretch" data-slot="featured">
<MediaFrame alt={photos[0]?.title ?? ""} src={photos[0]?.image ?? ""} />
<Group gap="4" align="center" justify="between">
<Stack gap="0">
<Text size="base" weight="semibold">
{photos[0]?.title ?? ""}
</Text>
<Text size="xs" class="text-muted-foreground">
{tpl(labels.counter, 1, (photos?.length ?? 0))}
</Text>
</Stack>
<Group gap="2">
<Button variant="outline" size="sm" layout="icon" aria-label={labels.previous}>
<LucideIcon name="chevron-left" size={16} />
</Button>
<Button variant="outline" size="sm" layout="icon" aria-label={labels.next}>
<LucideIcon name="chevron-right" size={16} />
</Button>
</Group>
</Group>
<Box class="grid grid-cols-3 gap-2 sm:grid-cols-9" data-slot="thumbs">
{#each photos as p, i (p.id)}
<MediaFrame alt={p.title} src={p.image} ratio="1/1" class={((i === 0) ? "ring-2 ring-foreground" : "")} />
{/each}
</Box>
</Stack>
{:else}
<Box
class={
(layout as string) === "masonry" ? "columns-1 gap-4 sm:columns-2 lg:columns-3"
: (layout as string) === "mosaic" ? "grid grid-cols-2 gap-4 md:grid-cols-4"
: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3"
}
data-slot="items"
>
{#each photos as p, i (p.id)}
<FigureBlock
class={cn(
"flex flex-col gap-2",
(((layout as string) === "masonry") ? "mb-4 break-inside-avoid" : ""),
((((layout as string) === "mosaic") && (i === 0)) ? "col-span-2 row-span-2" : ""),
(((layout as string) === "cards") ? "rounded bg-card inset-ring inset-ring-border p-4" : "")
)}
testid="item"
>
<MediaFrame
alt={p.title}
src={p.image}
ratio={
(layout as string) === "masonry" ? ((p.size === "tall") ? "3/4" : ((p.size === "wide") ? "16/9" : ((p.size === "large") ? "4/3" : "1/1")))
: (layout as string) === "grid" ? "4/3"
: "1/1"
}
class={(((layout as string) === "mosaic") ? "h-full" : "")}
/>
{#if (((captions as string) === "show") && ((layout as string) === "cards"))}
<Group gap="4" align="center" justify="between">
<Text size="sm" weight="semibold">
{p.title}
</Text>
<Badge variant="secondary" size="sm">
{p.tag}
</Badge>
</Group>
{/if}
{#if (((captions as string) === "show") && (((layout as string) === "grid") || ((layout as string) === "masonry")))}
<Box class="text-sm text-muted-foreground" data-slot="caption">
{p.title}
</Box>
{/if}
</FigureBlock>
{/each}
</Box>
{/if}
</SectionFrame>
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
export type Photo = {
id: string;
title: string;
tag: string;
size: string;
image?: string;
};
export type PhotoLabels = {
previous: string;
next: string;
counter: string;
};
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-cdnnpx ui8kit add photo-gallery// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* Photos in a grid, a masonry of mixed heights, a mosaic with one big tile, a featured picture over a strip of
* thumbnails, or cards with a title and a tag. Static markup: the featured layout's arrows are the page's. Axes:
* layout (grid, masonry, mosaic, featured, cards), captions (show, hide), tone, density.
*/
import { type ReactNode } from "react";
import { Badge, Box, Button, Group, Stack, Text } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { EmptyState } from "../components/empty-state";
import { FigureBlock } from "../components/figure-block";
import { MediaFrame } from "../components/media-frame";
import { SectionFrame } from "../components/section-frame";
import { cn, tpl } from "../utils";
import type { Photo, PhotoLabels } from "./photo-gallery.types";
export type PhotoGalleryProps = {
id: string;
title: string;
lead?: string;
photos: Photo[];
empty?: string;
labels: PhotoLabels;
layout?: "grid" | "masonry" | "mosaic" | "featured" | "cards";
captions?: "show" | "hide";
tone?: "default" | "muted";
density?: "default" | "compact";
landmarkLabel?: string;
};
export function PhotoGallery({
id,
title,
lead = "",
photos,
empty = "",
labels,
layout = "grid",
captions = "show",
tone = "default",
density = "default",
landmarkLabel,
}: PhotoGalleryProps) {
return (
<SectionFrame id={id} title={title} lead={lead} tone={tone} density={density} landmarkLabel={landmarkLabel}>
{((photos?.length ?? 0) === 0) ? (
<EmptyState icon="image" title={empty} />
) : ((layout as string) === "featured") ? (
<Stack gap="4" align="stretch" data-slot="featured">
<MediaFrame alt={photos[0]?.title ?? ""} src={photos[0]?.image ?? ""} />
<Group gap="4" align="center" justify="between">
<Stack gap="0">
<Text size="base" weight="semibold">
{photos[0]?.title ?? ""}
</Text>
<Text size="xs" className="text-muted-foreground">
{tpl(labels.counter, 1, (photos?.length ?? 0))}
</Text>
</Stack>
<Group gap="2">
<Button variant="outline" size="sm" layout="icon" aria-label={labels.previous}>
<LucideIcon name="chevron-left" size={16} />
</Button>
<Button variant="outline" size="sm" layout="icon" aria-label={labels.next}>
<LucideIcon name="chevron-right" size={16} />
</Button>
</Group>
</Group>
<Box className="grid grid-cols-3 gap-2 sm:grid-cols-9" data-slot="thumbs">
{(photos ?? []).map((p, i) => (
<MediaFrame key={p.id} alt={p.title} src={p.image} ratio="1/1" className={((i === 0) ? "ring-2 ring-foreground" : "")} />
))}
</Box>
</Stack>
) : (
<Box
className={
(layout as string) === "masonry" ? "columns-1 gap-4 sm:columns-2 lg:columns-3"
: (layout as string) === "mosaic" ? "grid grid-cols-2 gap-4 md:grid-cols-4"
: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3"
}
data-slot="items"
>
{(photos ?? []).map((p, i) => (
<FigureBlock key={p.id}
className={cn(
"flex flex-col gap-2",
(((layout as string) === "masonry") ? "mb-4 break-inside-avoid" : ""),
((((layout as string) === "mosaic") && (i === 0)) ? "col-span-2 row-span-2" : ""),
(((layout as string) === "cards") ? "rounded bg-card inset-ring inset-ring-border p-4" : "")
)}
testid="item"
>
<MediaFrame
alt={p.title}
src={p.image}
ratio={
(layout as string) === "masonry" ? ((p.size === "tall") ? "3/4" : ((p.size === "wide") ? "16/9" : ((p.size === "large") ? "4/3" : "1/1")))
: (layout as string) === "grid" ? "4/3"
: "1/1"
}
className={(((layout as string) === "mosaic") ? "h-full" : "")}
/>
{(((captions as string) === "show") && ((layout as string) === "cards")) ? (
<Group gap="4" align="center" justify="between">
<Text size="sm" weight="semibold">
{p.title}
</Text>
<Badge variant="secondary" size="sm">
{p.tag}
</Badge>
</Group>
) : null}
{(((captions as string) === "show") && (((layout as string) === "grid") || ((layout as string) === "masonry"))) ? (
<Box className="text-sm text-muted-foreground" data-slot="caption">
{p.title}
</Box>
) : null}
</FigureBlock>
))}
</Box>
)}
</SectionFrame>
);
}
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
export type Photo = {
id: string;
title: string;
tag: string;
size: string;
image?: string;
};
export type PhotoLabels = {
previous: string;
next: string;
counter: string;
};
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-cdnnpx ui8kit add photo-gallery// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
export type Photo = {
id: string;
title: string;
tag: string;
size: string;
image?: string;
};
export type PhotoLabels = {
previous: string;
next: string;
counter: string;
};
<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
Photos in a grid, a masonry of mixed heights, a mosaic with one big tile, a featured picture over a strip of
thumbnails, or cards with a title and a tag. Static markup: the featured layout's arrows are the page's. Axes:
layout (grid, masonry, mosaic, featured, cards), captions (show, hide), tone, density.
-->
<script lang="ts">
import type { Photo, PhotoLabels } from "./photo-gallery.types";
export type PhotoGalleryProps = {
id: string;
title: string;
lead?: string;
photos: Photo[];
empty?: string;
labels: PhotoLabels;
layout?: "grid" | "masonry" | "mosaic" | "featured" | "cards";
captions?: "show" | "hide";
tone?: "default" | "muted";
density?: "default" | "compact";
landmarkLabel?: string;
};
</script>
<script setup lang="ts">
import Badge from "../compose/Badge.vue";
import Box from "../compose/Box.vue";
import Button from "../compose/Button.vue";
import Group from "../compose/Group.vue";
import LucideIcon from "../icons/LucideIcon.vue";
import Stack from "../compose/Stack.vue";
import Text from "../compose/Text.vue";
import EmptyState from "../components/empty-state.vue";
import FigureBlock from "../components/figure-block.vue";
import MediaFrame from "../components/media-frame.vue";
import SectionFrame from "../components/section-frame.vue";
import { cn, tpl } from "../utils";
const {
id,
title,
lead = "",
photos,
empty = "",
labels,
layout = "grid",
captions = "show",
tone = "default",
density = "default",
landmarkLabel,
} = defineProps<PhotoGalleryProps>();
</script>
<template>
<SectionFrame
:id="id"
:title="title"
:lead="lead"
:tone="tone"
:density="density"
:landmarkLabel="landmarkLabel"
>
<EmptyState v-if="((photos?.length ?? 0) === 0)" icon="image" :title="empty" />
<Stack v-else-if="((layout as string) === 'featured')" gap="4" align="stretch" data-slot="featured">
<MediaFrame :alt="photos[0]?.title ?? ''" :src="photos[0]?.image ?? ''" />
<Group gap="4" align="center" justify="between">
<Stack gap="0">
<Text size="base" weight="semibold">
{{ photos[0]?.title ?? "" }}
</Text>
<Text size="xs" class="text-muted-foreground">
{{ tpl(labels.counter, 1, (photos?.length ?? 0)) }}
</Text>
</Stack>
<Group gap="2">
<Button variant="outline" size="sm" layout="icon" :aria-label="labels.previous">
<LucideIcon name="chevron-left" :size="16" />
</Button>
<Button variant="outline" size="sm" layout="icon" :aria-label="labels.next">
<LucideIcon name="chevron-right" :size="16" />
</Button>
</Group>
</Group>
<Box class="grid grid-cols-3 gap-2 sm:grid-cols-9" data-slot="thumbs">
<MediaFrame
v-for="(p, i) in photos"
:key="p.id"
:alt="p.title"
:src="p.image"
ratio="1/1"
:class="((i === 0) ? 'ring-2 ring-foreground' : '')"
/>
</Box>
</Stack>
<Box v-else
:class="
(layout as string) === 'masonry' ? 'columns-1 gap-4 sm:columns-2 lg:columns-3'
: (layout as string) === 'mosaic' ? 'grid grid-cols-2 gap-4 md:grid-cols-4'
: 'grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3'
"
data-slot="items"
>
<FigureBlock v-for="(p, i) in photos" :key="p.id"
:class="cn(
'flex flex-col gap-2',
(((layout as string) === 'masonry') ? 'mb-4 break-inside-avoid' : ''),
((((layout as string) === 'mosaic') && (i === 0)) ? 'col-span-2 row-span-2' : ''),
(((layout as string) === 'cards') ? 'rounded bg-card inset-ring inset-ring-border p-4' : '')
)"
testid="item"
>
<MediaFrame
:alt="p.title"
:src="p.image"
:ratio="
(layout as string) === 'masonry' ? ((p.size === 'tall') ? '3/4' : ((p.size === 'wide') ? '16/9' : ((p.size === 'large') ? '4/3' : '1/1')))
: (layout as string) === 'grid' ? '4/3'
: '1/1'
"
:class="(((layout as string) === 'mosaic') ? 'h-full' : '')"
/>
<Group
v-if="(((captions as string) === 'show') && ((layout as string) === 'cards'))"
gap="4"
align="center"
justify="between"
>
<Text size="sm" weight="semibold">
{{ p.title }}
</Text>
<Badge variant="secondary" size="sm">
{{ p.tag }}
</Badge>
</Group>
<Box
v-if="(((captions as string) === 'show') && (((layout as string) === 'grid') || ((layout as string) === 'masonry')))"
class="text-sm text-muted-foreground"
data-slot="caption"
>
{{ p.title }}
</Box>
</FigureBlock>
</Box>
</SectionFrame>
</template>
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-cdnnpx ui8kit add photo-gallery// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* Photos in a grid, a masonry of mixed heights, a mosaic with one big tile, a featured picture over a strip of
* thumbnails, or cards with a title and a tag. Static markup: the featured layout's arrows are the page's. Axes:
* layout (grid, masonry, mosaic, featured, cards), captions (show, hide), tone, density.
*/
import { For, type JSX } from "solid-js";
import { Badge, Box, Button, Group, Stack, Text } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { EmptyState } from "../components/empty-state";
import { FigureBlock } from "../components/figure-block";
import { MediaFrame } from "../components/media-frame";
import { SectionFrame } from "../components/section-frame";
import { cn, tpl } from "../utils";
import type { Photo, PhotoLabels } from "./photo-gallery.types";
export type PhotoGalleryProps = {
id: string;
title: string;
lead?: string;
photos: Photo[];
empty?: string;
labels: PhotoLabels;
layout?: "grid" | "masonry" | "mosaic" | "featured" | "cards";
captions?: "show" | "hide";
tone?: "default" | "muted";
density?: "default" | "compact";
landmarkLabel?: string;
};
export function PhotoGallery({
id,
title,
lead = "",
photos,
empty = "",
labels,
layout = "grid",
captions = "show",
tone = "default",
density = "default",
landmarkLabel,
}: PhotoGalleryProps) {
return (
<SectionFrame id={id} title={title} lead={lead} tone={tone} density={density} landmarkLabel={landmarkLabel}>
{((photos?.length ?? 0) === 0) ? (
<EmptyState icon="image" title={empty} />
) : ((layout as string) === "featured") ? (
<Stack gap="4" align="stretch" data-slot="featured">
<MediaFrame alt={photos[0]?.title ?? ""} src={photos[0]?.image ?? ""} />
<Group gap="4" align="center" justify="between">
<Stack gap="0">
<Text size="base" weight="semibold">
{photos[0]?.title ?? ""}
</Text>
<Text size="xs" class="text-muted-foreground">
{tpl(labels.counter, 1, (photos?.length ?? 0))}
</Text>
</Stack>
<Group gap="2">
<Button variant="outline" size="sm" layout="icon" aria-label={labels.previous}>
<LucideIcon name="chevron-left" size={16} />
</Button>
<Button variant="outline" size="sm" layout="icon" aria-label={labels.next}>
<LucideIcon name="chevron-right" size={16} />
</Button>
</Group>
</Group>
<Box class="grid grid-cols-3 gap-2 sm:grid-cols-9" data-slot="thumbs">
<For each={photos ?? []}>{(p, iOf) => { const i = iOf(); return (
<MediaFrame alt={p.title} src={p.image} ratio="1/1" class={((i === 0) ? "ring-2 ring-foreground" : "")} />
); }}</For>
</Box>
</Stack>
) : (
<Box
class={
(layout as string) === "masonry" ? "columns-1 gap-4 sm:columns-2 lg:columns-3"
: (layout as string) === "mosaic" ? "grid grid-cols-2 gap-4 md:grid-cols-4"
: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3"
}
data-slot="items"
>
<For each={photos ?? []}>{(p, iOf) => { const i = iOf(); return (
<FigureBlock
class={cn(
"flex flex-col gap-2",
(((layout as string) === "masonry") ? "mb-4 break-inside-avoid" : ""),
((((layout as string) === "mosaic") && (i === 0)) ? "col-span-2 row-span-2" : ""),
(((layout as string) === "cards") ? "rounded bg-card inset-ring inset-ring-border p-4" : "")
)}
testid="item"
>
<MediaFrame
alt={p.title}
src={p.image}
ratio={
(layout as string) === "masonry" ? ((p.size === "tall") ? "3/4" : ((p.size === "wide") ? "16/9" : ((p.size === "large") ? "4/3" : "1/1")))
: (layout as string) === "grid" ? "4/3"
: "1/1"
}
class={(((layout as string) === "mosaic") ? "h-full" : "")}
/>
{(((captions as string) === "show") && ((layout as string) === "cards")) ? (
<Group gap="4" align="center" justify="between">
<Text size="sm" weight="semibold">
{p.title}
</Text>
<Badge variant="secondary" size="sm">
{p.tag}
</Badge>
</Group>
) : null}
{(((captions as string) === "show") && (((layout as string) === "grid") || ((layout as string) === "masonry"))) ? (
<Box class="text-sm text-muted-foreground" data-slot="caption">
{p.title}
</Box>
) : null}
</FigureBlock>
); }}</For>
</Box>
)}
</SectionFrame>
);
}
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
export type Photo = {
id: string;
title: string;
tag: string;
size: string;
image?: string;
};
export type PhotoLabels = {
previous: string;
next: string;
counter: string;
};
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-cdnnpx ui8kit add photo-gallery// 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/photo-gallery.json
package blocks
import (
"github.com/ui8kit/codegen/generated/templ/ui/box"
"github.com/ui8kit/codegen/generated/templ/ui/button"
"github.com/ui8kit/codegen/generated/templ/compose"
"github.com/ui8kit/codegen/generated/templ/icons"
"github.com/ui8kit/codegen/generated/templ/ui/text"
uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)
// PhotoGalleryProps are the props of PhotoGallery; the values are the JSON shapes of the TypeScript props.
type PhotoGalleryProps struct {
Id any `json:"id"`
Title any `json:"title"`
Lead any `json:"lead"`
Photos any `json:"photos"`
Empty any `json:"empty"`
Labels any `json:"labels"`
Layout any `json:"layout"`
Captions any `json:"captions"`
Tone any `json:"tone"`
Density any `json:"density"`
LandmarkLabel any `json:"landmarkLabel"`
}
// Photos in a grid, a masonry of mixed heights, a mosaic with one big tile, a featured picture over a strip of thumbnails, or cards with a title and a tag. Static markup: the featured layout's arrows are the page's. Axes: layout (grid, masonry, mosaic, featured, cards), captions (show, hide), tone, density.
templ PhotoGallery(p PhotoGalleryProps) {
{{ vId := p.Id }}
{{ vTitle := p.Title }}
{{ vLead := uiutils.Def(p.Lead, "") }}
{{ vPhotos := p.Photos }}
{{ vEmpty := uiutils.Def(p.Empty, "") }}
{{ vLabels := p.Labels }}
{{ vLayout := uiutils.Def(p.Layout, "grid") }}
{{ vCaptions := uiutils.Def(p.Captions, "show") }}
{{ vTone := uiutils.Def(p.Tone, "default") }}
{{ vDensity := uiutils.Def(p.Density, "default") }}
{{ vLandmarkLabel := p.LandmarkLabel }}
@SectionFrame(SectionFrameProps{Id: vId, Title: vTitle, Lead: vLead, Tone: vTone, Density: vDensity, LandmarkLabel: vLandmarkLabel}) {
if uiutils.Eq(uiutils.Len(vPhotos), float64(0)) {
@EmptyState(EmptyStateProps{Icon: "image", Title: vEmpty})
} else if uiutils.Eq(vLayout, "featured") {
@compose.Stack(compose.StackProps{Gap: "4", Align: "stretch", BoxProps: box.BoxProps{Attrs: uiutils.Attrs("data-slot", "featured")}}) {
@MediaFrame(MediaFrameProps{Alt: uiutils.FirstOf(vPhotos, "title"), Src: uiutils.FirstOf(vPhotos, "image")})
@compose.Group(compose.GroupProps{Gap: "4", Align: "center", Justify: "between", BoxProps: box.BoxProps{}}) {
@compose.Stack(compose.StackProps{Gap: "0", BoxProps: box.BoxProps{}}) {
@compose.Text(compose.TextProps{Size: "base", Weight: "semibold", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.FirstOf(vPhotos, "title")) }
}
@compose.Text(compose.TextProps{Size: "xs", TextProps: text.TextProps{Class: "text-muted-foreground"}}) {
{ uiutils.Text(uiutils.Tpl(uiutils.Get(vLabels, "counter"), float64(1), uiutils.Len(vPhotos))) }
}
}
@compose.Group(compose.GroupProps{Gap: "2", BoxProps: box.BoxProps{}}) {
@compose.Button(compose.ButtonProps{Variant: "outline", Size: "sm", Layout: "icon", ButtonProps: button.ButtonProps{AriaLabel: uiutils.S(uiutils.Get(vLabels, "previous"))}}) {
@icons.LucideIcon(icons.LucideIconProps{Name: "chevron-left", Size: 16})
}
@compose.Button(compose.ButtonProps{Variant: "outline", Size: "sm", Layout: "icon", ButtonProps: button.ButtonProps{AriaLabel: uiutils.S(uiutils.Get(vLabels, "next"))}}) {
@icons.LucideIcon(icons.LucideIconProps{Name: "chevron-right", Size: 16})
}
}
}
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "grid grid-cols-3 gap-2 sm:grid-cols-9", Attrs: uiutils.Attrs("data-slot", "thumbs")}}) {
for vI, vP := range uiutils.L(vPhotos) {
@MediaFrame(MediaFrameProps{Alt: uiutils.Get(vP, "title"), Src: uiutils.Get(vP, "image"), Ratio: "1/1", Class: uiutils.Cnv(uiutils.Cond(uiutils.T(uiutils.Eq(float64(vI), float64(0))), "ring-2 ring-foreground", ""))})
}
}
}
} else {
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "masonry")), "columns-1 gap-4 sm:columns-2 lg:columns-3", uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "mosaic")), "grid grid-cols-2 gap-4 md:grid-cols-4", "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3"))), Attrs: uiutils.Attrs("data-slot", "items")}}) {
for vI, vP := range uiutils.L(vPhotos) {
@FigureBlock(FigureBlockProps{Class: uiutils.Cnv(uiutils.Cnv("flex flex-col gap-2", uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "masonry")), "mb-4 break-inside-avoid", ""), uiutils.Cond(uiutils.T(uiutils.And(uiutils.Eq(vLayout, "mosaic"), uiutils.Eq(float64(vI), float64(0)))), "col-span-2 row-span-2", ""), uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "cards")), "rounded bg-card inset-ring inset-ring-border p-4", ""))), Testid: "item"}) {
@MediaFrame(MediaFrameProps{Alt: uiutils.Get(vP, "title"), Src: uiutils.Get(vP, "image"), Ratio: uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "masonry")), uiutils.Cond(uiutils.T(uiutils.Eq(uiutils.Get(vP, "size"), "tall")), "3/4", uiutils.Cond(uiutils.T(uiutils.Eq(uiutils.Get(vP, "size"), "wide")), "16/9", uiutils.Cond(uiutils.T(uiutils.Eq(uiutils.Get(vP, "size"), "large")), "4/3", "1/1"))), uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "grid")), "4/3", "1/1")), Class: uiutils.Cnv(uiutils.Cond(uiutils.T(uiutils.Eq(vLayout, "mosaic")), "h-full", ""))})
if uiutils.T(uiutils.And(uiutils.Eq(vCaptions, "show"), uiutils.Eq(vLayout, "cards"))) {
@compose.Group(compose.GroupProps{Gap: "4", Align: "center", Justify: "between", BoxProps: box.BoxProps{}}) {
@compose.Text(compose.TextProps{Size: "sm", Weight: "semibold", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vP, "title")) }
}
@compose.Badge(compose.BadgeProps{Variant: "secondary", Size: "sm", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vP, "tag")) }
}
}
}
if uiutils.T(uiutils.And(uiutils.Eq(vCaptions, "show"), uiutils.Or(uiutils.Eq(vLayout, "grid"), uiutils.Eq(vLayout, "masonry")))) {
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "text-sm text-muted-foreground", Attrs: uiutils.Attrs("data-slot", "caption")}}) {
{ uiutils.Text(uiutils.Get(vP, "title")) }
}
}
}
}
}
}
}
}
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-cdnnpx ui8kit add photo-gallery{#- 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/photo-gallery.json
Photos in a grid, a masonry of mixed heights, a mosaic with one big tile, a featured picture over a strip of thumbnails, or cards with a title and a tag. Static markup: the featured layout's arrows are the page's. Axes: layout (grid, masonry, mosaic, featured, cards), captions (show, hide), tone, density.
Props (p): id, title, lead, photos, empty, labels, layout, captions, tone, density, landmarkLabel. -#}
{%- set v_id = (p.id ?? null) -%}
{%- set v_title = (p.title ?? null) -%}
{%- set v_lead = (p.lead ?? '') -%}
{%- set v_photos = (p.photos ?? null) -%}
{%- set v_empty = (p.empty ?? '') -%}
{%- set v_labels = (p.labels ?? null) -%}
{%- set v_layout = (p.layout ?? 'grid') -%}
{%- set v_captions = (p.captions ?? 'show') -%}
{%- set v_tone = (p.tone ?? 'default') -%}
{%- set v_density = (p.density ?? 'default') -%}
{%- set v_landmarkLabel = (p.landmarkLabel ?? null) -%}
{%- set c_16 -%}
{%- if og_t(og_eq(og_len(v_photos), 0)) %}
{{ include('blocks/empty-state.html.twig', {'p': {'icon': 'image', 'title': v_empty}}, with_context = false) }}
{%- elseif og_t(og_eq(v_layout, 'featured')) %}
{%- set c_9 -%}
{{ include('blocks/media-frame.html.twig', {'p': {'alt': og_first_of(v_photos, 'title'), 'src': og_first_of(v_photos, 'image')}}, with_context = false) }}
{%- set c_7 -%}
{%- set c_3 -%}
{%- set c_1 -%}
{{ og_text(og_first_of(v_photos, 'title')) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'base', 'weight': 'semibold', 'children': c_1}, with_context = false) }}
{%- set c_2 -%}
{{ og_text(og_tpl(og_get(v_labels, ['counter']), [1, og_len(v_photos)])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'xs', 'class': 'text-muted-foreground', 'children': c_2}, with_context = false) }}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '0', 'children': c_3}, with_context = false) }}
{%- set c_6 -%}
{%- set c_4 -%}
{{ include('icons/LucideIcon.html.twig', {'name': 'chevron-left', 'size': 16}, with_context = false) }}
{%- endset -%}
{{ include('compose/Button.html.twig', {'variant': 'outline', 'size': 'sm', 'layout': 'icon', 'ariaLabel': og_s(og_get(v_labels, ['previous'])), 'children': c_4}, with_context = false) }}
{%- set c_5 -%}
{{ include('icons/LucideIcon.html.twig', {'name': 'chevron-right', 'size': 16}, with_context = false) }}
{%- endset -%}
{{ include('compose/Button.html.twig', {'variant': 'outline', 'size': 'sm', 'layout': 'icon', 'ariaLabel': og_s(og_get(v_labels, ['next'])), 'children': c_5}, with_context = false) }}
{%- endset -%}
{{ include('compose/Group.html.twig', {'gap': '2', 'children': c_6}, with_context = false) }}
{%- endset -%}
{{ include('compose/Group.html.twig', {'gap': '4', 'align': 'center', 'justify': 'between', 'children': c_7}, with_context = false) }}
{%- set c_8 -%}
{%- for v_p in og_l(v_photos) %}
{%- set v_i = loop.index0 -%}
{{ include('blocks/media-frame.html.twig', {'p': {'alt': og_get(v_p, ['title']), 'src': og_get(v_p, ['image']), 'ratio': '1/1', 'className': og_cnv([(og_t(og_eq(v_i, 0)) ? 'ring-2 ring-foreground' : '')])}}, with_context = false) }}
{%- endfor %}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': 'grid grid-cols-3 gap-2 sm:grid-cols-9', 'attrs': og_attrs(['data-slot', 'thumbs']), 'children': c_8}, with_context = false) }}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '4', 'align': 'stretch', 'attrs': og_attrs(['data-slot', 'featured']), 'children': c_9}, with_context = false) }}
{%- else %}
{%- set c_15 -%}
{%- for v_p in og_l(v_photos) %}
{%- set v_i = loop.index0 -%}
{%- set c_14 -%}
{{ include('blocks/media-frame.html.twig', {'p': {'alt': og_get(v_p, ['title']), 'src': og_get(v_p, ['image']), 'ratio': (og_t(og_eq(v_layout, 'masonry')) ? (og_t(og_eq(og_get(v_p, ['size']), 'tall')) ? '3/4' : (og_t(og_eq(og_get(v_p, ['size']), 'wide')) ? '16/9' : (og_t(og_eq(og_get(v_p, ['size']), 'large')) ? '4/3' : '1/1'))) : (og_t(og_eq(v_layout, 'grid')) ? '4/3' : '1/1')), 'className': og_cnv([(og_t(og_eq(v_layout, 'mosaic')) ? 'h-full' : '')])}}, with_context = false) }}
{%- if og_t(og_and([og_eq(v_captions, 'show'), og_eq(v_layout, 'cards')])) %}
{%- set c_12 -%}
{%- set c_10 -%}
{{ og_text(og_get(v_p, ['title'])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'sm', 'weight': 'semibold', 'children': c_10}, with_context = false) }}
{%- set c_11 -%}
{{ og_text(og_get(v_p, ['tag'])) }}
{%- endset -%}
{{ include('compose/Badge.html.twig', {'variant': 'secondary', 'size': 'sm', 'children': c_11}, with_context = false) }}
{%- endset -%}
{{ include('compose/Group.html.twig', {'gap': '4', 'align': 'center', 'justify': 'between', 'children': c_12}, with_context = false) }}
{%- endif %}
{%- if og_t(og_and([og_eq(v_captions, 'show'), og_or([og_eq(v_layout, 'grid'), og_eq(v_layout, 'masonry')])])) %}
{%- set c_13 -%}
{{ og_text(og_get(v_p, ['title'])) }}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': 'text-sm text-muted-foreground', 'attrs': og_attrs(['data-slot', 'caption']), 'children': c_13}, with_context = false) }}
{%- endif %}
{%- endset -%}
{{ include('blocks/figure-block.html.twig', {'p': {'className': og_cnv([og_cnv(['flex flex-col gap-2', (og_t(og_eq(v_layout, 'masonry')) ? 'mb-4 break-inside-avoid' : ''), (og_t(og_and([og_eq(v_layout, 'mosaic'), og_eq(v_i, 0)])) ? 'col-span-2 row-span-2' : ''), (og_t(og_eq(v_layout, 'cards')) ? 'rounded bg-card inset-ring inset-ring-border p-4' : '')])]), 'testid': 'item'}, 'children': og_markup(c_14)}, with_context = false) }}
{%- endfor %}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': og_s((og_t(og_eq(v_layout, 'masonry')) ? 'columns-1 gap-4 sm:columns-2 lg:columns-3' : (og_t(og_eq(v_layout, 'mosaic')) ? 'grid grid-cols-2 gap-4 md:grid-cols-4' : 'grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3'))), 'attrs': og_attrs(['data-slot', 'items']), 'children': c_15}, with_context = false) }}
{%- endif %}
{%- endset -%}
{{ include('blocks/section-frame.html.twig', {'p': {'id': v_id, 'title': v_title, 'lead': v_lead, 'tone': v_tone, 'density': v_density, 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_16)}, with_context = false) }}
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-cdnnpx ui8kit add photo-gallery{* 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/photo-gallery.json
Photos in a grid, a masonry of mixed heights, a mosaic with one big tile, a featured picture over a strip of thumbnails, or cards with a title and a tag. Static markup: the featured layout's arrows are the page's. Axes: layout (grid, masonry, mosaic, featured, cards), captions (show, hide), tone, density.
Props (p): id, title, lead, photos, empty, labels, layout, captions, tone, density, landmarkLabel. *}
{var $v_id = ($p['id'] ?? null)}
{var $v_title = ($p['title'] ?? null)}
{var $v_lead = ($p['lead'] ?? '')}
{var $v_photos = ($p['photos'] ?? null)}
{var $v_empty = ($p['empty'] ?? '')}
{var $v_labels = ($p['labels'] ?? null)}
{var $v_layout = ($p['layout'] ?? 'grid')}
{var $v_captions = ($p['captions'] ?? 'show')}
{var $v_tone = ($p['tone'] ?? 'default')}
{var $v_density = ($p['density'] ?? 'default')}
{var $v_landmarkLabel = ($p['landmarkLabel'] ?? null)}
{capture $c_16}
{if og_t(og_eq(og_len($v_photos), 0))}
{=og_include('blocks/empty-state.latte', ['p' => ['icon' => 'image', 'title' => $v_empty]])|noescape}
{elseif og_t(og_eq($v_layout, 'featured'))}
{capture $c_9}
{=og_include('blocks/media-frame.latte', ['p' => ['alt' => og_first_of($v_photos, 'title'), 'src' => og_first_of($v_photos, 'image')]])|noescape}
{capture $c_7}
{capture $c_3}
{capture $c_1}
{=og_text(og_first_of($v_photos, 'title'))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'base', 'weight' => 'semibold', 'children' => (string) $c_1])|noescape}
{capture $c_2}
{=og_text(og_tpl(og_get($v_labels, ['counter']), [1, og_len($v_photos)]))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'xs', 'class' => 'text-muted-foreground', 'children' => (string) $c_2])|noescape}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '0', 'children' => (string) $c_3])|noescape}
{capture $c_6}
{capture $c_4}
{=og_include('icons/LucideIcon.latte', ['name' => 'chevron-left', 'size' => 16])|noescape}
{/capture}
{=og_include('compose/Button.latte', ['variant' => 'outline', 'size' => 'sm', 'layout' => 'icon', 'ariaLabel' => og_s(og_get($v_labels, ['previous'])), 'children' => (string) $c_4])|noescape}
{capture $c_5}
{=og_include('icons/LucideIcon.latte', ['name' => 'chevron-right', 'size' => 16])|noescape}
{/capture}
{=og_include('compose/Button.latte', ['variant' => 'outline', 'size' => 'sm', 'layout' => 'icon', 'ariaLabel' => og_s(og_get($v_labels, ['next'])), 'children' => (string) $c_5])|noescape}
{/capture}
{=og_include('compose/Group.latte', ['gap' => '2', 'children' => (string) $c_6])|noescape}
{/capture}
{=og_include('compose/Group.latte', ['gap' => '4', 'align' => 'center', 'justify' => 'between', 'children' => (string) $c_7])|noescape}
{capture $c_8}
{foreach og_l($v_photos) as $v_p}
{var $v_i = $iterator->counter0}
{=og_include('blocks/media-frame.latte', ['p' => ['alt' => og_get($v_p, ['title']), 'src' => og_get($v_p, ['image']), 'ratio' => '1/1', 'className' => og_cnv([(og_t(og_eq($v_i, 0)) ? 'ring-2 ring-foreground' : '')])]])|noescape}
{/foreach}
{/capture}
{=og_include('compose/Box.latte', ['class' => 'grid grid-cols-3 gap-2 sm:grid-cols-9', 'attrs' => og_attrs(['data-slot', 'thumbs']), 'children' => (string) $c_8])|noescape}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '4', 'align' => 'stretch', 'attrs' => og_attrs(['data-slot', 'featured']), 'children' => (string) $c_9])|noescape}
{else}
{capture $c_15}
{foreach og_l($v_photos) as $v_p}
{var $v_i = $iterator->counter0}
{capture $c_14}
{=og_include('blocks/media-frame.latte', ['p' => ['alt' => og_get($v_p, ['title']), 'src' => og_get($v_p, ['image']), 'ratio' => (og_t(og_eq($v_layout, 'masonry')) ? (og_t(og_eq(og_get($v_p, ['size']), 'tall')) ? '3/4' : (og_t(og_eq(og_get($v_p, ['size']), 'wide')) ? '16/9' : (og_t(og_eq(og_get($v_p, ['size']), 'large')) ? '4/3' : '1/1'))) : (og_t(og_eq($v_layout, 'grid')) ? '4/3' : '1/1')), 'className' => og_cnv([(og_t(og_eq($v_layout, 'mosaic')) ? 'h-full' : '')])]])|noescape}
{if og_t(og_and([og_eq($v_captions, 'show'), og_eq($v_layout, 'cards')]))}
{capture $c_12}
{capture $c_10}
{=og_text(og_get($v_p, ['title']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'sm', 'weight' => 'semibold', 'children' => (string) $c_10])|noescape}
{capture $c_11}
{=og_text(og_get($v_p, ['tag']))}
{/capture}
{=og_include('compose/Badge.latte', ['variant' => 'secondary', 'size' => 'sm', 'children' => (string) $c_11])|noescape}
{/capture}
{=og_include('compose/Group.latte', ['gap' => '4', 'align' => 'center', 'justify' => 'between', 'children' => (string) $c_12])|noescape}
{/if}
{if og_t(og_and([og_eq($v_captions, 'show'), og_or([og_eq($v_layout, 'grid'), og_eq($v_layout, 'masonry')])]))}
{capture $c_13}
{=og_text(og_get($v_p, ['title']))}
{/capture}
{=og_include('compose/Box.latte', ['class' => 'text-sm text-muted-foreground', 'attrs' => og_attrs(['data-slot', 'caption']), 'children' => (string) $c_13])|noescape}
{/if}
{/capture}
{=og_include('blocks/figure-block.latte', ['p' => ['className' => og_cnv([og_cnv(['flex flex-col gap-2', (og_t(og_eq($v_layout, 'masonry')) ? 'mb-4 break-inside-avoid' : ''), (og_t(og_and([og_eq($v_layout, 'mosaic'), og_eq($v_i, 0)])) ? 'col-span-2 row-span-2' : ''), (og_t(og_eq($v_layout, 'cards')) ? 'rounded bg-card inset-ring inset-ring-border p-4' : '')])]), 'testid' => 'item'], 'children' => og_markup($c_14)])|noescape}
{/foreach}
{/capture}
{=og_include('compose/Box.latte', ['class' => og_s((og_t(og_eq($v_layout, 'masonry')) ? 'columns-1 gap-4 sm:columns-2 lg:columns-3' : (og_t(og_eq($v_layout, 'mosaic')) ? 'grid grid-cols-2 gap-4 md:grid-cols-4' : 'grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3'))), 'attrs' => og_attrs(['data-slot', 'items']), 'children' => (string) $c_15])|noescape}
{/if}
{/capture}
{=og_include('blocks/section-frame.latte', ['p' => ['id' => $v_id, 'title' => $v_title, 'lead' => $v_lead, 'tone' => $v_tone, 'density' => $v_density, 'landmarkLabel' => $v_landmarkLabel], 'children' => og_markup($c_16)])|noescape}
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-cdnnpx ui8kit add photo-gallery{#- 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/photo-gallery.json
Photos in a grid, a masonry of mixed heights, a mosaic with one big tile, a featured picture over a strip of thumbnails, or cards with a title and a tag. Static markup: the featured layout's arrows are the page's. Axes: layout (grid, masonry, mosaic, featured, cards), captions (show, hide), tone, density.
Props (p): id, title, lead, photos, empty, labels, layout, captions, tone, density, landmarkLabel. -#}
{%- set v_id = og_def(p['id'], none) -%}
{%- set v_title = og_def(p['title'], none) -%}
{%- set v_lead = og_def(p['lead'], '') -%}
{%- set v_photos = og_def(p['photos'], none) -%}
{%- set v_empty = og_def(p['empty'], '') -%}
{%- set v_labels = og_def(p['labels'], none) -%}
{%- set v_layout = og_def(p['layout'], 'grid') -%}
{%- set v_captions = og_def(p['captions'], 'show') -%}
{%- set v_tone = og_def(p['tone'], 'default') -%}
{%- set v_density = og_def(p['density'], 'default') -%}
{%- set v_landmarkLabel = og_def(p['landmarkLabel'], none) -%}
{%- set c_16 -%}
{%- if og_t(og_eq(og_len(v_photos), 0)) %}
{{ og_include('blocks/empty-state.html.j2', {'p': {'icon': 'image', 'title': v_empty}}) }}
{%- elif og_t(og_eq(v_layout, 'featured')) %}
{%- set c_9 -%}
{{ og_include('blocks/media-frame.html.j2', {'p': {'alt': og_first_of(v_photos, 'title'), 'src': og_first_of(v_photos, 'image')}}) }}
{%- set c_7 -%}
{%- set c_3 -%}
{%- set c_1 -%}
{{ og_text(og_first_of(v_photos, 'title')) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'base', 'Weight': 'semibold'}, 'children': c_1}) }}
{%- set c_2 -%}
{{ og_text(og_tpl(og_get(v_labels, ['counter']), [1, og_len(v_photos)])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'xs', 'Class': 'text-muted-foreground'}, 'children': c_2}) }}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '0'}, 'children': c_3}) }}
{%- set c_6 -%}
{%- set c_4 -%}
{{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'chevron-left', 'Size': 16}}) }}
{%- endset -%}
{{ og_include('compose/button.html.j2', {'p': {'Variant': 'outline', 'Size': 'sm', 'Layout': 'icon', 'AriaLabel': og_s(og_get(v_labels, ['previous']))}, 'children': c_4}) }}
{%- set c_5 -%}
{{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'chevron-right', 'Size': 16}}) }}
{%- endset -%}
{{ og_include('compose/button.html.j2', {'p': {'Variant': 'outline', 'Size': 'sm', 'Layout': 'icon', 'AriaLabel': og_s(og_get(v_labels, ['next']))}, 'children': c_5}) }}
{%- endset -%}
{{ og_include('compose/group.html.j2', {'p': {'Gap': '2'}, 'children': c_6}) }}
{%- endset -%}
{{ og_include('compose/group.html.j2', {'p': {'Gap': '4', 'Align': 'center', 'Justify': 'between'}, 'children': c_7}) }}
{%- set c_8 -%}
{%- for v_p in og_l(v_photos) %}
{%- set v_i = loop.index0 -%}
{{ og_include('blocks/media-frame.html.j2', {'p': {'alt': og_get(v_p, ['title']), 'src': og_get(v_p, ['image']), 'ratio': '1/1', 'className': og_cnv([('ring-2 ring-foreground' if og_t(og_eq(v_i, 0)) else '')])}}) }}
{%- endfor %}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'grid grid-cols-3 gap-2 sm:grid-cols-9', 'Attrs': og_attrs(['data-slot', 'thumbs'])}, 'children': c_8}) }}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '4', 'Align': 'stretch', 'Attrs': og_attrs(['data-slot', 'featured'])}, 'children': c_9}) }}
{%- else %}
{%- set c_15 -%}
{%- for v_p in og_l(v_photos) %}
{%- set v_i = loop.index0 -%}
{%- set c_14 -%}
{{ og_include('blocks/media-frame.html.j2', {'p': {'alt': og_get(v_p, ['title']), 'src': og_get(v_p, ['image']), 'ratio': (('3/4' if og_t(og_eq(og_get(v_p, ['size']), 'tall')) else ('16/9' if og_t(og_eq(og_get(v_p, ['size']), 'wide')) else ('4/3' if og_t(og_eq(og_get(v_p, ['size']), 'large')) else '1/1'))) if og_t(og_eq(v_layout, 'masonry')) else ('4/3' if og_t(og_eq(v_layout, 'grid')) else '1/1')), 'className': og_cnv([('h-full' if og_t(og_eq(v_layout, 'mosaic')) else '')])}}) }}
{%- if og_t(og_and([og_eq(v_captions, 'show'), og_eq(v_layout, 'cards')])) %}
{%- set c_12 -%}
{%- set c_10 -%}
{{ og_text(og_get(v_p, ['title'])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'sm', 'Weight': 'semibold'}, 'children': c_10}) }}
{%- set c_11 -%}
{{ og_text(og_get(v_p, ['tag'])) }}
{%- endset -%}
{{ og_include('compose/badge.html.j2', {'p': {'Variant': 'secondary', 'Size': 'sm'}, 'children': c_11}) }}
{%- endset -%}
{{ og_include('compose/group.html.j2', {'p': {'Gap': '4', 'Align': 'center', 'Justify': 'between'}, 'children': c_12}) }}
{%- endif %}
{%- if og_t(og_and([og_eq(v_captions, 'show'), og_or([og_eq(v_layout, 'grid'), og_eq(v_layout, 'masonry')])])) %}
{%- set c_13 -%}
{{ og_text(og_get(v_p, ['title'])) }}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'text-sm text-muted-foreground', 'Attrs': og_attrs(['data-slot', 'caption'])}, 'children': c_13}) }}
{%- endif %}
{%- endset -%}
{{ og_include('blocks/figure-block.html.j2', {'p': {'className': og_cnv([og_cnv(['flex flex-col gap-2', ('mb-4 break-inside-avoid' if og_t(og_eq(v_layout, 'masonry')) else ''), ('col-span-2 row-span-2' if og_t(og_and([og_eq(v_layout, 'mosaic'), og_eq(v_i, 0)])) else ''), ('rounded bg-card inset-ring inset-ring-border p-4' if og_t(og_eq(v_layout, 'cards')) else '')])]), 'testid': 'item'}, 'children': og_markup(c_14)}) }}
{%- endfor %}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': og_s(('columns-1 gap-4 sm:columns-2 lg:columns-3' if og_t(og_eq(v_layout, 'masonry')) else ('grid grid-cols-2 gap-4 md:grid-cols-4' if og_t(og_eq(v_layout, 'mosaic')) else 'grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3'))), 'Attrs': og_attrs(['data-slot', 'items'])}, 'children': c_15}) }}
{%- endif %}
{%- endset -%}
{{ og_include('blocks/section-frame.html.j2', {'p': {'id': v_id, 'title': v_title, 'lead': v_lead, 'tone': v_tone, 'density': v_density, 'landmarkLabel': v_landmarkLabel}, 'children': og_markup(c_16)}) }}
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.
Photos in a grid, a masonry of mixed heights, a mosaic with one big tile, a featured picture over a strip of thumbnails, or cards with a title and a tag. Static markup: the featured layout's arrows are the page's. Axes: layout (grid, masonry, mosaic, featured, cards), captions (show, hide), tone, density.
| Prop | Type | Default | Description |
|---|---|---|---|
| id (required) | string | - | |
| title (required) | string | - | |
| lead | string | "" | |
| photos (required) | Photo[] | - | |
| empty | string | "" | the text of the empty state (no records), from the dictionary |
| labels (required) | PhotoLabels | - | |
| layout | "grid" | "masonry" | "mosaic" | "featured" | "cards" | "grid" | |
| captions | "show" | "hide" | "show" | |
| tone | "default" | "muted" | "default" | |
| density | "default" | "compact" | "default" | |
| landmarkLabel | string | - | accessible name of the landmark of this component when the page shows it more than once (a variant); replaces the heading name of the root landmark, follows the name of a nested one |