Skip to content
ui8kit

component / components

Media Topics

Media Topics component

Install

npx ui8kit add media-topics

Pulls in: compose, inline, kit-box, kit-text, lucide-icon, media-list, menu-entry, stack, text, utils

Preview

All categories

All products

48 items

Desk

12 items

Bags

9 items

Audio

11 items

Lighting

7 items

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 media-topics
components/media-topics.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 topics of MediaList as card rows: a glyph tile, the name, the count and an arrow. -->
<script lang="ts" module>
  import type { Snippet } from "svelte";
  import type { MediaExtras, MediaListLabels } from "../blocks/media-list.types";

  export type MediaTopicsProps = {
    extras: MediaExtras;
    labels: MediaListLabels;
  };
</script>

<script lang="ts">
  import Inline from "../compose/Inline.svelte";
  import LucideIcon from "../icons/LucideIcon.svelte";
  import Stack from "../compose/Stack.svelte";
  import Text from "../compose/Text.svelte";
  import MenuEntry from "../components/menu-entry.svelte";
  import { tpl } from "../utils";

  let { extras, labels }: MediaTopicsProps = $props();
</script>

<Stack gap="4" align="stretch" data-slot="media-topics">
  <Text size="sm" weight="semibold">
    {labels.list}
  </Text>
  {#each extras.topics as c, i (c.id)}
    {#if (i < 5)}
      <MenuEntry
        href={c.href}
        class="rounded bg-card inset-ring inset-ring-border flex w-full items-center gap-4 p-4"
        variant="block"
        testid="media-topic"
        block={true}
      >
        <Inline class="flex size-8 shrink-0 items-center justify-center rounded bg-primary text-primary-foreground">
          <LucideIcon name={c.icon} size={16} />
        </Inline>
        <Stack gap="0" class="min-w-0 flex-1">
          <Text size="sm" weight="semibold">
            {c.name}
          </Text>
          <Text size="xs" class="text-muted-foreground">
            {tpl(labels.count, c.count)}
          </Text>
        </Stack>
        <LucideIcon name="arrow-right" size={16} />
      </MenuEntry>
    {/if}
  {/each}
</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 media-topics
components/media-topics.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 topics of MediaList as card rows: a glyph tile, the name, the count and an arrow. */
import { Fragment, type ReactNode } from "react";
import { Inline, Stack, Text } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { MenuEntry } from "../components/menu-entry";
import { tpl } from "../utils";
import type { MediaExtras, MediaListLabels } from "../blocks/media-list.types";

export type MediaTopicsProps = {
  extras: MediaExtras;
  labels: MediaListLabels;
};

export function MediaTopics({ extras, labels }: MediaTopicsProps) {
  return (
    <Stack gap="4" align="stretch" data-slot="media-topics">
      <Text size="sm" weight="semibold">
        {labels.list}
      </Text>
      {(extras.topics ?? []).map((c, i) => (
        <Fragment key={c.id}>
          {(i < 5) ? (
            <MenuEntry
              href={c.href}
              className="rounded bg-card inset-ring inset-ring-border flex w-full items-center gap-4 p-4"
              variant="block"
              testid="media-topic"
              block={true}
            >
              <Inline className={"flex size-8 shrink-0 items-center justify-center rounded bg-primary text-primary-foreground"}>
                <LucideIcon name={c.icon} size={16} />
              </Inline>
              <Stack gap="0" className="min-w-0 flex-1">
                <Text size="sm" weight="semibold">
                  {c.name}
                </Text>
                <Text size="xs" className="text-muted-foreground">
                  {tpl(labels.count, c.count)}
                </Text>
              </Stack>
              <LucideIcon name="arrow-right" size={16} />
            </MenuEntry>
          ) : null}
        </Fragment>
      ))}
    </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 media-topics
components/media-topics.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 topics of MediaList as card rows: a glyph tile, the name, the count and an arrow. -->
<script lang="ts">
import type { MediaExtras, MediaListLabels } from "../blocks/media-list.types";

export type MediaTopicsProps = {
  extras: MediaExtras;
  labels: MediaListLabels;
};
</script>

<script setup lang="ts">
import Inline from "../compose/Inline.vue";
import LucideIcon from "../icons/LucideIcon.vue";
import Stack from "../compose/Stack.vue";
import Text from "../compose/Text.vue";
import MenuEntry from "../components/menu-entry.vue";
import { tpl } from "../utils";

const { extras, labels } = defineProps<MediaTopicsProps>();
</script>

<template>
  <Stack gap="4" align="stretch" data-slot="media-topics">
    <Text size="sm" weight="semibold">
      {{ labels.list }}
    </Text>
    <template v-for="(c, i) in extras.topics" :key="c.id">
      <MenuEntry v-if="(i < 5)"
        :href="c.href"
        class="rounded bg-card inset-ring inset-ring-border flex w-full items-center gap-4 p-4"
        variant="block"
        testid="media-topic"
        :block="true"
      >
        <Inline class="flex size-8 shrink-0 items-center justify-center rounded bg-primary text-primary-foreground">
          <LucideIcon :name="c.icon" :size="16" />
        </Inline>
        <Stack gap="0" class="min-w-0 flex-1">
          <Text size="sm" weight="semibold">
            {{ c.name }}
          </Text>
          <Text size="xs" class="text-muted-foreground">
            {{ tpl(labels.count, c.count) }}
          </Text>
        </Stack>
        <LucideIcon name="arrow-right" :size="16" />
      </MenuEntry>
    </template>
  </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 media-topics
components/media-topics.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 topics of MediaList as card rows: a glyph tile, the name, the count and an arrow. */
import { For, type JSX } from "solid-js";
import { Inline, Stack, Text } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { MenuEntry } from "../components/menu-entry";
import { tpl } from "../utils";
import type { MediaExtras, MediaListLabels } from "../blocks/media-list.types";

export type MediaTopicsProps = {
  extras: MediaExtras;
  labels: MediaListLabels;
};

export function MediaTopics({ extras, labels }: MediaTopicsProps) {
  return (
    <Stack gap="4" align="stretch" data-slot="media-topics">
      <Text size="sm" weight="semibold">
        {labels.list}
      </Text>
      <For each={extras.topics ?? []}>{(c, iOf) => { const i = iOf(); return (
        <>
          {(i < 5) ? (
            <MenuEntry
              href={c.href}
              class="rounded bg-card inset-ring inset-ring-border flex w-full items-center gap-4 p-4"
              variant="block"
              testid="media-topic"
              block={true}
            >
              <Inline class="flex size-8 shrink-0 items-center justify-center rounded bg-primary text-primary-foreground">
                <LucideIcon name={c.icon} size={16} />
              </Inline>
              <Stack gap="0" class="min-w-0 flex-1">
                <Text size="sm" weight="semibold">
                  {c.name}
                </Text>
                <Text size="xs" class="text-muted-foreground">
                  {tpl(labels.count, c.count)}
                </Text>
              </Stack>
              <LucideIcon name="arrow-right" size={16} />
            </MenuEntry>
          ) : null}
        </>
      ); }}</For>
    </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 media-topics
blocks/media-topics.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/media-topics.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/icons"
	"github.com/ui8kit/codegen/generated/templ/ui/text"
	uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)

// MediaTopicsProps are the props of MediaTopics; the values are the JSON shapes of the TypeScript props.
type MediaTopicsProps struct {
	Extras any `json:"extras"`
	Labels any `json:"labels"`
}

// The topics of MediaList as card rows: a glyph tile, the name, the count and an arrow.
templ MediaTopics(p MediaTopicsProps) {
	{{ vExtras := p.Extras }}
	{{ vLabels := p.Labels }}
	@compose.Stack(compose.StackProps{Gap: "4", Align: "stretch", BoxProps: box.BoxProps{Attrs: uiutils.Attrs("data-slot", "media-topics")}}) {
		@compose.Text(compose.TextProps{Size: "sm", Weight: "semibold", TextProps: text.TextProps{}}) {
			{ uiutils.Text(uiutils.Get(vLabels, "list")) }
		}
		for vI, vC := range uiutils.L(uiutils.Get(vExtras, "topics")) {
			if uiutils.Lt(float64(vI), float64(5)) {
				@MenuEntry(MenuEntryProps{Href: uiutils.Get(vC, "href"), Class: uiutils.Cnv("rounded bg-card inset-ring inset-ring-border flex w-full items-center gap-4 p-4"), Variant: "block", Testid: "media-topic", Block: true}) {
					@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "flex size-8 shrink-0 items-center justify-center rounded bg-primary text-primary-foreground"}}) {
						@icons.LucideIcon(icons.LucideIconProps{Name: uiutils.S(uiutils.Get(vC, "icon")), Size: 16})
					}
					@compose.Stack(compose.StackProps{Gap: "0", BoxProps: box.BoxProps{Class: "min-w-0 flex-1"}}) {
						@compose.Text(compose.TextProps{Size: "sm", Weight: "semibold", TextProps: text.TextProps{}}) {
							{ uiutils.Text(uiutils.Get(vC, "name")) }
						}
						@compose.Text(compose.TextProps{Size: "xs", TextProps: text.TextProps{Class: "text-muted-foreground"}}) {
							{ uiutils.Text(uiutils.Tpl(uiutils.Get(vLabels, "count"), uiutils.Get(vC, "count"))) }
						}
					}
					@icons.LucideIcon(icons.LucideIconProps{Name: "arrow-right", Size: 16})
				}
			}
		}
	}
}

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 media-topics
blocks/media-topics.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/media-topics.json
    The topics of MediaList as card rows: a glyph tile, the name, the count and an arrow.
    Props (p): extras, labels. -#}
{%- set v_extras = (p.extras ?? null) -%}
{%- set v_labels = (p.labels ?? null) -%}
{%- set c_7 -%}
  {%- set c_1 -%}
    {{ og_text(og_get(v_labels, ['list'])) }}
  {%- endset -%}
  {{ include('compose/Text.html.twig', {'size': 'sm', 'weight': 'semibold', 'children': c_1}, with_context = false) }}
  {%- for v_c in og_l(og_get(v_extras, ['topics'])) %}
    {%- set v_i = loop.index0 -%}
    {%- if og_t(og_lt(v_i, 5)) %}
      {%- set c_6 -%}
        {%- set c_2 -%}
          {{ include('icons/LucideIcon.html.twig', {'name': og_s(og_get(v_c, ['icon'])), 'size': 16}, with_context = false) }}
        {%- endset -%}
        {{ include('compose/Inline.html.twig', {'class': 'flex size-8 shrink-0 items-center justify-center rounded bg-primary text-primary-foreground', 'children': c_2}, with_context = false) }}
        {%- set c_5 -%}
          {%- set c_3 -%}
            {{ og_text(og_get(v_c, ['name'])) }}
          {%- endset -%}
          {{ include('compose/Text.html.twig', {'size': 'sm', 'weight': 'semibold', 'children': c_3}, with_context = false) }}
          {%- set c_4 -%}
            {{ og_text(og_tpl(og_get(v_labels, ['count']), [og_get(v_c, ['count'])])) }}
          {%- endset -%}
          {{ include('compose/Text.html.twig', {'size': 'xs', 'class': 'text-muted-foreground', 'children': c_4}, with_context = false) }}
        {%- endset -%}
        {{ include('compose/Stack.html.twig', {'gap': '0', 'class': 'min-w-0 flex-1', 'children': c_5}, with_context = false) }}
        {{ include('icons/LucideIcon.html.twig', {'name': 'arrow-right', 'size': 16}, with_context = false) }}
      {%- endset -%}
      {{ include('blocks/menu-entry.html.twig', {'p': {'href': og_get(v_c, ['href']), 'className': og_cnv(['rounded bg-card inset-ring inset-ring-border flex w-full items-center gap-4 p-4']), 'variant': 'block', 'testid': 'media-topic', 'block': true}, 'children': og_markup(c_6)}, with_context = false) }}
    {%- endif %}
  {%- endfor %}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '4', 'align': 'stretch', 'attrs': og_attrs(['data-slot', 'media-topics']), 'children': c_7}, 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 media-topics
blocks/media-topics.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/media-topics.json
    The topics of MediaList as card rows: a glyph tile, the name, the count and an arrow.
    Props (p): extras, labels. *}
{var $v_extras = ($p['extras'] ?? null)}
{var $v_labels = ($p['labels'] ?? null)}
{capture $c_7}
  {capture $c_1}
    {=og_text(og_get($v_labels, ['list']))}
  {/capture}
  {=og_include('compose/Text.latte', ['size' => 'sm', 'weight' => 'semibold', 'children' => (string) $c_1])|noescape}
  {foreach og_l(og_get($v_extras, ['topics'])) as $v_c}
    {var $v_i = $iterator->counter0}
    {if og_t(og_lt($v_i, 5))}
      {capture $c_6}
        {capture $c_2}
          {=og_include('icons/LucideIcon.latte', ['name' => og_s(og_get($v_c, ['icon'])), 'size' => 16])|noescape}
        {/capture}
        {=og_include('compose/Inline.latte', ['class' => 'flex size-8 shrink-0 items-center justify-center rounded bg-primary text-primary-foreground', 'children' => (string) $c_2])|noescape}
        {capture $c_5}
          {capture $c_3}
            {=og_text(og_get($v_c, ['name']))}
          {/capture}
          {=og_include('compose/Text.latte', ['size' => 'sm', 'weight' => 'semibold', 'children' => (string) $c_3])|noescape}
          {capture $c_4}
            {=og_text(og_tpl(og_get($v_labels, ['count']), [og_get($v_c, ['count'])]))}
          {/capture}
          {=og_include('compose/Text.latte', ['size' => 'xs', 'class' => 'text-muted-foreground', 'children' => (string) $c_4])|noescape}
        {/capture}
        {=og_include('compose/Stack.latte', ['gap' => '0', 'class' => 'min-w-0 flex-1', 'children' => (string) $c_5])|noescape}
        {=og_include('icons/LucideIcon.latte', ['name' => 'arrow-right', 'size' => 16])|noescape}
      {/capture}
      {=og_include('blocks/menu-entry.latte', ['p' => ['href' => og_get($v_c, ['href']), 'className' => og_cnv(['rounded bg-card inset-ring inset-ring-border flex w-full items-center gap-4 p-4']), 'variant' => 'block', 'testid' => 'media-topic', 'block' => true], 'children' => og_markup($c_6)])|noescape}
    {/if}
  {/foreach}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '4', 'align' => 'stretch', 'attrs' => og_attrs(['data-slot', 'media-topics']), 'children' => (string) $c_7])|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 media-topics
blocks/media-topics.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/media-topics.json
    The topics of MediaList as card rows: a glyph tile, the name, the count and an arrow.
    Props (p): extras, labels. -#}
{%- set v_extras = og_def(p['extras'], none) -%}
{%- set v_labels = og_def(p['labels'], none) -%}
{%- set c_7 -%}
  {%- set c_1 -%}
    {{ og_text(og_get(v_labels, ['list'])) }}
  {%- endset -%}
  {{ og_include('compose/text.html.j2', {'p': {'Size': 'sm', 'Weight': 'semibold'}, 'children': c_1}) }}
  {%- for v_c in og_l(og_get(v_extras, ['topics'])) %}
    {%- set v_i = loop.index0 -%}
    {%- if og_t(og_lt(v_i, 5)) %}
      {%- set c_6 -%}
        {%- set c_2 -%}
          {{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': og_s(og_get(v_c, ['icon'])), 'Size': 16}}) }}
        {%- endset -%}
        {{ og_include('compose/inline.html.j2', {'p': {'Class': 'flex size-8 shrink-0 items-center justify-center rounded bg-primary text-primary-foreground'}, 'children': c_2}) }}
        {%- set c_5 -%}
          {%- set c_3 -%}
            {{ og_text(og_get(v_c, ['name'])) }}
          {%- endset -%}
          {{ og_include('compose/text.html.j2', {'p': {'Size': 'sm', 'Weight': 'semibold'}, 'children': c_3}) }}
          {%- set c_4 -%}
            {{ og_text(og_tpl(og_get(v_labels, ['count']), [og_get(v_c, ['count'])])) }}
          {%- endset -%}
          {{ og_include('compose/text.html.j2', {'p': {'Size': 'xs', 'Class': 'text-muted-foreground'}, 'children': c_4}) }}
        {%- endset -%}
        {{ og_include('compose/stack.html.j2', {'p': {'Gap': '0', 'Class': 'min-w-0 flex-1'}, 'children': c_5}) }}
        {{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'arrow-right', 'Size': 16}}) }}
      {%- endset -%}
      {{ og_include('blocks/menu-entry.html.j2', {'p': {'href': og_get(v_c, ['href']), 'className': og_cnv(['rounded bg-card inset-ring inset-ring-border flex w-full items-center gap-4 p-4']), 'variant': 'block', 'testid': 'media-topic', 'block': true}, 'children': og_markup(c_6)}) }}
    {%- endif %}
  {%- endfor %}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '4', 'Align': 'stretch', 'Attrs': og_attrs(['data-slot', 'media-topics'])}, 'children': c_7}) }}

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 topics of MediaList as card rows: a glyph tile, the name, the count and an arrow.

Props of MediaTopics
PropTypeDefault Description
extras (required)MediaExtras-
labels (required)MediaListLabels-

Used in