Skip to content
ui8kit

component / components

Compare Mark

Compare Mark component

Install

npx ui8kit add compare-mark

Pulls in: compose, inline, kit-text, lucide-icon, utils

Preview

Not included

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 compare-mark
components/compare-mark.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. -->
<!--
  One cell value of ComparisonTable: yes shows a check, no a dash (both with the hidden word for screen
  readers), any other value is shown as text.
-->
<script lang="ts" module>
  import type { Snippet } from "svelte";

  export type CompareMarkProps = {
    value: string;
    yes: string;
    no: string;
  };
</script>

<script lang="ts">
  import Inline from "../compose/Inline.svelte";
  import LucideIcon from "../icons/LucideIcon.svelte";

  let { value, yes, no }: CompareMarkProps = $props();
</script>

{#if ((value as string) === "yes")}
  <Inline class="inline-flex items-center gap-2" data-mark="yes" data-slot="compare-mark">
    <LucideIcon name="check" size={16} class="text-foreground" />
    <Inline class="sr-only">
      {yes}
    </Inline>
  </Inline>
{/if}
{#if ((value as string) === "no")}
  <Inline class="inline-flex items-center gap-2 text-muted-foreground" data-mark="no" data-slot="compare-mark">
    <LucideIcon name="minus" size={16} />
    <Inline class="sr-only">
      {no}
    </Inline>
  </Inline>
{/if}
{#if (((value as string) !== "yes") && ((value as string) !== "no"))}
  <Inline data-slot="compare-mark">
    {value}
  </Inline>
{/if}

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 compare-mark
components/compare-mark.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.
/**
 * One cell value of ComparisonTable: yes shows a check, no a dash (both with the hidden word for screen
 * readers), any other value is shown as text.
 */
import { type ReactNode } from "react";
import { Inline } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";

export type CompareMarkProps = {
  value: string;
  yes: string;
  no: string;
};

export function CompareMark({ value, yes, no }: CompareMarkProps) {
  return (
    <>
      {((value as string) === "yes") ? (
        <Inline className="inline-flex items-center gap-2" data-mark="yes" data-slot="compare-mark">
          <LucideIcon name="check" size={16} className="text-foreground" />
          <Inline className="sr-only">
            {yes}
          </Inline>
        </Inline>
      ) : null}
      {((value as string) === "no") ? (
        <Inline
          className="inline-flex items-center gap-2 text-muted-foreground"
          data-mark="no"
          data-slot="compare-mark"
        >
          <LucideIcon name="minus" size={16} />
          <Inline className="sr-only">
            {no}
          </Inline>
        </Inline>
      ) : null}
      {(((value as string) !== "yes") && ((value as string) !== "no")) ? (
        <Inline data-slot="compare-mark">
          {value}
        </Inline>
      ) : null}
    </>
  );
}

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 compare-mark
components/compare-mark.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. -->
<!--
  One cell value of ComparisonTable: yes shows a check, no a dash (both with the hidden word for screen
  readers), any other value is shown as text.
-->
<script lang="ts">
export type CompareMarkProps = {
  value: string;
  yes: string;
  no: string;
};
</script>

<script setup lang="ts">
import Inline from "../compose/Inline.vue";
import LucideIcon from "../icons/LucideIcon.vue";

const { value, yes, no } = defineProps<CompareMarkProps>();
</script>

<template>
  <Inline
    v-if="((value as string) === 'yes')"
    class="inline-flex items-center gap-2"
    data-mark="yes"
    data-slot="compare-mark"
  >
    <LucideIcon name="check" :size="16" class="text-foreground" />
    <Inline class="sr-only">
      {{ yes }}
    </Inline>
  </Inline>
  <Inline
    v-if="((value as string) === 'no')"
    class="inline-flex items-center gap-2 text-muted-foreground"
    data-mark="no"
    data-slot="compare-mark"
  >
    <LucideIcon name="minus" :size="16" />
    <Inline class="sr-only">
      {{ no }}
    </Inline>
  </Inline>
  <Inline v-if="(((value as string) !== 'yes') && ((value as string) !== 'no'))" data-slot="compare-mark">
    {{ value }}
  </Inline>
</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 compare-mark
components/compare-mark.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.
/**
 * One cell value of ComparisonTable: yes shows a check, no a dash (both with the hidden word for screen
 * readers), any other value is shown as text.
 */
import { type JSX } from "solid-js";
import { Inline } from "../compose";
import { LucideIcon } from "../icons/LucideIcon";

export type CompareMarkProps = {
  value: string;
  yes: string;
  no: string;
};

export function CompareMark({ value, yes, no }: CompareMarkProps) {
  return (
    <>
      {((value as string) === "yes") ? (
        <Inline class="inline-flex items-center gap-2" data-mark="yes" data-slot="compare-mark">
          <LucideIcon name="check" size={16} class="text-foreground" />
          <Inline class="sr-only">
            {yes}
          </Inline>
        </Inline>
      ) : null}
      {((value as string) === "no") ? (
        <Inline class="inline-flex items-center gap-2 text-muted-foreground" data-mark="no" data-slot="compare-mark">
          <LucideIcon name="minus" size={16} />
          <Inline class="sr-only">
            {no}
          </Inline>
        </Inline>
      ) : null}
      {(((value as string) !== "yes") && ((value as string) !== "no")) ? (
        <Inline data-slot="compare-mark">
          {value}
        </Inline>
      ) : null}
    </>
  );
}

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 compare-mark
blocks/compare-mark.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/compare-mark.json

package blocks

import (
	"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"
)

// CompareMarkProps are the props of CompareMark; the values are the JSON shapes of the TypeScript props.
type CompareMarkProps struct {
	Value any `json:"value"`
	Yes any `json:"yes"`
	No any `json:"no"`
}

// One cell value of ComparisonTable: yes shows a check, no a dash (both with the hidden word for screen readers), any other value is shown as text.
templ CompareMark(p CompareMarkProps) {
	{{ vValue := p.Value }}
	{{ vYes := p.Yes }}
	{{ vNo := p.No }}
	if uiutils.Eq(vValue, "yes") {
		@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "inline-flex items-center gap-2", Attrs: uiutils.Attrs("data-mark", "yes", "data-slot", "compare-mark")}}) {
			@icons.LucideIcon(icons.LucideIconProps{Name: "check", Size: 16, Class: "text-foreground"})
			@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "sr-only"}}) {
				{ uiutils.Text(vYes) }
			}
		}
	}
	if uiutils.Eq(vValue, "no") {
		@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "inline-flex items-center gap-2 text-muted-foreground", Attrs: uiutils.Attrs("data-mark", "no", "data-slot", "compare-mark")}}) {
			@icons.LucideIcon(icons.LucideIconProps{Name: "minus", Size: 16})
			@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Class: "sr-only"}}) {
				{ uiutils.Text(vNo) }
			}
		}
	}
	if uiutils.T(uiutils.And(!uiutils.Eq(vValue, "yes"), !uiutils.Eq(vValue, "no"))) {
		@compose.Inline(compose.InlineProps{TextProps: text.TextProps{Attrs: uiutils.Attrs("data-slot", "compare-mark")}}) {
			{ uiutils.Text(vValue) }
		}
	}
}

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 compare-mark
blocks/compare-mark.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/compare-mark.json
    One cell value of ComparisonTable: yes shows a check, no a dash (both with the hidden word for screen readers), any other value is shown as text.
    Props (p): value, yes, no. -#}
{%- set v_value = (p.value ?? null) -%}
{%- set v_yes = (p.yes ?? null) -%}
{%- set v_no = (p.no ?? null) -%}
{%- if og_t(og_eq(v_value, 'yes')) %}
  {%- set c_2 -%}
    {{ include('icons/LucideIcon.html.twig', {'name': 'check', 'size': 16, 'class': 'text-foreground'}, with_context = false) }}
    {%- set c_1 -%}
      {{ og_text(v_yes) }}
    {%- endset -%}
    {{ include('compose/Inline.html.twig', {'class': 'sr-only', 'children': c_1}, with_context = false) }}
  {%- endset -%}
  {{ include('compose/Inline.html.twig', {'class': 'inline-flex items-center gap-2', 'attrs': og_attrs(['data-mark', 'yes', 'data-slot', 'compare-mark']), 'children': c_2}, with_context = false) }}
{%- endif %}
{%- if og_t(og_eq(v_value, 'no')) %}
  {%- set c_4 -%}
    {{ include('icons/LucideIcon.html.twig', {'name': 'minus', 'size': 16}, with_context = false) }}
    {%- set c_3 -%}
      {{ og_text(v_no) }}
    {%- endset -%}
    {{ include('compose/Inline.html.twig', {'class': 'sr-only', 'children': c_3}, with_context = false) }}
  {%- endset -%}
  {{ include('compose/Inline.html.twig', {'class': 'inline-flex items-center gap-2 text-muted-foreground', 'attrs': og_attrs(['data-mark', 'no', 'data-slot', 'compare-mark']), 'children': c_4}, with_context = false) }}
{%- endif %}
{%- if og_t(og_and([not (og_eq(v_value, 'yes')), not (og_eq(v_value, 'no'))])) %}
  {%- set c_5 -%}
    {{ og_text(v_value) }}
  {%- endset -%}
  {{ include('compose/Inline.html.twig', {'attrs': og_attrs(['data-slot', 'compare-mark']), 'children': c_5}, with_context = false) }}
{%- endif %}

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 compare-mark
blocks/compare-mark.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/compare-mark.json
    One cell value of ComparisonTable: yes shows a check, no a dash (both with the hidden word for screen readers), any other value is shown as text.
    Props (p): value, yes, no. *}
{var $v_value = ($p['value'] ?? null)}
{var $v_yes = ($p['yes'] ?? null)}
{var $v_no = ($p['no'] ?? null)}
{if og_t(og_eq($v_value, 'yes'))}
  {capture $c_2}
    {=og_include('icons/LucideIcon.latte', ['name' => 'check', 'size' => 16, 'class' => 'text-foreground'])|noescape}
    {capture $c_1}
      {=og_text($v_yes)}
    {/capture}
    {=og_include('compose/Inline.latte', ['class' => 'sr-only', 'children' => (string) $c_1])|noescape}
  {/capture}
  {=og_include('compose/Inline.latte', ['class' => 'inline-flex items-center gap-2', 'attrs' => og_attrs(['data-mark', 'yes', 'data-slot', 'compare-mark']), 'children' => (string) $c_2])|noescape}
{/if}
{if og_t(og_eq($v_value, 'no'))}
  {capture $c_4}
    {=og_include('icons/LucideIcon.latte', ['name' => 'minus', 'size' => 16])|noescape}
    {capture $c_3}
      {=og_text($v_no)}
    {/capture}
    {=og_include('compose/Inline.latte', ['class' => 'sr-only', 'children' => (string) $c_3])|noescape}
  {/capture}
  {=og_include('compose/Inline.latte', ['class' => 'inline-flex items-center gap-2 text-muted-foreground', 'attrs' => og_attrs(['data-mark', 'no', 'data-slot', 'compare-mark']), 'children' => (string) $c_4])|noescape}
{/if}
{if og_t(og_and([!(og_eq($v_value, 'yes')), !(og_eq($v_value, 'no'))]))}
  {capture $c_5}
    {=og_text($v_value)}
  {/capture}
  {=og_include('compose/Inline.latte', ['attrs' => og_attrs(['data-slot', 'compare-mark']), 'children' => (string) $c_5])|noescape}
{/if}

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 compare-mark
blocks/compare-mark.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/compare-mark.json
    One cell value of ComparisonTable: yes shows a check, no a dash (both with the hidden word for screen readers), any other value is shown as text.
    Props (p): value, yes, no. -#}
{%- set v_value = og_def(p['value'], none) -%}
{%- set v_yes = og_def(p['yes'], none) -%}
{%- set v_no = og_def(p['no'], none) -%}
{%- if og_t(og_eq(v_value, 'yes')) %}
  {%- set c_2 -%}
    {{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'check', 'Size': 16, 'Class': 'text-foreground'}}) }}
    {%- set c_1 -%}
      {{ og_text(v_yes) }}
    {%- endset -%}
    {{ og_include('compose/inline.html.j2', {'p': {'Class': 'sr-only'}, 'children': c_1}) }}
  {%- endset -%}
  {{ og_include('compose/inline.html.j2', {'p': {'Class': 'inline-flex items-center gap-2', 'Attrs': og_attrs(['data-mark', 'yes', 'data-slot', 'compare-mark'])}, 'children': c_2}) }}
{%- endif %}
{%- if og_t(og_eq(v_value, 'no')) %}
  {%- set c_4 -%}
    {{ og_include('icons/lucide-icon.html.j2', {'p': {'Name': 'minus', 'Size': 16}}) }}
    {%- set c_3 -%}
      {{ og_text(v_no) }}
    {%- endset -%}
    {{ og_include('compose/inline.html.j2', {'p': {'Class': 'sr-only'}, 'children': c_3}) }}
  {%- endset -%}
  {{ og_include('compose/inline.html.j2', {'p': {'Class': 'inline-flex items-center gap-2 text-muted-foreground', 'Attrs': og_attrs(['data-mark', 'no', 'data-slot', 'compare-mark'])}, 'children': c_4}) }}
{%- endif %}
{%- if og_t(og_and([not (og_eq(v_value, 'yes')), not (og_eq(v_value, 'no'))])) %}
  {%- set c_5 -%}
    {{ og_text(v_value) }}
  {%- endset -%}
  {{ og_include('compose/inline.html.j2', {'p': {'Attrs': og_attrs(['data-slot', 'compare-mark'])}, 'children': c_5}) }}
{%- endif %}

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.

One cell value of ComparisonTable: yes shows a check, no a dash (both with the hidden word for screen readers), any other value is shown as text.

Props of CompareMark
PropTypeDefault Description
value (required)string-yes, no or a short text
yes (required)string-the hidden word for yes
no (required)string-the hidden word for no

Used in