Skip to content
ui8kit

component / components

App Main

App Main component

Install

npx ui8kit add app-main

Pulls in: activity-feed, bar-chart, box, chart-panel, compose, dashboard-overview, grid, kit-box, kit-text, metric-row, panel, stack, stat-tile, timeline, title, utils

Preview

Overview

Revenue

$48,200

+8% this month

Orders

1,284

+3% this month

Visitors

92,410

+12% this month

Churn

1.9%

-0.2% this month

Orders this week

Orders per day over the last seven days.

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 app-main
components/app-main.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 main column of AppShell: the heading, the metric tiles, and the chart panel (beside the activity panel
  when `activity` is given).
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";
  import type { Metric } from "../blocks/metric-row.types";
  import type { Point } from "../blocks/chart-panel.types";
  import type { Event } from "../blocks/activity-feed.types";
  import type { OverviewChart, OverviewActivity } from "../blocks/dashboard-overview.types";

  export type AppMainProps = {
    id: string;
    title: string;
    metrics: Metric[];
    chart: OverviewChart;
    activity?: OverviewActivity;
    cols?: "1-2" | "1-4";
    density?: "default" | "compact";
  };
</script>

<script lang="ts">
  import Box from "../compose/Box.svelte";
  import Grid from "../compose/Grid.svelte";
  import Stack from "../compose/Stack.svelte";
  import Title from "../compose/Title.svelte";
  import BarChart from "../components/bar-chart.svelte";
  import Panel from "../components/panel.svelte";
  import StatTile from "../components/stat-tile.svelte";
  import Timeline from "../components/timeline.svelte";
  import { tpl } from "../utils";

  let { id, title, metrics, chart, activity, cols = "1-2", density = "default" }: AppMainProps = $props();
</script>

<Stack
  gap={(((density as string) === "compact") ? "4" : "6")}
  align="stretch"
  class="min-w-0"
  data-slot="app-main"
>
  <Title as={2} size="2xl" weight="bold" id={tpl("{0}-title", id)}>
    {title}
  </Title>
  {#if ((metrics?.length ?? 0) > 0)}
    <Grid cols={cols} class="gap-4" data-slot="items">
      {#each metrics as m (m.id)}
        <Box data-slot="item">
          <StatTile label={m.label} value={m.value} icon={m.icon} hint={m.hint} />
        </Box>
      {/each}
    </Grid>
  {/if}
  {#if activity}
    <Grid cols="1-2" class="items-stretch gap-4">
      {#if ((chart.series?.length ?? 0) > 0)}
        <Panel title={chart.title} description={chart.text} id={tpl("{0}-chart", id)} class="h-full">
          <BarChart bars={chart.series} label={chart.summary} height={144} />
        </Panel>
      {/if}
      {#if ((activity?.events?.length ?? 0) > 0)}
        <Panel title={activity?.title} description={activity?.text} id={tpl("{0}-feed", id)} class="h-full">
          <Timeline items={activity?.events} />
        </Panel>
      {/if}
    </Grid>
  {:else if ((chart.series?.length ?? 0) > 0)}
    <Panel title={chart.title} description={chart.text} id={tpl("{0}-chart", id)} class="h-full">
      <BarChart bars={chart.series} label={chart.summary} height={144} />
    </Panel>
  {/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 app-main
components/app-main.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 main column of AppShell: the heading, the metric tiles, and the chart panel (beside the activity panel
 * when `activity` is given).
 */
import { type ReactNode } from "react";
import { Box, Grid, Stack, Title } from "../compose";
import { BarChart } from "../components/bar-chart";
import { Panel } from "../components/panel";
import { StatTile } from "../components/stat-tile";
import { Timeline } from "../components/timeline";
import { tpl } from "../utils";
import type { Metric } from "../blocks/metric-row.types";
import type { Point } from "../blocks/chart-panel.types";
import type { Event } from "../blocks/activity-feed.types";
import type { OverviewChart, OverviewActivity } from "../blocks/dashboard-overview.types";

export type AppMainProps = {
  id: string;
  title: string;
  metrics: Metric[];
  chart: OverviewChart;
  activity?: OverviewActivity;
  cols?: "1-2" | "1-4";
  density?: "default" | "compact";
};

export function AppMain({
  id,
  title,
  metrics,
  chart,
  activity,
  cols = "1-2",
  density = "default",
}: AppMainProps) {
  return (
    <Stack
      gap={(((density as string) === "compact") ? "4" : "6")}
      align="stretch"
      className="min-w-0"
      data-slot="app-main"
    >
      <Title as={2} size="2xl" weight="bold" id={tpl("{0}-title", id)}>
        {title}
      </Title>
      {((metrics?.length ?? 0) > 0) ? (
        <Grid cols={cols} className="gap-4" data-slot="items">
          {(metrics ?? []).map((m) => (
            <Box key={m.id} data-slot="item">
              <StatTile label={m.label} value={m.value} icon={m.icon} hint={m.hint} />
            </Box>
          ))}
        </Grid>
      ) : null}
      {activity ? (
        <Grid cols="1-2" className="items-stretch gap-4">
          {((chart.series?.length ?? 0) > 0) ? (
            <Panel title={chart.title} description={chart.text} id={tpl("{0}-chart", id)} className="h-full">
              <BarChart bars={chart.series} label={chart.summary} height={144} />
            </Panel>
          ) : null}
          {((activity?.events?.length ?? 0) > 0) ? (
            <Panel title={activity?.title} description={activity?.text} id={tpl("{0}-feed", id)} className="h-full">
              <Timeline items={activity?.events} />
            </Panel>
          ) : null}
        </Grid>
      ) : ((chart.series?.length ?? 0) > 0) ? (
        <Panel title={chart.title} description={chart.text} id={tpl("{0}-chart", id)} className="h-full">
          <BarChart bars={chart.series} label={chart.summary} height={144} />
        </Panel>
      ) : 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 app-main
components/app-main.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 main column of AppShell: the heading, the metric tiles, and the chart panel (beside the activity panel
  when `activity` is given).
-->
<script lang="ts">
import type { Metric } from "../blocks/metric-row.types";
import type { Point } from "../blocks/chart-panel.types";
import type { Event } from "../blocks/activity-feed.types";
import type { OverviewChart, OverviewActivity } from "../blocks/dashboard-overview.types";

export type AppMainProps = {
  id: string;
  title: string;
  metrics: Metric[];
  chart: OverviewChart;
  activity?: OverviewActivity;
  cols?: "1-2" | "1-4";
  density?: "default" | "compact";
};
</script>

<script setup lang="ts">
import Box from "../compose/Box.vue";
import Grid from "../compose/Grid.vue";
import Stack from "../compose/Stack.vue";
import Title from "../compose/Title.vue";
import BarChart from "../components/bar-chart.vue";
import Panel from "../components/panel.vue";
import StatTile from "../components/stat-tile.vue";
import Timeline from "../components/timeline.vue";
import { tpl } from "../utils";

const {
  id,
  title,
  metrics,
  chart,
  activity,
  cols = "1-2",
  density = "default",
} = defineProps<AppMainProps>();
</script>

<template>
  <Stack
    :gap="(((density as string) === 'compact') ? '4' : '6')"
    align="stretch"
    class="min-w-0"
    data-slot="app-main"
  >
    <Title :as="2" size="2xl" weight="bold" :id="tpl('{0}-title', id)">
      {{ title }}
    </Title>
    <Grid v-if="((metrics?.length ?? 0) > 0)" :cols="cols" class="gap-4" data-slot="items">
      <Box v-for="m in metrics" :key="m.id" data-slot="item">
        <StatTile :label="m.label" :value="m.value" :icon="m.icon" :hint="m.hint" />
      </Box>
    </Grid>
    <Grid v-if="activity" cols="1-2" class="items-stretch gap-4">
      <Panel
        v-if="((chart.series?.length ?? 0) > 0)"
        :title="chart.title"
        :description="chart.text"
        :id="tpl('{0}-chart', id)"
        class="h-full"
      >
        <BarChart :bars="chart.series" :label="chart.summary" :height="144" />
      </Panel>
      <Panel
        v-if="((activity?.events?.length ?? 0) > 0)"
        :title="activity?.title"
        :description="activity?.text"
        :id="tpl('{0}-feed', id)"
        class="h-full"
      >
        <Timeline :items="activity?.events" />
      </Panel>
    </Grid>
    <Panel
      v-else-if="((chart.series?.length ?? 0) > 0)"
      :title="chart.title"
      :description="chart.text"
      :id="tpl('{0}-chart', id)"
      class="h-full"
    >
      <BarChart :bars="chart.series" :label="chart.summary" :height="144" />
    </Panel>
  </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 app-main
components/app-main.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 main column of AppShell: the heading, the metric tiles, and the chart panel (beside the activity panel
 * when `activity` is given).
 */
import { For, type JSX } from "solid-js";
import { Box, Grid, Stack, Title } from "../compose";
import { BarChart } from "../components/bar-chart";
import { Panel } from "../components/panel";
import { StatTile } from "../components/stat-tile";
import { Timeline } from "../components/timeline";
import { tpl } from "../utils";
import type { Metric } from "../blocks/metric-row.types";
import type { Point } from "../blocks/chart-panel.types";
import type { Event } from "../blocks/activity-feed.types";
import type { OverviewChart, OverviewActivity } from "../blocks/dashboard-overview.types";

export type AppMainProps = {
  id: string;
  title: string;
  metrics: Metric[];
  chart: OverviewChart;
  activity?: OverviewActivity;
  cols?: "1-2" | "1-4";
  density?: "default" | "compact";
};

export function AppMain({
  id,
  title,
  metrics,
  chart,
  activity,
  cols = "1-2",
  density = "default",
}: AppMainProps) {
  return (
    <Stack
      gap={(((density as string) === "compact") ? "4" : "6")}
      align="stretch"
      class="min-w-0"
      data-slot="app-main"
    >
      <Title as={2} size="2xl" weight="bold" id={tpl("{0}-title", id)}>
        {title}
      </Title>
      {((metrics?.length ?? 0) > 0) ? (
        <Grid cols={cols} class="gap-4" data-slot="items">
          <For each={metrics ?? []}>{(m) => (
            <Box data-slot="item">
              <StatTile label={m.label} value={m.value} icon={m.icon} hint={m.hint} />
            </Box>
          )}</For>
        </Grid>
      ) : null}
      {activity ? (
        <Grid cols="1-2" class="items-stretch gap-4">
          {((chart.series?.length ?? 0) > 0) ? (
            <Panel title={chart.title} description={chart.text} id={tpl("{0}-chart", id)} class="h-full">
              <BarChart bars={chart.series} label={chart.summary} height={144} />
            </Panel>
          ) : null}
          {((activity?.events?.length ?? 0) > 0) ? (
            <Panel title={activity?.title} description={activity?.text} id={tpl("{0}-feed", id)} class="h-full">
              <Timeline items={activity?.events} />
            </Panel>
          ) : null}
        </Grid>
      ) : ((chart.series?.length ?? 0) > 0) ? (
        <Panel title={chart.title} description={chart.text} id={tpl("{0}-chart", id)} class="h-full">
          <BarChart bars={chart.series} label={chart.summary} height={144} />
        </Panel>
      ) : 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 app-main
blocks/app-main.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/app-main.json

package blocks

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

// AppMainProps are the props of AppMain; the values are the JSON shapes of the TypeScript props.
type AppMainProps struct {
	Id any `json:"id"`
	Title any `json:"title"`
	Metrics any `json:"metrics"`
	Chart any `json:"chart"`
	Activity any `json:"activity"`
	Cols any `json:"cols"`
	Density any `json:"density"`
}

// The main column of AppShell: the heading, the metric tiles, and the chart panel (beside the activity panel when `activity` is given).
templ AppMain(p AppMainProps) {
	{{ vId := p.Id }}
	{{ vTitle := p.Title }}
	{{ vMetrics := p.Metrics }}
	{{ vChart := p.Chart }}
	{{ vActivity := p.Activity }}
	{{ vCols := uiutils.Def(p.Cols, "1-2") }}
	{{ vDensity := uiutils.Def(p.Density, "default") }}
	@compose.Stack(compose.StackProps{Gap: uiutils.S(uiutils.Cond(uiutils.T(uiutils.Eq(vDensity, "compact")), "4", "6")), Align: "stretch", BoxProps: box.BoxProps{Class: "min-w-0", Attrs: uiutils.Attrs("data-slot", "app-main")}}) {
		@compose.Title(compose.TitleProps{As: "2", Size: "2xl", Weight: "bold", TextProps: text.TextProps{Attrs: uiutils.Attrs("id", uiutils.Tpl("{0}-title", vId))}}) {
			{ uiutils.Text(vTitle) }
		}
		if uiutils.Gt(uiutils.Len(vMetrics), float64(0)) {
			@compose.Grid(compose.GridProps{Cols: uiutils.S(vCols), BoxProps: box.BoxProps{Class: "gap-4", Attrs: uiutils.Attrs("data-slot", "items")}}) {
				for _, vM := range uiutils.L(vMetrics) {
					@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Attrs: uiutils.Attrs("data-slot", "item")}}) {
						@StatTile(StatTileProps{Label: uiutils.Get(vM, "label"), Value: uiutils.Get(vM, "value"), Icon: uiutils.Get(vM, "icon"), Hint: uiutils.Get(vM, "hint")})
					}
				}
			}
		}
		if uiutils.T(vActivity) {
			@compose.Grid(compose.GridProps{Cols: "1-2", BoxProps: box.BoxProps{Class: "items-stretch gap-4"}}) {
				if uiutils.Gt(uiutils.Len(uiutils.Get(vChart, "series")), float64(0)) {
					@Panel(PanelProps{Title: uiutils.Get(vChart, "title"), Description: uiutils.Get(vChart, "text"), Id: uiutils.Tpl("{0}-chart", vId), Class: uiutils.Cnv("h-full")}) {
						@BarChart(BarChartProps{Bars: uiutils.Get(vChart, "series"), Label: uiutils.Get(vChart, "summary"), Height: float64(144)})
					}
				}
				if uiutils.Gt(uiutils.Len(uiutils.Get(vActivity, "events")), float64(0)) {
					@Panel(PanelProps{Title: uiutils.Get(vActivity, "title"), Description: uiutils.Get(vActivity, "text"), Id: uiutils.Tpl("{0}-feed", vId), Class: uiutils.Cnv("h-full")}) {
						@Timeline(TimelineProps{Items: uiutils.Get(vActivity, "events")})
					}
				}
			}
		} else if uiutils.Gt(uiutils.Len(uiutils.Get(vChart, "series")), float64(0)) {
			@Panel(PanelProps{Title: uiutils.Get(vChart, "title"), Description: uiutils.Get(vChart, "text"), Id: uiutils.Tpl("{0}-chart", vId), Class: uiutils.Cnv("h-full")}) {
				@BarChart(BarChartProps{Bars: uiutils.Get(vChart, "series"), Label: uiutils.Get(vChart, "summary"), Height: float64(144)})
			}
		}
	}
}

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 app-main
blocks/app-main.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/app-main.json
    The main column of AppShell: the heading, the metric tiles, and the chart panel (beside the activity panel when `activity` is given).
    Props (p): id, title, metrics, chart, activity, cols, density. -#}
{%- set v_id = (p.id ?? null) -%}
{%- set v_title = (p.title ?? null) -%}
{%- set v_metrics = (p.metrics ?? null) -%}
{%- set v_chart = (p.chart ?? null) -%}
{%- set v_activity = (p.activity ?? null) -%}
{%- set v_cols = (p.cols ?? '1-2') -%}
{%- set v_density = (p.density ?? 'default') -%}
{%- set c_8 -%}
  {%- set c_1 -%}
    {{ og_text(v_title) }}
  {%- endset -%}
  {{ include('compose/Title.html.twig', {'as': 2, 'size': '2xl', 'weight': 'bold', 'attrs': og_attrs(['id', og_tpl('{0}-title', [v_id])]), 'children': c_1}, with_context = false) }}
  {%- if og_t(og_gt(og_len(v_metrics), 0)) %}
    {%- set c_3 -%}
      {%- for v_m in og_l(v_metrics) %}
        {%- set c_2 -%}
          {{ include('blocks/stat-tile.html.twig', {'p': {'label': og_get(v_m, ['label']), 'value': og_get(v_m, ['value']), 'icon': og_get(v_m, ['icon']), 'hint': og_get(v_m, ['hint'])}}, with_context = false) }}
        {%- endset -%}
        {{ include('compose/Box.html.twig', {'attrs': og_attrs(['data-slot', 'item']), 'children': c_2}, with_context = false) }}
      {%- endfor %}
    {%- endset -%}
    {{ include('compose/Grid.html.twig', {'cols': og_s(v_cols), 'class': 'gap-4', 'attrs': og_attrs(['data-slot', 'items']), 'children': c_3}, with_context = false) }}
  {%- endif %}
  {%- if og_t(v_activity) %}
    {%- set c_6 -%}
      {%- if og_t(og_gt(og_len(og_get(v_chart, ['series'])), 0)) %}
        {%- set c_4 -%}
          {{ include('blocks/bar-chart.html.twig', {'p': {'bars': og_get(v_chart, ['series']), 'label': og_get(v_chart, ['summary']), 'height': 144}}, with_context = false) }}
        {%- endset -%}
        {{ include('blocks/panel.html.twig', {'p': {'title': og_get(v_chart, ['title']), 'description': og_get(v_chart, ['text']), 'id': og_tpl('{0}-chart', [v_id]), 'className': og_cnv(['h-full'])}, 'children': og_markup(c_4)}, with_context = false) }}
      {%- endif %}
      {%- if og_t(og_gt(og_len(og_get(v_activity, ['events'])), 0)) %}
        {%- set c_5 -%}
          {{ include('blocks/timeline.html.twig', {'p': {'items': og_get(v_activity, ['events'])}}, with_context = false) }}
        {%- endset -%}
        {{ include('blocks/panel.html.twig', {'p': {'title': og_get(v_activity, ['title']), 'description': og_get(v_activity, ['text']), 'id': og_tpl('{0}-feed', [v_id]), 'className': og_cnv(['h-full'])}, 'children': og_markup(c_5)}, with_context = false) }}
      {%- endif %}
    {%- endset -%}
    {{ include('compose/Grid.html.twig', {'cols': '1-2', 'class': 'items-stretch gap-4', 'children': c_6}, with_context = false) }}
  {%- elseif og_t(og_gt(og_len(og_get(v_chart, ['series'])), 0)) %}
    {%- set c_7 -%}
      {{ include('blocks/bar-chart.html.twig', {'p': {'bars': og_get(v_chart, ['series']), 'label': og_get(v_chart, ['summary']), 'height': 144}}, with_context = false) }}
    {%- endset -%}
    {{ include('blocks/panel.html.twig', {'p': {'title': og_get(v_chart, ['title']), 'description': og_get(v_chart, ['text']), 'id': og_tpl('{0}-chart', [v_id]), 'className': og_cnv(['h-full'])}, 'children': og_markup(c_7)}, with_context = false) }}
  {%- endif %}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': og_s((og_t(og_eq(v_density, 'compact')) ? '4' : '6')), 'align': 'stretch', 'class': 'min-w-0', 'attrs': og_attrs(['data-slot', 'app-main']), 'children': c_8}, 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 app-main
blocks/app-main.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/app-main.json
    The main column of AppShell: the heading, the metric tiles, and the chart panel (beside the activity panel when `activity` is given).
    Props (p): id, title, metrics, chart, activity, cols, density. *}
{var $v_id = ($p['id'] ?? null)}
{var $v_title = ($p['title'] ?? null)}
{var $v_metrics = ($p['metrics'] ?? null)}
{var $v_chart = ($p['chart'] ?? null)}
{var $v_activity = ($p['activity'] ?? null)}
{var $v_cols = ($p['cols'] ?? '1-2')}
{var $v_density = ($p['density'] ?? 'default')}
{capture $c_8}
  {capture $c_1}
    {=og_text($v_title)}
  {/capture}
  {=og_include('compose/Title.latte', ['as' => 2, 'size' => '2xl', 'weight' => 'bold', 'attrs' => og_attrs(['id', og_tpl('{0}-title', [$v_id])]), 'children' => (string) $c_1])|noescape}
  {if og_t(og_gt(og_len($v_metrics), 0))}
    {capture $c_3}
      {foreach og_l($v_metrics) as $v_m}
        {capture $c_2}
          {=og_include('blocks/stat-tile.latte', ['p' => ['label' => og_get($v_m, ['label']), 'value' => og_get($v_m, ['value']), 'icon' => og_get($v_m, ['icon']), 'hint' => og_get($v_m, ['hint'])]])|noescape}
        {/capture}
        {=og_include('compose/Box.latte', ['attrs' => og_attrs(['data-slot', 'item']), 'children' => (string) $c_2])|noescape}
      {/foreach}
    {/capture}
    {=og_include('compose/Grid.latte', ['cols' => og_s($v_cols), 'class' => 'gap-4', 'attrs' => og_attrs(['data-slot', 'items']), 'children' => (string) $c_3])|noescape}
  {/if}
  {if og_t($v_activity)}
    {capture $c_6}
      {if og_t(og_gt(og_len(og_get($v_chart, ['series'])), 0))}
        {capture $c_4}
          {=og_include('blocks/bar-chart.latte', ['p' => ['bars' => og_get($v_chart, ['series']), 'label' => og_get($v_chart, ['summary']), 'height' => 144]])|noescape}
        {/capture}
        {=og_include('blocks/panel.latte', ['p' => ['title' => og_get($v_chart, ['title']), 'description' => og_get($v_chart, ['text']), 'id' => og_tpl('{0}-chart', [$v_id]), 'className' => og_cnv(['h-full'])], 'children' => og_markup($c_4)])|noescape}
      {/if}
      {if og_t(og_gt(og_len(og_get($v_activity, ['events'])), 0))}
        {capture $c_5}
          {=og_include('blocks/timeline.latte', ['p' => ['items' => og_get($v_activity, ['events'])]])|noescape}
        {/capture}
        {=og_include('blocks/panel.latte', ['p' => ['title' => og_get($v_activity, ['title']), 'description' => og_get($v_activity, ['text']), 'id' => og_tpl('{0}-feed', [$v_id]), 'className' => og_cnv(['h-full'])], 'children' => og_markup($c_5)])|noescape}
      {/if}
    {/capture}
    {=og_include('compose/Grid.latte', ['cols' => '1-2', 'class' => 'items-stretch gap-4', 'children' => (string) $c_6])|noescape}
  {elseif og_t(og_gt(og_len(og_get($v_chart, ['series'])), 0))}
    {capture $c_7}
      {=og_include('blocks/bar-chart.latte', ['p' => ['bars' => og_get($v_chart, ['series']), 'label' => og_get($v_chart, ['summary']), 'height' => 144]])|noescape}
    {/capture}
    {=og_include('blocks/panel.latte', ['p' => ['title' => og_get($v_chart, ['title']), 'description' => og_get($v_chart, ['text']), 'id' => og_tpl('{0}-chart', [$v_id]), 'className' => og_cnv(['h-full'])], 'children' => og_markup($c_7)])|noescape}
  {/if}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => og_s((og_t(og_eq($v_density, 'compact')) ? '4' : '6')), 'align' => 'stretch', 'class' => 'min-w-0', 'attrs' => og_attrs(['data-slot', 'app-main']), 'children' => (string) $c_8])|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 app-main
blocks/app-main.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/app-main.json
    The main column of AppShell: the heading, the metric tiles, and the chart panel (beside the activity panel when `activity` is given).
    Props (p): id, title, metrics, chart, activity, cols, density. -#}
{%- set v_id = og_def(p['id'], none) -%}
{%- set v_title = og_def(p['title'], none) -%}
{%- set v_metrics = og_def(p['metrics'], none) -%}
{%- set v_chart = og_def(p['chart'], none) -%}
{%- set v_activity = og_def(p['activity'], none) -%}
{%- set v_cols = og_def(p['cols'], '1-2') -%}
{%- set v_density = og_def(p['density'], 'default') -%}
{%- set c_8 -%}
  {%- set c_1 -%}
    {{ og_text(v_title) }}
  {%- endset -%}
  {{ og_include('compose/title.html.j2', {'p': {'As': 2, 'Size': '2xl', 'Weight': 'bold', 'Attrs': og_attrs(['id', og_tpl('{0}-title', [v_id])])}, 'children': c_1}) }}
  {%- if og_t(og_gt(og_len(v_metrics), 0)) %}
    {%- set c_3 -%}
      {%- for v_m in og_l(v_metrics) %}
        {%- set c_2 -%}
          {{ og_include('blocks/stat-tile.html.j2', {'p': {'label': og_get(v_m, ['label']), 'value': og_get(v_m, ['value']), 'icon': og_get(v_m, ['icon']), 'hint': og_get(v_m, ['hint'])}}) }}
        {%- endset -%}
        {{ og_include('compose/box.html.j2', {'p': {'Attrs': og_attrs(['data-slot', 'item'])}, 'children': c_2}) }}
      {%- endfor %}
    {%- endset -%}
    {{ og_include('compose/grid.html.j2', {'p': {'Cols': og_s(v_cols), 'Class': 'gap-4', 'Attrs': og_attrs(['data-slot', 'items'])}, 'children': c_3}) }}
  {%- endif %}
  {%- if og_t(v_activity) %}
    {%- set c_6 -%}
      {%- if og_t(og_gt(og_len(og_get(v_chart, ['series'])), 0)) %}
        {%- set c_4 -%}
          {{ og_include('blocks/bar-chart.html.j2', {'p': {'bars': og_get(v_chart, ['series']), 'label': og_get(v_chart, ['summary']), 'height': 144}}) }}
        {%- endset -%}
        {{ og_include('blocks/panel.html.j2', {'p': {'title': og_get(v_chart, ['title']), 'description': og_get(v_chart, ['text']), 'id': og_tpl('{0}-chart', [v_id]), 'className': og_cnv(['h-full'])}, 'children': og_markup(c_4)}) }}
      {%- endif %}
      {%- if og_t(og_gt(og_len(og_get(v_activity, ['events'])), 0)) %}
        {%- set c_5 -%}
          {{ og_include('blocks/timeline.html.j2', {'p': {'items': og_get(v_activity, ['events'])}}) }}
        {%- endset -%}
        {{ og_include('blocks/panel.html.j2', {'p': {'title': og_get(v_activity, ['title']), 'description': og_get(v_activity, ['text']), 'id': og_tpl('{0}-feed', [v_id]), 'className': og_cnv(['h-full'])}, 'children': og_markup(c_5)}) }}
      {%- endif %}
    {%- endset -%}
    {{ og_include('compose/grid.html.j2', {'p': {'Cols': '1-2', 'Class': 'items-stretch gap-4'}, 'children': c_6}) }}
  {%- elif og_t(og_gt(og_len(og_get(v_chart, ['series'])), 0)) %}
    {%- set c_7 -%}
      {{ og_include('blocks/bar-chart.html.j2', {'p': {'bars': og_get(v_chart, ['series']), 'label': og_get(v_chart, ['summary']), 'height': 144}}) }}
    {%- endset -%}
    {{ og_include('blocks/panel.html.j2', {'p': {'title': og_get(v_chart, ['title']), 'description': og_get(v_chart, ['text']), 'id': og_tpl('{0}-chart', [v_id]), 'className': og_cnv(['h-full'])}, 'children': og_markup(c_7)}) }}
  {%- endif %}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': og_s(('4' if og_t(og_eq(v_density, 'compact')) else '6')), 'Align': 'stretch', 'Class': 'min-w-0', 'Attrs': og_attrs(['data-slot', 'app-main'])}, 'children': c_8}) }}

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 main column of AppShell: the heading, the metric tiles, and the chart panel (beside the activity panel when `activity` is given).

Props of AppMain
PropTypeDefault Description
id (required)string-
title (required)string-
metrics (required)Metric[]-
chart (required)OverviewChart-
activity OverviewActivity-the activity panel beside the chart; none: the chart alone
cols "1-2" | "1-4""1-2"columns of the metric tiles
density "default" | "compact""default"

Used in