Mixins / foldkit-mixins-ui

Breadcrumb

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

export * as Breadcrumb from './breadcrumb.js'

In the guides

Members

type · packages/mixins-ui/src/breadcrumb.ts:94

type BreadcrumbCollapse<Message> =
  BreadcrumbExpand<Message> | CollapseFeature<Message>

interface · packages/mixins-ui/src/breadcrumb.ts:64

interface BreadcrumbExpand<Message> extends CollapseParts {
  readonly onExpand: Message
  readonly draw?: undefined
}

The middle of a long trail folded into one ellipsis, which shows it all when pressed.

const · packages/mixins-ui/src/breadcrumb.ts:27

const BreadcrumbSlots: Slots.Contract<{ readonly root: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly [Attr.AttrToken<"role">, Attr.AttrToken<"aria-label">], readonly Slot.RequirementName[], boolean>; readonly list: 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 item: 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 link: Slot.UnnamedSlot<Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>, readonly Slot.EventName[], readonly [Attr.AttrToken<"aria-label">], readonly Slot.RequirementName[], boolean>; readonly current: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly [Attr.AttrToken<"aria-current">, Attr.AttrToken<"aria-label">], readonly Slot.RequirementName[], boolean>; readonly icon: Slot.UnnamedSlot<Capability.Capability<"Container", readonly  …;

A breadcrumb trail publishes its regions as slots; it owns no state, messages, or bundles. The trail is a navigation landmark with an ordered list; the current page is text, not a link, marked aria-current. The recipe draws the separator between steps; a separator of the view's own is drawn in each step after the first, hidden from assistive technology. Folded (collapse), the middle of a long trail is one ellipsis, which asks the application to draw the trail whole, or opens what a CollapseFeature draws, such as BreadcrumbMenu.make's Menu of the steps it hides.

interface · packages/mixins-ui/src/breadcrumb.ts:46

interface BreadcrumbStep {
  readonly label: string
  readonly href?: string | undefined
  readonly current?: boolean | undefined
  readonly icon?: Html | undefined
  readonly trailing?: Html | undefined
  readonly labelHidden?: boolean | undefined
}

One step: a link anywhere but here, plain text for where we are.

interface · packages/mixins-ui/src/breadcrumb.ts:149

interface BreadcrumbView<Message = never> {
  readonly words?: Partial<BreadcrumbWords> | undefined
  readonly steps: ReadonlyArray<BreadcrumbStep>
  readonly separator?: Html | undefined
  readonly collapse?: BreadcrumbCollapse<Message> | undefined
  readonly style?: NamedStyle<typeof BreadcrumbSlots> | undefined
  readonly mixins?: MixinList<Message> | undefined
}

A breadcrumb trail in one call: the steps from the site root to here, a style for its slots, and mixins beside the style. No upstream component stands behind it.

interface · packages/mixins-ui/src/breadcrumb.ts:163

interface BreadcrumbWords {
  readonly label: string
  readonly more: string
  readonly ellipsis: string
}

Breadcrumb.chosen

function · packages/mixins-ui/src/breadcrumb.ts:137

function chosen(
  steps: ReadonlyArray<BreadcrumbStep>,
  max: number,
  value: string,
): Option.Option<BreadcrumbStep>

The hidden step a Menu row chosen stands for, by the row's value (the Menu's Selected value); none when no hidden step has it.

Breadcrumb.collapsedOf

function · packages/mixins-ui/src/breadcrumb.ts:101

function collapsedOf(
  steps: ReadonlyArray<BreadcrumbStep>,
  max: number,
): {
  readonly before: ReadonlyArray<BreadcrumbStep>
  readonly hidden: ReadonlyArray<BreadcrumbStep>
  readonly after: ReadonlyArray<BreadcrumbStep>
}

The steps drawn before the ellipsis, the ones it hides, and the ones after it: the first step, then the last max - 1. A trail of max steps or fewer hides none.

Breadcrumb.CollapseDraw

interface · packages/mixins-ui/src/breadcrumb.ts:71

interface CollapseDraw<Message> {
  readonly label: string
  readonly ellipsis: string
  readonly hidden: ReadonlyArray<BreadcrumbStep>
  readonly builders: SlotBuilders<typeof BreadcrumbSlots, Message>
}

What a CollapseFeature is given to draw the ellipsis.

Breadcrumb.CollapseFeature

interface · packages/mixins-ui/src/breadcrumb.ts:88

interface CollapseFeature<Message> extends CollapseParts {
  readonly draw: (input: CollapseDraw<Message>, h: HtmlBuilder<Message>) => Html
  readonly onExpand?: undefined
}

How a folded trail draws its ellipsis, built by the application and handed to the view as collapse. BreadcrumbMenu.make is one, a Menu of the hidden steps; one of the application's own (a Popover, a dialog) is a value of this shape. It lives apart from the trail so a page that never folds into a Menu never loads Menu.

Breadcrumb.hiddenRows

function · packages/mixins-ui/src/breadcrumb.ts:130

function hiddenRows(
  hidden: ReadonlyArray<BreadcrumbStep>,
): ReadonlyArray<ItemRow>

The rows of a Menu of these hidden steps; a row's value is its place among them.

function · packages/mixins-ui/src/breadcrumb.ts:124

function menuRows(
  steps: ReadonlyArray<BreadcrumbStep>,
  max: number,
): ReadonlyArray<ItemRow>

The rows of the Menu a folded trail opens: one per hidden step, in order, for Menu.init and the view. A row's value is its step's place among the hidden ones, so two steps with one label are two rows.

Breadcrumb.view

function · packages/mixins-ui/src/breadcrumb.ts:179

function view<Message = never>(
  options: BreadcrumbView<Message>,
  h: HtmlBuilder<Message>,
): Html

Breadcrumb.words

const · packages/mixins-ui/src/breadcrumb.ts:173

const words = { label, more, ellipsis }

The defaults, in English: text with {blanks}.