Article Block
Article Block component
Install
npx ui8kit add article-blockPulls in: block, compose, kit-box, utils
Preview
How do I start a new site?
Pick a template, change the texts in one dictionary and publish. Most sites are live in an hour.
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 article-block<!-- 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 self-contained item (a review, a card, a project) in its own file: Block tag article. -->
<script lang="ts" module>
import type { Snippet } from "svelte";
export type ArticleBlockProps = {
testid?: string;
class?: string;
children?: Snippet;
};
</script>
<script lang="ts">
import Block from "../compose/Block.svelte";
import { cn } from "../utils";
let { testid, class: className, children }: ArticleBlockProps = $props();
</script>
<Block tag="article" class={cn(className)} data-slot={(testid ?? "article-block")}>
{@render children?.()}
</Block>
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 article-block// 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 self-contained item (a review, a card, a project) in its own file: Block tag article. */
import { type ReactNode } from "react";
import { Block } from "../compose";
import { cn } from "../utils";
export type ArticleBlockProps = {
testid?: string;
className?: string;
children?: ReactNode;
};
export function ArticleBlock({ testid, className, children }: ArticleBlockProps) {
return (
<Block tag="article" className={cn(className)} data-slot={(testid ?? "article-block")}>
{children}
</Block>
);
}
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 article-block<!-- 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 self-contained item (a review, a card, a project) in its own file: Block tag article. -->
<script lang="ts">
export type ArticleBlockProps = {
testid?: string;
class?: string;
};
</script>
<script setup lang="ts">
import Block from "../compose/Block.vue";
import { cn } from "../utils";
const { testid, class: className } = defineProps<ArticleBlockProps>();
defineSlots<{ default?(): unknown }>();
</script>
<template>
<Block tag="article" :class="cn(className)" :data-slot="(testid ?? 'article-block')">
<slot />
</Block>
</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 article-block// 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 self-contained item (a review, a card, a project) in its own file: Block tag article. */
import { type JSX } from "solid-js";
import { Block } from "../compose";
import { cn } from "../utils";
export type ArticleBlockProps = {
testid?: string;
class?: string;
children?: JSX.Element;
};
export function ArticleBlock({ testid, class: className, children }: ArticleBlockProps) {
return (
<Block tag="article" class={cn(className)} data-slot={(testid ?? "article-block")}>
{children}
</Block>
);
}
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 article-block// 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/article-block.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"
)
// ArticleBlockProps are the props of ArticleBlock; the values are the JSON shapes of the TypeScript props.
type ArticleBlockProps struct {
Testid any `json:"testid"`
Class string `json:"className"`
}
// A self-contained item (a review, a card, a project) in its own file: Block tag article.
templ ArticleBlock(p ArticleBlockProps) {
{{ vTestid := p.Testid }}
@compose.Block(compose.BlockProps{BoxProps: box.BoxProps{Tag: "article", Class: uiutils.S(uiutils.Cnv(p.Class)), Attrs: uiutils.Attrs("data-slot", uiutils.Coalesce(vTestid, "article-block"))}}) {
{ children... }
}
}
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 article-block{#- 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/article-block.json
A self-contained item (a review, a card, a project) in its own file: Block tag article.
Props (p): testid, className; children: markup. -#}
{%- set v_testid = (p.testid ?? null) -%}
{%- set c_1 -%}
{{ og_slot((children ?? null))|raw }}
{%- endset -%}
{{ include('compose/Block.html.twig', {'tag': 'article', 'class': og_s(og_cnv([(p.className ?? '')])), 'attrs': og_attrs(['data-slot', og_coalesce([v_testid, 'article-block'])]), 'children': c_1}, 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 article-block{* 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/article-block.json
A self-contained item (a review, a card, a project) in its own file: Block tag article.
Props (p): testid, className; children: markup. *}
{var $v_testid = ($p['testid'] ?? null)}
{capture $c_1}
{=og_slot(($children ?? null))|noescape}
{/capture}
{=og_include('compose/Block.latte', ['tag' => 'article', 'class' => og_s(og_cnv([($p['className'] ?? '')])), 'attrs' => og_attrs(['data-slot', og_coalesce([$v_testid, 'article-block'])]), 'children' => (string) $c_1])|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 article-block{#- 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/article-block.json
A self-contained item (a review, a card, a project) in its own file: Block tag article.
Props (p): testid, className; children: markup. -#}
{%- set v_testid = og_def(p['testid'], none) -%}
{%- set c_1 -%}
{{ og_slot(og_def(children, none))|safe }}
{%- endset -%}
{{ og_include('compose/block.html.j2', {'p': {'Tag': 'article', 'Class': og_s(og_cnv([og_def(p['className'], '')])), 'Attrs': og_attrs(['data-slot', og_coalesce([v_testid, 'article-block'])])}, 'children': c_1}) }}
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 self-contained item (a review, a card, a project) in its own file: Block tag article.
| Prop | Type | Default | Description |
|---|---|---|---|
| testid | string | - | data-slot of the root (default: the component name) |