Bubble
左右どちらかに寄せるチャットメッセージの吹き出しです。
Does the theme support Markdoc?
Yes. Register a tag with an Astro wrapper.
Great, thanks.
インポート
「インポート」セクションimport { Bubble, BubbleContent, BubbleGroup } from "@pelagornis/page/components";上のプレビューはこのファイルを描画したものです。src/components/ にコピーして使い始めてください。
import { Bubble, BubbleContent, BubbleGroup } from "@pelagornis/page/components";
export default function BubbleDemo() { return ( <BubbleGroup className="w-full max-w-md"> <Bubble variant="muted" align="start"> <BubbleContent>Does the theme support Markdoc?</BubbleContent> </Bubble> <Bubble variant="default" align="end"> <BubbleContent>Yes. Register a tag with an Astro wrapper.</BubbleContent> </Bubble> <Bubble variant="muted" align="start"> <BubbleContent>Great, thanks.</BubbleContent> </Bubble> </BubbleGroup> );}MDX で使う
「MDX で使う」セクションBubble は React の状態を共有する複数のパーツで構成されます。MDX に書いた子要素はそれぞれ別のアイランドとして描画されるため、パーツ同士がつながりません。上の例のように .tsx ファイルで組み立て、そのファイルをインポートしてください。
---title: Example---
import BubbleExample from "../../components/BubbleExample";
<BubbleExample client:load />client:load はページの読み込み時にアイランドをハイドレートします。ページの下の方にあるコンテンツには client:visible を使ってください。
Markdoc で使う
「Markdoc で使う」セクションMarkdoc のタグは Astro コンポーネントを描画しますが、このコンポーネントにはクライアントの状態が必要です。例をハイドレートする .astro ファイルで包み、そのファイルをタグとして登録してください。
---import BubbleExample from "../BubbleExample";---
<BubbleExample client:load />import { component, defineMarkdocConfig } from "@astrojs/markdoc/config";import starlightMarkdoc from "@astrojs/starlight-markdoc";import pageMarkdoc from "@pelagornis/page/markdoc";
export default defineMarkdocConfig({ extends: [starlightMarkdoc(), pageMarkdoc()], tags: { "bubble-example": { render: component("./src/components/markdoc/BubbleExample.astro"), selfClosing: true, }, },});{% bubble-example /%}バリアント
「バリアント」セクション各 variant prop が受け付ける値です。
| Prop | 値 |
|---|---|
variant | default secondary muted tinted outline ghost destructive |
コンポーネントを構成するパーツと、それぞれが描画する data-refineui のロールです。
| パーツ | ロール |
|---|---|
root | bubble |
content | bubble-content |
group | bubble-group |
reactions | bubble-reactions |
surface | bubble-surface |
- デザインのガイドとトークンの詳細は RefineUI · Bubble を参照してください。
- 共通のルールは MDX で使う と Markdoc で使う を参照してください。