Mixins / foldkit-mixins-ui

Sidebar

namespace · packages/mixins-ui/src/sidebar.ts:1

export * as Sidebar from './sidebar.js'

In the guides

Members

Sidebar.fluid

const · packages/mixins-ui/src/sidebar/fluid.ts:14

const fluid: readonly [Mixin<never>, Mixin<never>]

What moves the indicator and highlight, on the navigation: the current link is measured (--fk-sidebar-chosen-*), and one highlight follows the pointer to the nearest row (--fk-sidebar-hover-*), born at the current one. Pass them beside the style; until they run, the current link fills itself. The phone's Sheet draws its own marker and highlight for them.

Sidebar.init

function · packages/mixins-ui/src/sidebar.ts:194

function init(config: InitConfig): Model

A sidebar, expanded unless collapsed, with a Tooltip for each of rows.

Sidebar.InitConfig

interface · packages/mixins-ui/src/sidebar.ts:170

interface InitConfig {
  readonly id: string
  readonly rows: ReadonlyArray<string>
  readonly collapsed?: boolean | undefined
  readonly open?: ReadonlyArray<string> | undefined
  readonly side?: 'left' | 'right' | undefined
  readonly width?:
    | {
        readonly size?: number | undefined
        readonly min?: number | undefined
        readonly max?: number | undefined
      }
    | undefined
}

Sidebar.Message

const · packages/mixins-ui/src/sidebar.ts:147

const Message: MessageUnion<{ readonly ToggledSection: { readonly id: Schema.String; }; readonly ToggledCollapsed: {}; readonly ExpandedTo: { readonly id: Schema.String; }; readonly GotTip: { readonly row: Schema.String; readonly message: MessageUnion<{ readonly EnteredTrigger: {}; readonly LeftTrigger: {}; readonly FocusedTrigger: {}; readonly BlurredTrigger: {}; readonly PressedEscape: {}; readonly PressedPointerOnTrigger: { pointerType: Schema.String; }; readonly CompletedWaitBeforeShowing: { version: Schema.Number; }; readonly CompletedAnchorTooltip: {}; }>; }; readonly GotSheet: { readonly message: MessageUnion<{ readonly GotDialog: { readonly message: MessageUnion<{ readonly RequestedOpen: {}; readonly RequestedClose: {}; readonly SucceededShowDialog: {}; readonly FailedShowDialog: {}; readonly SucceededAcquireResources: {}; readonly FailedAcquireResources: {}; readonly CompletedCloseDialog: {}; readonly Unmounted: {}; readonly CompletedReleaseDialogResources: {}; readonly GotAnimationMessage: { message: import("foldkit/message").MessageUnion<{ readonly Showed: {}; readonly Hid: {}; readonly CompletedWaitForPaint: { generation: Schema.Number; }; readonly EndedAnimation: { generation: Schema.Number; }; }>; }; }>; }; readonly Grabbed: { readonly size: Schema.Number; }; readonly Dragged: { readonly delta: Schema.Number; }; readonly Released: { readonly delta: Schema.Number; readonly velocity: Schema.Number; readonly completed: Schema.Boolean; }; readonly SnappedTo: { readonly at: Schema. …;

Sidebar.Model

const · packages/mixins-ui/src/sidebar.ts:131

const Model: Schema.Struct<{ readonly id: Schema.String; readonly collapsed: Schema.Boolean; readonly width: Schema.Option<Schema.Struct<{ readonly size: Schema.Number; readonly min: Schema.Number; readonly max: Schema.Number; }>>; readonly drag: Schema.Option<Schema.Struct<{ readonly from: Schema.Number; readonly size: Schema.Number; }>>; readonly open: Schema.$Array<Schema.String>; readonly tips: Schema.$Array<Schema.Struct<{ readonly row: Schema.String; readonly tooltip: Schema.Struct<{ readonly id: Schema.String; readonly isOpen: Schema.Boolean; readonly isHovered: Schema.Boolean; readonly isFocused: Schema.Boolean; readonly isDismissed: Schema.Boolean; readonly showDelay: Schema.DurationFromMillis; readonly pendingShowVersion: Schema.Number; readonly maybeLastPointerType: Schema.Option<Schema.String>; }>; }>>; readonly sheet: Schema.Struct<{ readonly dialog: Schema.Struct<{ readonly id: Schema.String; readonly isOpen: Schema.Boolean; readonly isAnimated: Schema.Boolean; readonly animation: Schema.Struct<{ readonly id: Schema.String; readonly isShowing: Schema.Boolean; readonly transitionState: Schema.Literals<readonly ["Idle", "EnterStart", "EnterAnimating", "LeaveStart", "LeaveAnimating"]>; readonly transitionGeneration: Schema.Number; }>; readonly maybeFocusSelector: Schema.Option<Schema.String>; }>; readonly side: Schema.Literals<readonly ["top", "right", "bottom", "left"]>; readonly points: Schema.$Array<Schema.Number>; readonly at: Schema.Number; readonly opensAt: Schema.Number; …;

Sidebar.SidebarAction

interface · packages/mixins-ui/src/sidebar.ts:79

interface SidebarAction<Message> {
  readonly label: string
  readonly icon: Html
  readonly message: Message
}

A button beside a row or a group's heading: an icon, named by label, that sends message.

Sidebar.SidebarBranch

interface · packages/mixins-ui/src/sidebar.ts:96

interface SidebarBranch extends RowParts {
  readonly items: ReadonlyArray<SidebarLeaf>
  readonly href?: undefined
  readonly action?: undefined
}

A row that shows and hides items under it, open while its id is in the Model's open.

Sidebar.SidebarEnd

interface · packages/mixins-ui/src/sidebar.ts:105

interface SidebarEnd {
  readonly content: Html
  readonly mark?: Html | undefined
}

The header or the footer: a mark, which a rail keeps centred, and what follows it.

Sidebar.SidebarGroup

interface · packages/mixins-ui/src/sidebar.ts:111

interface SidebarGroup<Message = never> {
  readonly id: string
  readonly title?: string | undefined
  readonly collapsible?: boolean | undefined
  readonly action?: SidebarAction<Message> | undefined
  readonly rows: ReadonlyArray<SidebarRow<Message>>
}

Sidebar.SidebarLeaf

interface · packages/mixins-ui/src/sidebar.ts:72

interface SidebarLeaf extends Pick<
  RowContent,
  'label' | 'icon' | 'content' | 'trailing'
> {
  readonly href: string
  readonly current?: boolean | undefined
}

A link nested under a branch, with the same parts as a row but its id.

interface · packages/mixins-ui/src/sidebar.ts:86

interface SidebarLink<Message = never> extends RowParts {
  readonly href: string
  readonly current?: boolean | undefined
  readonly action?: SidebarAction<Message> | undefined
  readonly items?: undefined
}

A row that leads to a page.

Sidebar.SidebarRow

type · packages/mixins-ui/src/sidebar.ts:102

type SidebarRow<Message = never> = SidebarLink<Message> | SidebarBranch

Sidebar.SidebarSlots

const · packages/mixins-ui/src/sidebar/slots.ts:4

const SidebarSlots: Slots.Contract<{ readonly root: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly header: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly footer: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly toggle: Slot.UnnamedSlot<Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>, readonly [Event.EventToken<"click">], readonly [Attr.AttrToken<"aria-expanded">, Attr.AttrToken<"aria-label">], readonly Slot.RequirementName[], boolean>; readonly opener: Slot.UnnamedSlot<Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>, readonly [Event.EventToken<"click">], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly nav: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capab …;

A sidebar's pieces: the column, its groups and rows, the rail's tips, the marker and the resize handle.

Sidebar.SidebarView

interface · packages/mixins-ui/src/sidebar.ts:350

interface SidebarView<Message> {
  readonly model: Model
  readonly onMessage: (message: typeof Message.Type) => NoInfer<Message>
  readonly label: string
  readonly groups: ReadonlyArray<SidebarGroup<Message>>
  readonly header?: SidebarEnd | undefined
  readonly footer?: SidebarEnd | undefined
  readonly direction?: 'ltr' | 'rtl' | undefined
  readonly collapse?: 'offcanvas' | 'icons' | undefined
  readonly words?: Partial<SidebarWords> | undefined
  readonly style?: NamedStyle<typeof SidebarSlots> | undefined
  readonly mixins?: MixinList<Message> | undefined
  readonly tooltip?: MixinList<Message> | undefined
  readonly sheet?: MixinList<Message> | undefined
}

Sidebar.SidebarWords

interface · packages/mixins-ui/src/sidebar.ts:332

interface SidebarWords {
  readonly show: string
  readonly hide: string
  readonly open: string
  readonly resize: string
}

The fixed text a sidebar draws, with {label} where the navigation's name goes.

Sidebar.toggled

function · packages/mixins-ui/src/sidebar.ts:212

function toggled(open: ReadonlyArray<string>, id: string): ReadonlyArray<string>

The open groups after id is pressed: several stay open, a press flips one.

Sidebar.update

function · packages/mixins-ui/src/sidebar.ts:234

function update(model: Model, message: Message): Return<Model, Message>

The sidebar after message; the same Model when nothing changes.

Sidebar.view

function · packages/mixins-ui/src/sidebar.ts:383

function view<Message>(
  options: SidebarView<Message>,
  h: HtmlBuilder<Message>,
): Html

The sidebar. The phone's Sheet draws the same groups again, with ids of its own, so the two never share one.

Sidebar.words

const · packages/mixins-ui/src/sidebar.ts:343

const words = { show, hide, open, resize }