Color mode

UI Primitive

@riebeckite/honox/ui は UI framework ではありません。

Site が独自のデザインを作りながら、Riebeckite と共通の HTML 構造を利用するための小さな primitive set です。

公開されている主な component は次のとおりです。

  • Article
  • ArticleLayout
  • ArticleHeader
  • ArticleContent
  • ArticleBody
  • PageBody
  • ArticleMeta
  • ArticleFooter
  • ContentSlot
  • Sidebar

対応する *Props 型も公開されています。ContentSlot には hasSlot(slots, name) という純粋 helper が対応し、ARTICLE_SLOT 定数が標準 slot 名を提供します。

Stable Styling Hooks

各 primitive は次の class を stable styling hook として提供します。

Component Class
Article rb-article
ArticleLayout rb-article-layout
ArticleHeader rb-article-header
ArticleContent rb-article-body
ArticleBody rb-article-content
ArticleMeta rb-article-meta
ArticleFooter rb-article-footer
Sidebar rb-sidebar

ArticleBody はレンダリング済み Markdown 本文を .rb-article-content として描画し、Markdown typography はこの wrapper にのみ適用されます。plugin component の見出しは plugin 自身が所有します。

ContentSlot は slots map から slot 名で HTML fragment を取り出し、data-slot を付けて描画します。存在しない slot、空文字、whitespace のみの slot は何も描画しません。class / className で Site 固有 class を追加できます。slot 名から semantic 要素を推測するような暗黙の mapping は行いません。

Primitive が担当するのは主に、

  • semantic HTML
  • stable styling hook
  • class / className の合成
  • hook を成立させる構造 CSS

です。rb-* hook を成立させる構造 CSS は @riebeckite/honox/style.css にあり、生成された .riebeckite/framework-styles.css 経由で Site に読み込まれます。

一方、

  • 記事本文の見た目
  • metadata の表示形式
  • navigation の配置
  • card
  • page layout の composition
  • island
  • Site 固有の visual design と override

は Site Application が管理します。

使用例

tsx
import {
  Article,
  ArticleBody,
  ArticleContent,
  ArticleLayout,
  ContentSlot,
} from "@riebeckite/honox/ui";
 
<Article class="site-article">
  <ArticleLayout>
    <ContentSlot
      slots={bodySlots}
      name="article.aside"
      class="site-article__aside"
    />
    <ArticleContent>
      <ContentSlot slots={bodySlots} name="article.header" />
      <ContentSlot slots={bodySlots} name="article.metadata" />
      <ArticleBody html={post.html ?? ""} />
    </ArticleContent>
  </ArticleLayout>
</Article>;

ArticleHeader と ArticleContent は、children と HTML input prop のどちらか一方だけを受け取ります。レンダリング済み Markdown 本文は ArticleBody に渡してください。ArticleContent html={...} は後方互換のために残っていますが非推奨です。

Primitive は composition point として使用し、構造は Framework の hook CSS が、見た目は Site 側が定義してください。

また、

text
@riebeckite/honox/src/

以下を直接 import しないでください。

公開 API として記載されていない内部 component に依存することも避けてください。

History

1 changesCollapseExpand
1 + ---
2 + title: UI Primitive
3 + sidebar:
4 + label: UI Primitive
5 + order: 10
6 + ---
7 + # UI Primitive
8 +
9 + `@riebeckite/honox/ui` は UI framework ではありません。
10 +
11 + Site が独自のデザインを作りながら、Riebeckite と共通の HTML 構造を利用するための小さな primitive set です。
12 +
13 + 公開されている主な component は次のとおりです。
14 +
15 + - `Article`
16 + - `ArticleLayout`
17 + - `ArticleHeader`
18 + - `ArticleContent`
19 + - `ArticleBody`
20 + - `PageBody`
21 + - `ArticleMeta`
22 + - `ArticleFooter`
23 + - `ContentSlot`
24 + - `Sidebar`
25 +
26 + 対応する `*Props` 型も公開されています。`ContentSlot` には `hasSlot(slots, name)` という純粋 helper が対応し、`ARTICLE_SLOT` 定数が標準 slot 名を提供します。
27 +
28 + ## Stable Styling Hooks
29 +
30 + 各 primitive は次の class を stable styling hook として提供します。
31 +
32 + | Component | Class |
33 + | --- | --- |
34 + | `Article` | `rb-article` |
35 + | `ArticleLayout` | `rb-article-layout` |
36 + | `ArticleHeader` | `rb-article-header` |
37 + | `ArticleContent` | `rb-article-body` |
38 + | `ArticleBody` | `rb-article-content` |
39 + | `ArticleMeta` | `rb-article-meta` |
40 + | `ArticleFooter` | `rb-article-footer` |
41 + | `Sidebar` | `rb-sidebar` |
42 +
43 + `ArticleBody` はレンダリング済み Markdown 本文を `.rb-article-content` として描画し、Markdown typography はこの wrapper にのみ適用されます。plugin component の見出しは plugin 自身が所有します。
44 +
45 + `ContentSlot` は `slots` map から slot 名で HTML fragment を取り出し、`data-slot` を付けて描画します。存在しない slot、空文字、whitespace のみの slot は何も描画しません。`class` / `className` で Site 固有 class を追加できます。slot 名から semantic 要素を推測するような暗黙の mapping は行いません。
46 +
47 + Primitive が担当するのは主に、
48 +
49 + - semantic HTML
50 + - stable styling hook
51 + - `class` / `className` の合成
52 + - hook を成立させる構造 CSS
53 +
54 + です。`rb-*` hook を成立させる構造 CSS は `@riebeckite/honox/style.css` にあり、生成された `.riebeckite/framework-styles.css` 経由で Site に読み込まれます。
55 +
56 + 一方、
57 +
58 + - 記事本文の見た目
59 + - metadata の表示形式
60 + - navigation の配置
61 + - card
62 + - page layout の composition
63 + - island
64 + - Site 固有の visual design と override
65 +
66 + は Site Application が管理します。
67 +
68 + ## 使用例
69 +
70 + ```tsx
71 + import {
72 + Article,
73 + ArticleBody,
74 + ArticleContent,
75 + ArticleLayout,
76 + ContentSlot,
77 + } from "@riebeckite/honox/ui";
78 +
79 + <Article class="site-article">
80 + <ArticleLayout>
81 + <ContentSlot
82 + slots={bodySlots}
83 + name="article.aside"
84 + class="site-article__aside"
85 + />
86 + <ArticleContent>
87 + <ContentSlot slots={bodySlots} name="article.header" />
88 + <ContentSlot slots={bodySlots} name="article.metadata" />
89 + <ArticleBody html={post.html ?? ""} />
90 + </ArticleContent>
91 + </ArticleLayout>
92 + </Article>;
93 + ```
94 +
95 + `ArticleHeader` と `ArticleContent` は、children と HTML input prop のどちらか一方だけを受け取ります。レンダリング済み Markdown 本文は `ArticleBody` に渡してください。`ArticleContent html={...}` は後方互換のために残っていますが非推奨です。
96 +
97 + Primitive は composition point として使用し、構造は Framework の hook CSS が、見た目は Site 側が定義してください。
98 +
99 + また、
100 +
101 + ```text
102 + @riebeckite/honox/src/
103 + ```
104 +
105 + 以下を直接 import しないでください。
106 +
107 + 公開 API として記載されていない内部 component に依存することも避けてください。
108 +