Faq Finder
Faq Finder component
Install
npx ui8kit add faq-finderPulls in: button, compose, faq-list, faq-split, group, kit-box, kit-button, kit-text, list, list-item, menu-entry, search-field, stack, text, utils
Preview
Popular questions
- How do I start a new site?
- Can I use my own domain?
- When am I billed?
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 faq-finder<!-- 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 finder of FaqSplit: a search field, the topics as a row of buttons, and the first three questions as
popular links.
-->
<script lang="ts" module>
import type { Snippet } from "svelte";
import type { Question, FaqSplitLabels } from "../blocks/faq-split.types";
import type { FaqTab } from "../blocks/faq-list.types";
export type FaqFinderProps = {
items: Question[];
labels: FaqSplitLabels;
topics: FaqTab[];
};
</script>
<script lang="ts">
import Button from "../compose/Button.svelte";
import Group from "../compose/Group.svelte";
import List from "../compose/List.svelte";
import ListItem from "../compose/ListItem.svelte";
import Stack from "../compose/Stack.svelte";
import Text from "../compose/Text.svelte";
import MenuEntry from "../components/menu-entry.svelte";
import SearchField from "../components/search-field.svelte";
let { items, labels, topics }: FaqFinderProps = $props();
</script>
<Stack gap="6" align="stretch" data-slot="faq-finder">
<SearchField label={labels.search} placeholder={labels.search} value={(labels.query ?? "")} />
<Group gap="2" class="flex-wrap">
{#each topics as t (t.id)}
<Button variant="outline" size="sm" data-value={t.value}>
{t.title}
</Button>
{/each}
</Group>
<Stack gap="2">
<Text size="sm" weight="semibold">
{labels.popular}
</Text>
<List class="m-0 flex list-none flex-col gap-2 p-0">
{#each items as q, i (q.id)}
{#if (i < 3)}
<ListItem data-slot="faq-popular">
<MenuEntry href={q.href} class="text-sm font-medium" size="sm">
{q.question}
</MenuEntry>
</ListItem>
{/if}
{/each}
</List>
</Stack>
</Stack>
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 faq-finder// 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 finder of FaqSplit: a search field, the topics as a row of buttons, and the first three questions as
* popular links.
*/
import { Fragment, type ReactNode } from "react";
import { Button, Group, List, ListItem, Stack, Text } from "../compose";
import { MenuEntry } from "../components/menu-entry";
import { SearchField } from "../components/search-field";
import type { Question, FaqSplitLabels } from "../blocks/faq-split.types";
import type { FaqTab } from "../blocks/faq-list.types";
export type FaqFinderProps = {
items: Question[];
labels: FaqSplitLabels;
topics: FaqTab[];
};
export function FaqFinder({ items, labels, topics }: FaqFinderProps) {
return (
<Stack gap="6" align="stretch" data-slot="faq-finder">
<SearchField label={labels.search} placeholder={labels.search} value={(labels.query ?? "")} />
<Group gap="2" className="flex-wrap">
{(topics ?? []).map((t) => (
<Button key={t.id} variant="outline" size="sm" data-value={t.value}>
{t.title}
</Button>
))}
</Group>
<Stack gap="2">
<Text size="sm" weight="semibold">
{labels.popular}
</Text>
<List className="m-0 flex list-none flex-col gap-2 p-0">
{(items ?? []).map((q, i) => (
<Fragment key={q.id}>
{(i < 3) ? (
<ListItem data-slot="faq-popular">
<MenuEntry href={q.href} className="text-sm font-medium" size="sm">
{q.question}
</MenuEntry>
</ListItem>
) : null}
</Fragment>
))}
</List>
</Stack>
</Stack>
);
}
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 faq-finder<!-- 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 finder of FaqSplit: a search field, the topics as a row of buttons, and the first three questions as
popular links.
-->
<script lang="ts">
import type { Question, FaqSplitLabels } from "../blocks/faq-split.types";
import type { FaqTab } from "../blocks/faq-list.types";
export type FaqFinderProps = {
items: Question[];
labels: FaqSplitLabels;
topics: FaqTab[];
};
</script>
<script setup lang="ts">
import Button from "../compose/Button.vue";
import Group from "../compose/Group.vue";
import List from "../compose/List.vue";
import ListItem from "../compose/ListItem.vue";
import Stack from "../compose/Stack.vue";
import Text from "../compose/Text.vue";
import MenuEntry from "../components/menu-entry.vue";
import SearchField from "../components/search-field.vue";
const { items, labels, topics } = defineProps<FaqFinderProps>();
</script>
<template>
<Stack gap="6" align="stretch" data-slot="faq-finder">
<SearchField :label="labels.search" :placeholder="labels.search" :value="(labels.query ?? '')" />
<Group gap="2" class="flex-wrap">
<Button v-for="t in topics" :key="t.id" variant="outline" size="sm" :data-value="t.value">
{{ t.title }}
</Button>
</Group>
<Stack gap="2">
<Text size="sm" weight="semibold">
{{ labels.popular }}
</Text>
<List class="m-0 flex list-none flex-col gap-2 p-0">
<template v-for="(q, i) in items" :key="q.id">
<ListItem v-if="(i < 3)" data-slot="faq-popular">
<MenuEntry :href="q.href" class="text-sm font-medium" size="sm">
{{ q.question }}
</MenuEntry>
</ListItem>
</template>
</List>
</Stack>
</Stack>
</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 faq-finder// 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 finder of FaqSplit: a search field, the topics as a row of buttons, and the first three questions as
* popular links.
*/
import { For, type JSX } from "solid-js";
import { Button, Group, List, ListItem, Stack, Text } from "../compose";
import { MenuEntry } from "../components/menu-entry";
import { SearchField } from "../components/search-field";
import type { Question, FaqSplitLabels } from "../blocks/faq-split.types";
import type { FaqTab } from "../blocks/faq-list.types";
export type FaqFinderProps = {
items: Question[];
labels: FaqSplitLabels;
topics: FaqTab[];
};
export function FaqFinder({ items, labels, topics }: FaqFinderProps) {
return (
<Stack gap="6" align="stretch" data-slot="faq-finder">
<SearchField label={labels.search} placeholder={labels.search} value={(labels.query ?? "")} />
<Group gap="2" class="flex-wrap">
<For each={topics ?? []}>{(t) => (
<Button variant="outline" size="sm" data-value={t.value}>
{t.title}
</Button>
)}</For>
</Group>
<Stack gap="2">
<Text size="sm" weight="semibold">
{labels.popular}
</Text>
<List class="m-0 flex list-none flex-col gap-2 p-0">
<For each={items ?? []}>{(q, iOf) => { const i = iOf(); return (
<>
{(i < 3) ? (
<ListItem data-slot="faq-popular">
<MenuEntry href={q.href} class="text-sm font-medium" size="sm">
{q.question}
</MenuEntry>
</ListItem>
) : null}
</>
); }}</For>
</List>
</Stack>
</Stack>
);
}
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 faq-finder// 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/faq-finder.json
package blocks
import (
"github.com/ui8kit/codegen/generated/templ/ui/box"
"github.com/ui8kit/codegen/generated/templ/ui/button"
"github.com/ui8kit/codegen/generated/templ/compose"
"github.com/ui8kit/codegen/generated/templ/ui/text"
uiutils "github.com/ui8kit/codegen/generated/templ/orgutils"
)
// FaqFinderProps are the props of FaqFinder; the values are the JSON shapes of the TypeScript props.
type FaqFinderProps struct {
Items any `json:"items"`
Labels any `json:"labels"`
Topics any `json:"topics"`
}
// The finder of FaqSplit: a search field, the topics as a row of buttons, and the first three questions as popular links.
templ FaqFinder(p FaqFinderProps) {
{{ vItems := p.Items }}
{{ vLabels := p.Labels }}
{{ vTopics := p.Topics }}
@compose.Stack(compose.StackProps{Gap: "6", Align: "stretch", BoxProps: box.BoxProps{Attrs: uiutils.Attrs("data-slot", "faq-finder")}}) {
@SearchField(SearchFieldProps{Label: uiutils.Get(vLabels, "search"), Placeholder: uiutils.Get(vLabels, "search"), Value: uiutils.Coalesce(uiutils.Get(vLabels, "query"), "")})
@compose.Group(compose.GroupProps{Gap: "2", BoxProps: box.BoxProps{Class: "flex-wrap"}}) {
for _, vT := range uiutils.L(vTopics) {
@compose.Button(compose.ButtonProps{Variant: "outline", Size: "sm", ButtonProps: button.ButtonProps{Attrs: uiutils.Attrs("data-value", uiutils.Get(vT, "value"))}}) {
{ uiutils.Text(uiutils.Get(vT, "title")) }
}
}
}
@compose.Stack(compose.StackProps{Gap: "2", BoxProps: box.BoxProps{}}) {
@compose.Text(compose.TextProps{Size: "sm", Weight: "semibold", TextProps: text.TextProps{}}) {
{ uiutils.Text(uiutils.Get(vLabels, "popular")) }
}
@compose.List(compose.ListProps{BoxProps: box.BoxProps{Class: "m-0 flex list-none flex-col gap-2 p-0"}}) {
for vI, vQ := range uiutils.L(vItems) {
if uiutils.Lt(float64(vI), float64(3)) {
@compose.ListItem(compose.ListItemProps{BoxProps: box.BoxProps{Attrs: uiutils.Attrs("data-slot", "faq-popular")}}) {
@MenuEntry(MenuEntryProps{Href: uiutils.Get(vQ, "href"), Class: uiutils.Cnv("text-sm font-medium"), Size: "sm"}) {
{ uiutils.Text(uiutils.Get(vQ, "question")) }
}
}
}
}
}
}
}
}
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 faq-finder{#- 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/faq-finder.json
The finder of FaqSplit: a search field, the topics as a row of buttons, and the first three questions as popular links.
Props (p): items, labels, topics. -#}
{%- set v_items = (p.items ?? null) -%}
{%- set v_labels = (p.labels ?? null) -%}
{%- set v_topics = (p.topics ?? null) -%}
{%- set c_8 -%}
{{ include('blocks/search-field.html.twig', {'p': {'label': og_get(v_labels, ['search']), 'placeholder': og_get(v_labels, ['search']), 'value': og_coalesce([og_get(v_labels, ['query']), ''])}}, with_context = false) }}
{%- set c_2 -%}
{%- for v_t in og_l(v_topics) %}
{%- set c_1 -%}
{{ og_text(og_get(v_t, ['title'])) }}
{%- endset -%}
{{ include('compose/Button.html.twig', {'variant': 'outline', 'size': 'sm', 'attrs': og_attrs(['data-value', og_get(v_t, ['value'])]), 'children': c_1}, with_context = false) }}
{%- endfor %}
{%- endset -%}
{{ include('compose/Group.html.twig', {'gap': '2', 'class': 'flex-wrap', 'children': c_2}, with_context = false) }}
{%- set c_7 -%}
{%- set c_3 -%}
{{ og_text(og_get(v_labels, ['popular'])) }}
{%- endset -%}
{{ include('compose/Text.html.twig', {'size': 'sm', 'weight': 'semibold', 'children': c_3}, with_context = false) }}
{%- set c_6 -%}
{%- for v_q in og_l(v_items) %}
{%- set v_i = loop.index0 -%}
{%- if og_t(og_lt(v_i, 3)) %}
{%- set c_5 -%}
{%- set c_4 -%}
{{ og_text(og_get(v_q, ['question'])) }}
{%- endset -%}
{{ include('blocks/menu-entry.html.twig', {'p': {'href': og_get(v_q, ['href']), 'className': og_cnv(['text-sm font-medium']), 'size': 'sm'}, 'children': og_markup(c_4)}, with_context = false) }}
{%- endset -%}
{{ include('compose/ListItem.html.twig', {'attrs': og_attrs(['data-slot', 'faq-popular']), 'children': c_5}, with_context = false) }}
{%- endif %}
{%- endfor %}
{%- endset -%}
{{ include('compose/List.html.twig', {'class': 'm-0 flex list-none flex-col gap-2 p-0', 'children': c_6}, with_context = false) }}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '2', 'children': c_7}, with_context = false) }}
{%- endset -%}
{{ include('compose/Stack.html.twig', {'gap': '6', 'align': 'stretch', 'attrs': og_attrs(['data-slot', 'faq-finder']), 'children': c_8}, 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 faq-finder{* 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/faq-finder.json
The finder of FaqSplit: a search field, the topics as a row of buttons, and the first three questions as popular links.
Props (p): items, labels, topics. *}
{var $v_items = ($p['items'] ?? null)}
{var $v_labels = ($p['labels'] ?? null)}
{var $v_topics = ($p['topics'] ?? null)}
{capture $c_8}
{=og_include('blocks/search-field.latte', ['p' => ['label' => og_get($v_labels, ['search']), 'placeholder' => og_get($v_labels, ['search']), 'value' => og_coalesce([og_get($v_labels, ['query']), ''])]])|noescape}
{capture $c_2}
{foreach og_l($v_topics) as $v_t}
{capture $c_1}
{=og_text(og_get($v_t, ['title']))}
{/capture}
{=og_include('compose/Button.latte', ['variant' => 'outline', 'size' => 'sm', 'attrs' => og_attrs(['data-value', og_get($v_t, ['value'])]), 'children' => (string) $c_1])|noescape}
{/foreach}
{/capture}
{=og_include('compose/Group.latte', ['gap' => '2', 'class' => 'flex-wrap', 'children' => (string) $c_2])|noescape}
{capture $c_7}
{capture $c_3}
{=og_text(og_get($v_labels, ['popular']))}
{/capture}
{=og_include('compose/Text.latte', ['size' => 'sm', 'weight' => 'semibold', 'children' => (string) $c_3])|noescape}
{capture $c_6}
{foreach og_l($v_items) as $v_q}
{var $v_i = $iterator->counter0}
{if og_t(og_lt($v_i, 3))}
{capture $c_5}
{capture $c_4}
{=og_text(og_get($v_q, ['question']))}
{/capture}
{=og_include('blocks/menu-entry.latte', ['p' => ['href' => og_get($v_q, ['href']), 'className' => og_cnv(['text-sm font-medium']), 'size' => 'sm'], 'children' => og_markup($c_4)])|noescape}
{/capture}
{=og_include('compose/ListItem.latte', ['attrs' => og_attrs(['data-slot', 'faq-popular']), 'children' => (string) $c_5])|noescape}
{/if}
{/foreach}
{/capture}
{=og_include('compose/List.latte', ['class' => 'm-0 flex list-none flex-col gap-2 p-0', 'children' => (string) $c_6])|noescape}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '2', 'children' => (string) $c_7])|noescape}
{/capture}
{=og_include('compose/Stack.latte', ['gap' => '6', 'align' => 'stretch', 'attrs' => og_attrs(['data-slot', 'faq-finder']), 'children' => (string) $c_8])|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 faq-finder{#- 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/faq-finder.json
The finder of FaqSplit: a search field, the topics as a row of buttons, and the first three questions as popular links.
Props (p): items, labels, topics. -#}
{%- set v_items = og_def(p['items'], none) -%}
{%- set v_labels = og_def(p['labels'], none) -%}
{%- set v_topics = og_def(p['topics'], none) -%}
{%- set c_8 -%}
{{ og_include('blocks/search-field.html.j2', {'p': {'label': og_get(v_labels, ['search']), 'placeholder': og_get(v_labels, ['search']), 'value': og_coalesce([og_get(v_labels, ['query']), ''])}}) }}
{%- set c_2 -%}
{%- for v_t in og_l(v_topics) %}
{%- set c_1 -%}
{{ og_text(og_get(v_t, ['title'])) }}
{%- endset -%}
{{ og_include('compose/button.html.j2', {'p': {'Variant': 'outline', 'Size': 'sm', 'Attrs': og_attrs(['data-value', og_get(v_t, ['value'])])}, 'children': c_1}) }}
{%- endfor %}
{%- endset -%}
{{ og_include('compose/group.html.j2', {'p': {'Gap': '2', 'Class': 'flex-wrap'}, 'children': c_2}) }}
{%- set c_7 -%}
{%- set c_3 -%}
{{ og_text(og_get(v_labels, ['popular'])) }}
{%- endset -%}
{{ og_include('compose/text.html.j2', {'p': {'Size': 'sm', 'Weight': 'semibold'}, 'children': c_3}) }}
{%- set c_6 -%}
{%- for v_q in og_l(v_items) %}
{%- set v_i = loop.index0 -%}
{%- if og_t(og_lt(v_i, 3)) %}
{%- set c_5 -%}
{%- set c_4 -%}
{{ og_text(og_get(v_q, ['question'])) }}
{%- endset -%}
{{ og_include('blocks/menu-entry.html.j2', {'p': {'href': og_get(v_q, ['href']), 'className': og_cnv(['text-sm font-medium']), 'size': 'sm'}, 'children': og_markup(c_4)}) }}
{%- endset -%}
{{ og_include('compose/list-item.html.j2', {'p': {'Attrs': og_attrs(['data-slot', 'faq-popular'])}, 'children': c_5}) }}
{%- endif %}
{%- endfor %}
{%- endset -%}
{{ og_include('compose/list.html.j2', {'p': {'Class': 'm-0 flex list-none flex-col gap-2 p-0'}, 'children': c_6}) }}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '2'}, 'children': c_7}) }}
{%- endset -%}
{{ og_include('compose/stack.html.j2', {'p': {'Gap': '6', 'Align': 'stretch', 'Attrs': og_attrs(['data-slot', 'faq-finder'])}, 'children': c_8}) }}
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 finder of FaqSplit: a search field, the topics as a row of buttons, and the first three questions as popular links.
| Prop | Type | Default | Description |
|---|---|---|---|
| items (required) | Question[] | - | |
| labels (required) | FaqSplitLabels | - | |
| topics (required) | FaqTab[] | - |