コンテンツにスキップ
Page

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/ にコピーして使い始めてください。

src/components/BubbleExample.tsx
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>
);
}

Bubble は React の状態を共有する複数のパーツで構成されます。MDX に書いた子要素はそれぞれ別のアイランドとして描画されるため、パーツ同士がつながりません。上の例のように .tsx ファイルで組み立て、そのファイルをインポートしてください。

src/content/docs/example.mdx
---
title: Example
---
import BubbleExample from "../../components/BubbleExample";
<BubbleExample client:load />

client:load はページの読み込み時にアイランドをハイドレートします。ページの下の方にあるコンテンツには client:visible を使ってください。

Markdoc のタグは Astro コンポーネントを描画しますが、このコンポーネントにはクライアントの状態が必要です。例をハイドレートする .astro ファイルで包み、そのファイルをタグとして登録してください。

src/components/markdoc/BubbleExample.astro
---
import BubbleExample from "../BubbleExample";
---
<BubbleExample client:load />
markdoc.config.mjs
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,
},
},
});
src/content/docs/example.mdoc
{% bubble-example /%}

各 variant prop が受け付ける値です。

Prop値
variantdefault secondary muted tinted outline ghost destructive

コンポーネントを構成するパーツと、それぞれが描画する data-refineui のロールです。

パーツロール
rootbubble
contentbubble-content
groupbubble-group
reactionsbubble-reactions
surfacebubble-surface