Over Media
Over Media component
Install
npx ui8kit add over-mediaPulls in: box, compose, kit-box, media-frame, utils
Preview
Code
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework svelte --dir src --registry-url https://registry.buildy.tw/svelte --strict-cdnnpx ui8kit add over-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. -->
<!--
A faded picture behind the content of its header (a transparent top bar over a hero image); on false: nothing.
It sits inside the header Block, which is `relative isolate overflow-hidden` and transparent when on, so the
header stays the root of the block (rule 01).
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
export type OverMediaProps = {
on?: boolean;
alt: string;
};
</script>
<script lang="ts">
import Box from "../compose/Box.svelte";
import MediaFrame from "../components/media-frame.svelte";
let { on = false, alt }: OverMediaProps = $props();
</script>
{#if on}
<Box class="pointer-events-none absolute inset-0 -z-10" data-slot="over">
<MediaFrame alt={alt} ratio="21/9" class="size-full rounded-none opacity-40" />
</Box>
{/if}
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 over-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.
/**
* A faded picture behind the content of its header (a transparent top bar over a hero image); on false: nothing.
* It sits inside the header Block, which is `relative isolate overflow-hidden` and transparent when on, so the
* header stays the root of the block (rule 01).
*/
import { type ReactNode } from "react";
import { Box } from "../compose";
import { MediaFrame } from "../components/media-frame";
export type OverMediaProps = {
on?: boolean;
alt: string;
};
export function OverMedia({ on = false, alt }: OverMediaProps) {
return (
<>
{on ? (
<Box className="pointer-events-none absolute inset-0 -z-10" data-slot="over">
<MediaFrame alt={alt} ratio="21/9" className="size-full rounded-none opacity-40" />
</Box>
) : null}
</>
);
}
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 over-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. -->
<!--
A faded picture behind the content of its header (a transparent top bar over a hero image); on false: nothing.
It sits inside the header Block, which is `relative isolate overflow-hidden` and transparent when on, so the
header stays the root of the block (rule 01).
-->
<script lang="ts">
export type OverMediaProps = {
on?: boolean;
alt: string;
};
</script>
<script setup lang="ts">
import Box from "../compose/Box.vue";
import MediaFrame from "../components/media-frame.vue";
const { on = false, alt } = defineProps<OverMediaProps>();
</script>
<template>
<Box v-if="on" class="pointer-events-none absolute inset-0 -z-10" data-slot="over">
<MediaFrame :alt="alt" ratio="21/9" class="size-full rounded-none opacity-40" />
</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 over-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.
/**
* A faded picture behind the content of its header (a transparent top bar over a hero image); on false: nothing.
* It sits inside the header Block, which is `relative isolate overflow-hidden` and transparent when on, so the
* header stays the root of the block (rule 01).
*/
import { type JSX } from "solid-js";
import { Box } from "../compose";
import { MediaFrame } from "../components/media-frame";
export type OverMediaProps = {
on?: boolean;
alt: string;
};
export function OverMedia({ on = false, alt }: OverMediaProps) {
return (
<>
{on ? (
<Box class="pointer-events-none absolute inset-0 -z-10" data-slot="over">
<MediaFrame alt={alt} ratio="21/9" class="size-full rounded-none opacity-40" />
</Box>
) : null}
</>
);
}
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 over-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/over-media.json
package blocks
import (
"github.com/ui8kit/codegen/generated/templ/ui/box"
"github.com/ui8kit/codegen/generated/templ/compose"
uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)
// OverMediaProps are the props of OverMedia; the values are the JSON shapes of the TypeScript props.
type OverMediaProps struct {
On any `json:"on"`
Alt any `json:"alt"`
}
// A faded picture behind the content of its header (a transparent top bar over a hero image); on false: nothing. It sits inside the header Block, which is `relative isolate overflow-hidden` and transparent when on, so the header stays the root of the block (rule 01).
templ OverMedia(p OverMediaProps) {
{{ vOn := uiutils.Def(p.On, false) }}
{{ vAlt := p.Alt }}
if uiutils.T(vOn) {
@compose.Box(compose.BoxProps{BoxProps: box.BoxProps{Class: "pointer-events-none absolute inset-0 -z-10", Attrs: uiutils.Attrs("data-slot", "over")}}) {
@MediaFrame(MediaFrameProps{Alt: vAlt, Ratio: "21/9", Class: uiutils.Cnv("size-full rounded-none opacity-40")})
}
}
}
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 over-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/over-media.json
A faded picture behind the content of its header (a transparent top bar over a hero image); on false: nothing. It sits inside the header Block, which is `relative isolate overflow-hidden` and transparent when on, so the header stays the root of the block (rule 01).
Props (p): on, alt. -#}
{%- set v_on = (p.on ?? false) -%}
{%- set v_alt = (p.alt ?? null) -%}
{%- if og_t(v_on) %}
{%- set c_1 -%}
{{ include('blocks/media-frame.html.twig', {'p': {'alt': v_alt, 'ratio': '21/9', 'className': og_cnv(['size-full rounded-none opacity-40'])}}, with_context = false) }}
{%- endset -%}
{{ include('compose/Box.html.twig', {'class': 'pointer-events-none absolute inset-0 -z-10', 'attrs': og_attrs(['data-slot', 'over']), 'children': c_1}, with_context = false) }}
{%- endif %}
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 over-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/over-media.json
A faded picture behind the content of its header (a transparent top bar over a hero image); on false: nothing. It sits inside the header Block, which is `relative isolate overflow-hidden` and transparent when on, so the header stays the root of the block (rule 01).
Props (p): on, alt. *}
{var $v_on = ($p['on'] ?? false)}
{var $v_alt = ($p['alt'] ?? null)}
{if og_t($v_on)}
{capture $c_1}
{=og_include('blocks/media-frame.latte', ['p' => ['alt' => $v_alt, 'ratio' => '21/9', 'className' => og_cnv(['size-full rounded-none opacity-40'])]])|noescape}
{/capture}
{=og_include('compose/Box.latte', ['class' => 'pointer-events-none absolute inset-0 -z-10', 'attrs' => og_attrs(['data-slot', 'over']), 'children' => (string) $c_1])|noescape}
{/if}
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 over-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/over-media.json
A faded picture behind the content of its header (a transparent top bar over a hero image); on false: nothing. It sits inside the header Block, which is `relative isolate overflow-hidden` and transparent when on, so the header stays the root of the block (rule 01).
Props (p): on, alt. -#}
{%- set v_on = og_def(p['on'], false) -%}
{%- set v_alt = og_def(p['alt'], none) -%}
{%- if og_t(v_on) %}
{%- set c_1 -%}
{{ og_include('blocks/media-frame.html.j2', {'p': {'alt': v_alt, 'ratio': '21/9', 'className': og_cnv(['size-full rounded-none opacity-40'])}}) }}
{%- endset -%}
{{ og_include('compose/box.html.j2', {'p': {'Class': 'pointer-events-none absolute inset-0 -z-10', 'Attrs': og_attrs(['data-slot', 'over'])}, 'children': c_1}) }}
{%- endif %}
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.
A faded picture behind the content of its header (a transparent top bar over a hero image); on false: nothing. It sits inside the header Block, which is `relative isolate overflow-hidden` and transparent when on, so the header stays the root of the block (rule 01).
| Prop | Type | Default | Description |
|---|---|---|---|
| on | boolean | false | |
| alt (required) | string | - | accessible name of the picture |