コンテンツにスキップ
Page

Resizable

ドラッグできるハンドルで区切られた分割パネルです。

Sidebar
Content
import { ResizablePanelGroup, ResizablePanel, ResizableHandle } from "@pelagornis/page/components";

上のプレビューはこのファイルを描画したものです。src/components/ にコピーして使い始めてください。

src/components/ResizableExample.tsx
import {
Box,
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
Text,
} from "@pelagornis/page/components";
export default function ResizableDemo() {
return (
<Box border="strokeWidthThin" borderColor="borderDefault" radius="roundedLarge" className="h-48 w-full overflow-hidden">
<ResizablePanelGroup orientation="horizontal">
<ResizablePanel defaultSize={35} minSize={20}>
<Box padding="sizeLarge">
<Text variant="subtitleMd">Sidebar</Text>
</Box>
</ResizablePanel>
<ResizableHandle />
<ResizablePanel defaultSize={65} minSize={30}>
<Box padding="sizeLarge">
<Text variant="subtitleMd">Content</Text>
</Box>
</ResizablePanel>
</ResizablePanelGroup>
</Box>
);
}

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

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

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

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

src/components/markdoc/ResizableExample.astro
---
import ResizableExample from "../ResizableExample";
---
<ResizableExample 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: {
"resizable-example": {
render: component("./src/components/markdoc/ResizableExample.astro"),
selfClosing: true,
},
},
});
src/content/docs/example.mdoc
{% resizable-example /%}

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

Prop値
orientationhorizontal vertical

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

パーツロール
rootresizable-panel-group
resizable_handleresizable-handle
resizable_panelresizable-panel

フォーカスがあるときにコンポーネントが処理するキーです。

キー動作
Homefirst-trigger
Endlast-trigger