Mixins / foldkit-mixins-ui

Alert

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

export * as Alert from './alert.js'

In the guides

Members

Alert.AlertAction

type · packages/mixins-ui/src/alert.ts:48

type AlertAction<Message> =
  | {
      readonly label: string
      readonly href: string
    }
  | {
      readonly label: string
      readonly onClick: Message
    }

An action: a link to follow, or a button that sends a Message.

Alert.AlertPreset

type · packages/mixins-ui/src/alert.ts:169

type AlertPreset = Pick<AlertView<never>, 'style' | 'words'> & {
  readonly mixins?: MixinList<never>
}

What an Alert is given once: its look and words. The layout and the content are each use's.

Alert.AlertSlots

const · packages/mixins-ui/src/alert.ts:19

const AlertSlots: 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 icon: 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 title: 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 description: 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 actions: 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 action: Slot.UnnamedSlot<Capability.Capability<"Interactive", re …;

An alert publishes its regions as slots; it owns no state. Shown or dismissed is the application's: onDismiss asks, and the next view leaves the alert out. The root carries data-layout and data-dismissible for a style to read. Given recoveryPart, its dismiss button is a FocusRecovery part: with FocusRecovery.behavior (from foldkit-primitives/interaction) on the list holding the alerts, dismissing one hands its focus to the fallback the list's parts name for it instead of dropping it to the page.

Alert.AlertTone

type · packages/mixins-ui/src/alert.ts:34

type AlertTone = Tone

A tone the alert's recipe draws: the vocabulary every recipe with a tone axis shares.

Alert.AlertView

type · packages/mixins-ui/src/alert.ts:96

type AlertView<Message = never> = InlineAlert<Message> | BannerAlert<Message>

Alert.AlertWords

interface · packages/mixins-ui/src/alert.ts:40

interface AlertWords {
  readonly dismiss: string
  readonly dismissMark: string
}

The fixed text an alert draws: the dismiss button's name ({name} is the title inline and the label as a banner) and its mark.

Alert.BannerAlert

interface · packages/mixins-ui/src/alert.ts:90

interface BannerAlert<Message> extends AlertContent<Message> {
  readonly layout: 'banner'
  readonly label: string
}

A full-width strip across a page or a section, there when it loads: a region landmark (a section named by label), not a live region, which would say nothing on load. The landmark lets a screen reader find it, and its dismiss button, from anywhere.

Alert.configure

function · packages/mixins-ui/src/alert.ts:177

function configure<const Names extends string = never>(
  config: Presets<AlertPreset, Names>,
): {
  readonly view: <Outer>(
    options: AlertView<Outer> & PresetOption<Names>,
    h: HtmlBuilder<Outer>,
  ) => Html
}

The application's own Alert: base for every use, presets chosen at a use with preset (a warning, a failure), and the call over both.

Alert.InlineAlert

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

interface InlineAlert<Message> extends AlertContent<Message> {
  readonly layout: 'inline'
  readonly assertive?: boolean | undefined
}

A notice inside the content, of something that just happened: a live region. assertive interrupts (role="alert"); anything else reports (role="status"). Screen readers speak what changes in a live region, not what it held when the page loaded, so draw it when the thing happens.

Alert.view

function · packages/mixins-ui/src/alert.ts:98

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

Alert.words

const · packages/mixins-ui/src/alert.ts:45

const words = { dismiss, dismissMark }