セパレータ
stimeo--separator
APG Separator の意味付け。任意で値を持つフォーカス可能版も提供。
stimeo--separator コントローラは、装飾的区切りに role="separator" と aria-orientation を付与します。任意の「値を持つフォーカス可能セパレータ」では aria-valuenow を同期し、矢印キーでの増減時に stimeo--separator:change を発火します(ArrowUp/ArrowRight で増、ArrowDown/ArrowLeft で減、Home/End で最小 / 最大へ。向きの軸にスコープ)。実際のペインのサイズ変更・ドラッグは対象外で、それは Resizable に委ねます。ライブラリは挙動のみを提供し、線の描画はこの Playground が持ちます。
下の細い横線は装飾的なセパレータです(role="separator" の意味付けだけで、操作はありません)。
次のハンドルは値を持つフォーカス可能なセパレータです。Tab でフォーカスし、矢印キーで左右の割合を増減できます(マウスのドラッグでリサイズしたい場合は Resizable コンポーネントを使います)。
キーボード操作
| キー | 動作 |
|---|---|
| 矢印キー | 向きの軸に沿って値を増減(フォーカス可能版)。 |
| Home / End | 最小 / 最大へジャンプ(フォーカス可能版)。 |
<%# Markup for the separator demo.
The top is a decorative separator (only role="separator" and aria-orientation).
The bottom is a valued, focusable separator that increments/decrements aria-valuenow
with the arrow keys and fires stimeo--separator:change. The actual pane-width change
(demo.js) and line rendering (demo.css) are the consumer's job. %>
<div class="separator-demo">
<p class="separator-demo__text"><%= t("components.separator.demo.intro") %></p>
<div
class="separator separator--horizontal"
role="separator"
data-controller="stimeo--separator"
data-stimeo--separator-orientation-value="horizontal"></div>
<p class="separator-demo__text"><%= t("components.separator.demo.after") %></p>
<div class="separator-demo__split">
<div class="separator-demo__pane"><%= t("components.separator.demo.left") %></div>
<div
class="separator separator--vertical"
role="separator"
tabindex="0"
aria-label="<%= t('components.separator.demo.handle') %>"
aria-orientation="vertical"
aria-valuemin="20"
aria-valuemax="80"
aria-valuenow="50"
data-controller="stimeo--separator"
data-stimeo--separator-focusable-value="true"
data-stimeo--separator-step-value="5"
data-action="keydown->stimeo--separator#onKeydown"></div>
<div class="separator-demo__pane"><%= t("components.separator.demo.right") %></div>
</div>
</div>
/*
* Presentation-only styles for the separator demo.
* The line's rendering, color, and thickness are owned by the consumer's CSS. The
* library only gives meaning to role / aria-orientation / aria-valuenow.
*/
.separator-demo {
max-width: 32rem;
}
.separator-demo__text {
margin: 0.5rem 0;
}
.separator--horizontal {
height: 1px;
margin: 0.75rem 0;
background: var(--border-strong);
}
.separator-demo__split {
display: flex;
align-items: stretch;
height: 6rem;
margin-top: 1rem;
border: 1px solid var(--border-default);
border-radius: 0.5rem;
overflow: hidden;
/* demo.js updates this variable from aria-valuenow (%) to set the left pane's width. */
--separator-split: 50%;
}
.separator-demo__pane {
display: grid;
place-items: center;
padding: 0.5rem;
background: var(--surface-subtle);
}
.separator-demo__pane:first-child {
flex: 0 0 var(--separator-split);
}
.separator-demo__pane:last-child {
flex: 1;
}
.separator--vertical {
flex: 0 0 0.5rem;
background: var(--border-strong);
cursor: col-resize;
}
/* Use :focus (not :focus-visible) so the color inversion shows on click too, not
only on keyboard focus — a resize handle is dragged with the mouse, and the user
needs to see it took focus. (Same reasoning as the time_picker demo.) */
.separator--vertical:focus {
outline: 2px solid var(--accent);
outline-offset: -2px;
background: var(--accent);
}
// Consumer-side JS for the separator demo (optional).
// A valued, focusable separator increments/decrements aria-valuenow with the arrow
// keys and fires stimeo--separator:change with { value }.
// Here we reflect that value (%) into the left pane's width to visualize the resize.
// The actual layout/size computation is the consumer's job (the library only gives the
// value meaning).
document.addEventListener("stimeo--separator:change", (event) => {
const split = event.target.closest(".separator-demo__split");
if (!split) return;
split.style.setProperty("--separator-split", `${event.detail.value}%`);
});
これらのスタイルは共通のデザイントークン(ライト/ダーク両対応)を使います。 共通スタイルも一緒にコピーし、ルート要素の data-theme を切り替えればダークになります。
このコンポーネントを動かすために HTML へ記述する data-* 属性です。ルート要素に下の data-controller を付け、その内側に各 target / value / action を配置します。
ルート要素に付与
data-controller="stimeo--separator"
値(Values)
| 名前 | 説明 | 属性 |
|---|---|---|
orientation
|
未設定時に aria-orientation を初期化する(既定 horizontal、または vertical)。 |
data-stimeo--separator-orientation-value |
focusable
|
true のとき、矢印キーで値を調整できるフォーカス可能な値付きセパレーターにする(既定 false)。 | data-stimeo--separator-focusable-value |
step
|
矢印キー1回あたりに aria-valuenow が変化する量(既定 1)。 |
data-stimeo--separator-step-value |
アクション
| 名前 | 説明 | アクション |
|---|---|---|
onKeydown
|
フォーカス可能な場合に矢印キーと Home/End で aria-valuenow を範囲内に調整する。 |
stimeo--separator#onKeydown |
イベント
| 名前 | 説明 | イベント |
|---|---|---|
change
|
矢印・Home/End キーで値が変化したときに発火。detail にクランプ済みの { value } を載せる。 |
stimeo--separator:change |
状態フック
ライブラリが操作するのはこれらの ARIA / data 属性、カスタムプロパティだけです。見た目は利用側 CSS がこれらに反応して作ります([aria-selected] / [aria-expanded] / var(--stimeo--…) などのセレクタでフックします)。
| フック | 対象 | 意味 |
|---|---|---|
aria-orientation |
ルート要素 | "horizontal" / "vertical"。 |
aria-valuenow |
ルート要素 | 値を持つ区切りの現在値(フォーカス可能時)。 |