コンテンツにスキップ

spst-gallery-01

実サービスへ通信しない見本です。モデルの描画は静止した代替表示です。

元 commit: d204666f04a0ee7b6f18543f8aec414b4128874e · shadcn build 4.23.1

Noto Sans JP · @fontsource/noto-sans-jp 5.3.1 · OFL-1.1

操作を試す

全画面で開く

取り込む(公開予定)

以下の URL は公開予定です。公開前は取り込めません。既存ファイルとの差分を確認してから実行し、--overwrite を既定にしないでください。

npx shadcn@latest add https://spritestack.dev/r/spst-gallery-01.json

components.json の registries に追加

{"registries":{"@spritestack":"https://spritestack.dev/r/{name}.json"}}
npx shadcn@latest add @spritestack/spst-gallery-01

React 19・Tailwind v4・shadcn の src/ を持つ構成が対象です。src/ の無い構成は未検証です。取り込みはソースのコピーで、自動更新されません。

import "./styles/spritestack/theme.css";

<div className="spst-theme" data-theme="light">
  {/* Render components here. */}
</div>

Portal の container / portalContainer は .spst-theme 内の要素を渡してください。Noto Sans JP の 400・600・700 は利用先が自己ホストしてください。未導入時は system-ui です。

依存

Props / API

以下は実際のソースを構文解析して生成しています。… の行は継承する React / Radix の公開型です。既定欄の — は、この関数の引数で既定を指定していないことを表します。union の必須条件は型宣言も確認してください。

src/components/spritestack/blocks/gallery-01.tsx

Gallery01

Gallery01({ locale = "ja", messages }: SampleProps = {})
Prop型必須既定イベント
…SampleProps———
分割代入の既定値(継承した props も含む)
locale = "ja"
型宣言とソースを確認
"use client";
// 出典: SpriteStack デザインシステム設計 §4.2・§4.4(Issue 313)。基本部品は同梱の shadcn/ui 派生を合成。
import { useState } from "react";
import { Badge } from "../../ui/badge";
import { Button, buttonVariants } from "../../ui/button";
import { Card } from "../../ui/card";
import { Input } from "../../ui/input";
import { CategoryStrip } from "../category-strip";
import { CommandCopy } from "../command-copy";
import { ModelCard } from "../model-card";
import { SiteFooter } from "../site-footer";
import { SiteHeader } from "../site-header";
import { ViewerControls } from "../viewer-controls";
import { ViewerFrame } from "../viewer-frame";
import { getComponentMessages } from "./component-messages";
import { getSampleData } from "./sample-data";
import { getSampleMessages, type SampleProps } from "./sample-messages";
export function Gallery01({ locale = "ja", messages }: SampleProps = {}) {
  const m = getSampleMessages(locale, messages);
  const { demoModels, demoLinks } = getSampleData(locale, messages);
  const c = getComponentMessages(locale);
  const [category, setCategory] = useState("all");
  const [search, setSearch] = useState("");
  const [selected, setSelected] = useState<string>(demoModels[0].id);
  const [mode, setMode] = useState<"2d" | "3d">("3d");
  const [gap, setGap] = useState(0);
  const [rotation, setRotation] = useState("");
  const model = demoModels.find((item) => item.id === selected) ?? demoModels[0];
  const models = demoModels.filter(
    (item) => (category === "all" || item.category === category) && item.title.includes(search),
  );
  return (
    <div data-block="gallery-01" className="min-w-0 bg-background text-foreground">
      <SiteHeader
        locale={locale}
        homeHref="#sample-home"
        links={demoLinks}
        currentPath="#sample-home"
      />
      <div className="grid min-w-0 gap-5 p-4 lg:grid-cols-3">
        <section className="grid min-w-0 content-start gap-4 lg:col-span-2" aria-label={m.gallery}>
          <h1 className="text-xl font-(weight:--spst-font-weight-heading)">
            {m.findModelsForYourGame}
          </h1>
          <Input
            type="search"
            aria-label={m.searchModels}
            placeholder={m.searchModels}
            value={search}
            onChange={(event) => setSearch(event.target.value)}
          />
          <CategoryStrip
            messages={c.CategoryStrip}
            categories={[
              { value: "all", label: m.all },
              { value: "items", label: m.items },
              { value: "nature", label: m.nature },
            ]}
            value={category}
            onValueChange={setCategory}
            layout="wrap"
          />
          <div className="grid min-w-0 grid-cols-2 gap-3 xl:grid-cols-4">
            {models.map((item) => (
              <ModelCard
                messages={c.ModelCard}
                key={item.id}
                {...item}
                selected={selected === item.id}
                onSelect={() => setSelected(item.id)}
              />
            ))}
          </div>
          {models.length === 0 && <p role="status">{m.noMatchingModels}</p>}
        </section>
        <section className="min-w-0" aria-label={m.selectedModel}>
          <Card className="min-w-0 gap-3 p-4 [overflow-wrap:anywhere]">
            <h2 className="text-xl font-(weight:--spst-font-weight-heading)">{model.title}</h2>
            {/* 描画枠の状態表示を保ち、外側のカードに枠と影を集約する。 */}
            <div className="[&>[data-component=viewer-frame]]:border-0 [&>[data-component=viewer-frame]]:bg-transparent [&>[data-component=viewer-frame]]:p-0 [&>[data-component=viewer-frame]]:shadow-none">
              <ViewerFrame
                messages={c.ViewerFrame}
                variant="wide"
                controls={
                  <ViewerControls
                    messages={c.ViewerControls}
                    mode={mode}
                    onModeChange={setMode}
                    gap={gap}
                    onGapChange={setGap}
                    gapMin={0}
                    gapMax={4}
                    onRotate={(direction) =>
                      setRotation(
                        direction === "left" ? m.rotateLeftRequested : m.rotateRightRequested,
                      )
                    }
                  />
                }
              >
                <p className="p-4">
                  {model.title} {m.renderingNotice}
                </p>
              </ViewerFrame>
            </div>
            <p role="status" className={rotation ? "text-sm" : "sr-only"}>
              {rotation}
            </p>
            <div className="flex flex-wrap items-center justify-between gap-2">
              <span>
                {m.author} {model.author}
              </span>
              <Badge>{model.license}</Badge>
            </div>
            <p className="text-sm">{m.staticModel(model.title)}</p>
            <Button
              messages={c.Button}
              variant="outline"
              onClick={() => setRotation(m.detailsNotice)}
            >
              {m.openDetails}
            </Button>
            <a href="#sample-download" download className={buttonVariants()}>
              {m.downloadSs}
            </a>
            <CommandCopy
              messages={c.CommandCopy}
              text={`https://example.invalid/models/${model.id}`}
              variant="request"
              label={m.copyLink}
            />
          </Card>
        </section>
      </div>
      <SiteFooter locale={locale} links={[{ href: "#sample-docs", label: m.usageExample }]} />
    </div>
  );
}

アクセシビリティの利用条件

  • 入力には Label または読み上げ名を与え、エラーを aria-describedby で関連づけます。色だけで状態を伝えません。
  • 画像にはモデル名と代替表示を与えます。単独アイコンのボタンにも名前が必要です。
  • Dialog / Sheet に題名と説明を与え、Portal をテーマ内に置きます。Tab・矢印・Escape と閉じた後のフォーカスを利用先でも確認します。
  • Slider は名前と有限の min < max、ToggleGroup は空でない single の値が必要です。pending は親が制御します。

対応画像: 01・02 · 暗色とエラーは設計による補完です。