Offer Media
Offer Media component
Install
npx ui8kit add offer-mediaPulls in: box, compose, group, kit-box, kit-text, lucide-icon, media-frame, stack, store-hero, text, utils
Preview
Built in a day
Most teams publish their first page before lunch.
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 offer-media<!-- 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 picture of the StoreHero overlay layout with an offer card floating on its lower corner (the card floats
over the picture).
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
import type { OfferCard } from "../blocks/store-hero.types";
export type OfferMediaProps = {
alt: string;
image?: string;
card: OfferCard;
};
</script>
<script lang="ts">
import Box from "../compose/Box.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 MediaFrame from "../components/media-frame.svelte";
let { alt, image, card }: OfferMediaProps = $props();
</script>
<Box class="relative" data-slot="hero-media">
<MediaFrame alt={alt} src={image} ratio="4/3" />
<Group
gap="4"
align="start"
class="absolute bottom-4 left-4 mr-4 max-w-xs rounded bg-card p-4 shadow-lg"
data-slot="offer-card"
>
<Box class="flex size-10 shrink-0 items-center justify-center rounded bg-muted">
<LucideIcon name={card.icon} size={20} />
</Box>
<Stack gap="0">
<Text size="sm" weight="semibold">
{card.title}
</Text>
<Text size="xs" class="text-muted-foreground">
{card.text}
</Text>
</Stack>
</Group>
</Box>
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 offer-media// 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 picture of the StoreHero overlay layout with an offer card floating on its lower corner (the card floats
* over the picture).
*/
import { type ReactNode } from "react";
import { Box, Group, Stack, Text } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { MediaFrame } from "../components/media-frame";
import type { OfferCard } from "../blocks/store-hero.types";
export type OfferMediaProps = {
alt: string;
image?: string;
card: OfferCard;
};
export function OfferMedia({ alt, image, card }: OfferMediaProps) {
return (
<Box className="relative" data-slot="hero-media">
<MediaFrame alt={alt} src={image} ratio="4/3" />
<Group
gap="4"
align="start"
className="absolute bottom-4 left-4 mr-4 max-w-xs rounded bg-card p-4 shadow-lg"
data-slot="offer-card"
>
<Box className="flex size-10 shrink-0 items-center justify-center rounded bg-muted">
<LucideIcon name={card.icon} size={20} />
</Box>
<Stack gap="0">
<Text size="sm" weight="semibold">
{card.title}
</Text>
<Text size="xs" className="text-muted-foreground">
{card.text}
</Text>
</Stack>
</Group>
</Box>
);
}
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 offer-media<!-- 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 picture of the StoreHero overlay layout with an offer card floating on its lower corner (the card floats
over the picture).
-->
<script lang="ts">
import type { OfferCard } from "../blocks/store-hero.types";
export type OfferMediaProps = {
alt: string;
image?: string;
card: OfferCard;
};
</script>
<script setup lang="ts">
import Box from "../compose/Box.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 MediaFrame from "../components/media-frame.vue";
const { alt, image, card } = defineProps<OfferMediaProps>();
</script>
<template>
<Box class="relative" data-slot="hero-media">
<MediaFrame :alt="alt" :src="image" ratio="4/3" />
<Group
gap="4"
align="start"
class="absolute bottom-4 left-4 mr-4 max-w-xs rounded bg-card p-4 shadow-lg"
data-slot="offer-card"
>
<Box class="flex size-10 shrink-0 items-center justify-center rounded bg-muted">
<LucideIcon :name="card.icon" :size="20" />
</Box>
<Stack gap="0">
<Text size="sm" weight="semibold">
{{ card.title }}
</Text>
<Text size="xs" class="text-muted-foreground">
{{ card.text }}
</Text>
</Stack>
</Group>
</Box>
</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 offer-media// 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 picture of the StoreHero overlay layout with an offer card floating on its lower corner (the card floats
* over the picture).
*/
import { type JSX } from "solid-js";
import { Box, Group, Stack, Text } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";
import { MediaFrame } from "../components/media-frame";
import type { OfferCard } from "../blocks/store-hero.types";
export type OfferMediaProps = {
alt: string;
image?: string;
card: OfferCard;
};
export function OfferMedia({ alt, image, card }: OfferMediaProps) {
return (
<Box class="relative" data-slot="hero-media">
<MediaFrame alt={alt} src={image} ratio="4/3" />
<Group
gap="4"
align="start"
class="absolute bottom-4 left-4 mr-4 max-w-xs rounded bg-card p-4 shadow-lg"
data-slot="offer-card"
>
<Box class="flex size-10 shrink-0 items-center justify-center rounded bg-muted">
<LucideIcon name={card.icon} size={20} />
</Box>
<Stack gap="0">
<Text size="sm" weight="semibold">
{card.title}
</Text>
<Text size="xs" class="text-muted-foreground">
{card.text}
</Text>
</Stack>
</Group>
</Box>
);
}
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 offer-media// 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/offer-media.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"
)
// OfferMediaProps are the props of OfferMedia; the values are the JSON shapes of the TypeScript props.
type OfferMediaProps struct {
Alt any `json:"alt"`
Image any `json:"image"`
Card any `json:"card"`
}
// The picture of the StoreHero overlay layout with an offer card floating on its lower corner (the card floats over the picture).
templ OfferMedia(p OfferMediaProps) {
{{ vAlt := p.Alt }}
{{ vImage := p.Image }}
{{ vCard := p.Card }}
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "relative", Attrs: uiutils.Attrs("data-slot", "hero-media")}}) {
@MediaFrame(MediaFrameProps{Alt: vAlt, Src: vImage, Ratio: "4/3"})
@compose.Group(compose.GroupProps{Gap: "4", Align: "start", BoxProps: box.BoxProps{Class: "absolute bottom-4 left-4 mr-4 max-w-xs rounded bg-card p-4 shadow-lg", Attrs: uiutils.Attrs("data-slot", "offer-card")}}) {
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "flex size-10 shrink-0 items-center justify-center rounded bg-muted"}}) {
@icons.LucideIcon(icons.LucideIconProps{Name: uiutils.S(uiutils.Get(vCard, "icon")), Size: 20})
}
@compose.Stack(compose.StackProps{Gap: "0", BoxProps: box.BoxProps{}}) {
@compose.Text(compose.TextProps{Size: "sm", Weight: "semibold", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vCard, "title")) }
}
@compose.Text(compose.TextProps{Size: "xs", TextProps: text.TextProps{Class: "text-muted-foreground"}}) {
{ uiutils.Text(uiutils.Get(vCard, "text")) }
}
}
}
}
}
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 offer-media{#- 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/offer-media.json
The picture of the StoreHero overlay layout with an offer card floating on its lower corner (the card floats over the picture).
Props (p): alt, image, card. -#}
{%- set v_alt = (p.alt ?? null) -%}
{%- set v_image = (p.image ?? null) -%}
{%- set v_card = (p.card ?? null) -%}
{%- set c_6 -%}
{{ include('blocks/media-frame.html.twig', {'p': {'alt': v_alt, 'src': v_image, 'ratio': '4/3'}}, with_context = false) }}
{%- set c_5 -%}
{%- set c_1 -%}
{{ include('icons/LucideIcon.html.twig', {'name': og_s(og_get(v_card, ['icon'])), 'size': 20}, with_context = false) }}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': 'flex size-10 shrink-0 items-center justify-center rounded bg-muted', 'children': c_1}, with_context = false) }}
{%- set c_4 -%}
{%- set c_2 -%}
{{ og_text(og_get(v_card, ['title'])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'sm', 'weight': 'semibold', 'children': c_2}, with_context = false) }}
{%- set c_3 -%}
{{ og_text(og_get(v_card, ['text'])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'xs', 'class': 'text-muted-foreground', 'children': c_3}, with_context = false) }}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '0', 'children': c_4}, with_context = false) }}
{%- endset -%}
{{ include('compose/Group.html.twig', {'gap': '4', 'align': 'start', 'class': 'absolute bottom-4 left-4 mr-4 max-w-xs rounded bg-card p-4 shadow-lg', 'attrs': og_attrs(['data-slot', 'offer-card']), 'children': c_5}, with_context = false) }}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': 'relative', 'attrs': og_attrs(['data-slot', 'hero-media']), 'children': c_6}, 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 offer-media{* 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/offer-media.json
The picture of the StoreHero overlay layout with an offer card floating on its lower corner (the card floats over the picture).
Props (p): alt, image, card. *}
{var $v_alt = ($p['alt'] ?? null)}
{var $v_image = ($p['image'] ?? null)}
{var $v_card = ($p['card'] ?? null)}
{capture $c_6}
{=og_include('blocks/media-frame.latte', ['p' => ['alt' => $v_alt, 'src' => $v_image, 'ratio' => '4/3']])|noescape}
{capture $c_5}
{capture $c_1}
{=og_include('icons/LucideIcon.latte', ['name' => og_s(og_get($v_card, ['icon'])), 'size' => 20])|noescape}
{/capture}
{=og_include('compose/Box.latte', ['class' => 'flex size-10 shrink-0 items-center justify-center rounded bg-muted', 'children' => (string) $c_1])|noescape}
{capture $c_4}
{capture $c_2}
{=og_text(og_get($v_card, ['title']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'sm', 'weight' => 'semibold', 'children' => (string) $c_2])|noescape}
{capture $c_3}
{=og_text(og_get($v_card, ['text']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'xs', 'class' => 'text-muted-foreground', 'children' => (string) $c_3])|noescape}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '0', 'children' => (string) $c_4])|noescape}
{/capture}
{=og_include('compose/Group.latte', ['gap' => '4', 'align' => 'start', 'class' => 'absolute bottom-4 left-4 mr-4 max-w-xs rounded bg-card p-4 shadow-lg', 'attrs' => og_attrs(['data-slot', 'offer-card']), 'children' => (string) $c_5])|noescape}
{/capture}
{=og_include('compose/Box.latte', ['class' => 'relative', 'attrs' => og_attrs(['data-slot', 'hero-media']), 'children' => (string) $c_6])|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 offer-media{#- 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/offer-media.json
The picture of the StoreHero overlay layout with an offer card floating on its lower corner (the card floats over the picture).
Props (p): alt, image, card. -#}
{%- set v_alt = og_def(p['alt'], none) -%}
{%- set v_image = og_def(p['image'], none) -%}
{%- set v_card = og_def(p['card'], none) -%}
{%- set c_6 -%}
{{ og_include('blocks/media-frame.html.j2', {'p': {'alt': v_alt, 'src': v_image, 'ratio': '4/3'}}) }}
{%- set c_5 -%}
{%- set c_1 -%}
{{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': og_s(og_get(v_card, ['icon'])), 'Size': 20}}) }}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'flex size-10 shrink-0 items-center justify-center rounded bg-muted'}, 'children': c_1}) }}
{%- set c_4 -%}
{%- set c_2 -%}
{{ og_text(og_get(v_card, ['title'])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'sm', 'Weight': 'semibold'}, 'children': c_2}) }}
{%- set c_3 -%}
{{ og_text(og_get(v_card, ['text'])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'xs', 'Class': 'text-muted-foreground'}, 'children': c_3}) }}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '0'}, 'children': c_4}) }}
{%- endset -%}
{{ og_include('compose/group.html.j2', {'p': {'Gap': '4', 'Align': 'start', 'Class': 'absolute bottom-4 left-4 mr-4 max-w-xs rounded bg-card p-4 shadow-lg', 'Attrs': og_attrs(['data-slot', 'offer-card'])}, 'children': c_5}) }}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'relative', 'Attrs': og_attrs(['data-slot', 'hero-media'])}, 'children': c_6}) }}
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 picture of the StoreHero overlay layout with an offer card floating on its lower corner (the card floats over the picture).
| Prop | Type | Default | Description |
|---|---|---|---|
| alt (required) | string | - | accessible name of the picture |
| image | string | - | address of the picture; none: the placeholder |
| card (required) | OfferCard | - |