Skip to content
fandhe-frontend
GitHub

Drawer

fandhe-frontend-pre-styled-uidrawer mod が提供するスタイル済み Drawer 部品です。 画面端からスライドインするパネルで、WAI-ARIA 上は Dialog パターンの変種のため 新規状態機械を作らず dialogDisclosure 状態機械をそのまま再利用します。 DrawerPlacement(始端/終端/上端/下端、既定は終端)でどの端から出現するかを 切り替えられます。

関連 API: fandhe-frontend-pre-styled-ui API / fandhe-frontend-headless-ui API

Demo

headless-ui の Drawer(WAI-ARIA dialog パターンの変種、dialog の状態機械を再利用)に pre-styled-ui の data-scope / data-part セレクタ CSS を適用した静的掲示です。placement="end" を掲示しています。backdrop は掲示用に非表示化し、positioner はフロー内配置へ中和しています。

Features

  • 画面端からスライドインするパネル。WAI-ARIA 上は Dialog パターンの変種であり、新規状態機械を作らず crate::dialog の状態機械(Disclosure)をそのまま再利用する。
  • Root / Trigger / Backdrop / Positioner / Content / Title / Description / CloseTrigger の 8 anatomy パーツ(dialog と同一構成)。
  • DrawerPlacement(Start/End/Top/Bottom、既定 End)で画面のどの端から出現するかを data-placement として root/positioner/content へ出力する。
  • size variant で寸法を切り替える。

Anatomy

trigger
root
  backdrop
  positioner
    content
      title
      description
      close-trigger

API Reference

Arguments

NameTypeDefaultDescription
sizeSizeSize::Mdroot へ付与するサイズ variant(Sm/Md/Lg)。
stateOpenState開閉状態(Open/Closed)。dialog と同じ Disclosure 状態機械を再利用する。
placementDrawerPlacementDrawerPlacement::End画面のどの端から出現するか(Start/End/Top/Bottom)。data-placement として出力される。

Data Attributes

PartAttributeObserved Values
backdropdata-stateopen
contentdata-placementend
contentdata-stateopen
positionerdata-placementend
positionerdata-stateopen
rootdata-placementend
rootdata-stateopen
triggerdata-stateopen

CSS Variables

VariableDefault
--fandhe-drawer-content-paddingvar(--fandhe-space-6)
--fandhe-drawer-size20rem

Accessibility

WAI-ARIA

AttributeDescription
aria-haspopup="dialog"trigger に固定付与。
aria-expanded / aria-controlstrigger に付与。dialog と同一の意味論。
role="dialog"content に固定付与。
aria-modalcontent に付与。モーダルかどうかを表す真偽値。
aria-labelledby / aria-describedbycontent に付与。対応する title/description が設定されているときのみ出力される。