Mixins / foldkit-mixins-ui

Card

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

export * as Card from './card.js'

In the guides

Members

Card.CARD_HOVER

const · packages/mixins-ui/src/card/fluid.ts:5

const CARD_HOVER: 'card-hover'

The name of the group's highlight: its place is --fk-card-hover-x, -y, -w, -h.

Card.CardDismiss

interface · packages/mixins-ui/src/card.ts:61

interface CardDismiss<Message> {
  readonly onDismiss: Message
  readonly always?: boolean | undefined
}

A button that removes the card, revealed on hover or focus unless always.

Card.CardGroupFluid

interface · packages/mixins-ui/src/card.ts:216

interface CardGroupFluid {
  readonly resting: Readonly<Record<string, string>>
  readonly mount: (columns: number) => ReturnType<typeof FluidHover>
}

What Card.fluid is: the highlight's resting values and the Mount that moves it, which take columns to read the pointer's nearness in both directions in a grid. A public interface: implement it for a highlight of your own.

Card.CardGroupSlots

const · packages/mixins-ui/src/card.ts:203

const CardGroupSlots: 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 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 highlight: Slot.UnnamedSlot<
    Capability.Capability<
      'Container',
      readonly [
        Capability.Capability<
          'Interactive',
          readonly [Capability.Capability<'Base', readonly []>]
        >,
      ]
    >,
    readonly Slot.EventName[],
    readonly Slot.AttributeName[],
    readonly Slot.RequirementName[],
    boolean
  >
}>

A card group publishes its frame, the list of cards, each card's place in it, and the one highlight that moves between the cards. The root carries the most columns as --fk-card-columns, for a style's grid, which may lay fewer where the cards would be too narrow, and data-card-fluid, whether the highlight is drawn, so a card can tell whether to draw a hover of its own.

Card.CardGroupView

interface · packages/mixins-ui/src/card.ts:229

interface CardGroupView<Message> {
  readonly cards: ReadonlyArray<CardOfGroup<Message>>
  readonly columns?: number | undefined
  readonly fluid?: CardGroupFluid | undefined
  readonly label?: string | undefined
  readonly wrap?:
    ((card: Html, source: CardOfGroup<Message>) => Html) | undefined
  readonly style?: NamedStyle<typeof CardGroupSlots> | undefined
  readonly cardStyle?: NamedStyle<typeof CardSlots> | undefined
  readonly mixins?: MixinList<Message> | undefined
}

Cards as one list: in one column or a grid, divided or apart, and, given fluid, with one highlight that follows the pointer to the nearest card in place of a hover on each.

Card.CardOfGroup

type · packages/mixins-ui/src/card.ts:222

type CardOfGroup<Message> = CardView<Message> & {
  readonly key: string
}

One card of a group: a card with the key that keeps its DOM when it moves.

Card.CardPreset

type · packages/mixins-ui/src/card.ts:296

type CardPreset<Message = never> = Pick<
  CardView<Message>,
  'style' | 'words' | 'headingLevel'
> & {
  readonly groupStyle?: NamedStyle<typeof CardGroupSlots> | undefined
  readonly fluid?: CardGroupFluid | undefined
  readonly mixins?: MixinList<Message>
}

What a Card is given once: its look and words, the look of a group of them, and its highlight.

Card.CardSlots

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

const CardSlots: 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 image: 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 media: 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 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<"Intera …;

A card publishes its regions as slots; it owns no state. Draw the parts the card has and skip the rest: a bare card is a root with content, a full one adds an image, a media tile, a header with an action, and a footer.

A pressable card is one control: overlay is a link or a button stretched over the whole card, named by the title, so the card is one tab stop and one announcement. The action, the footer and the dismiss button sit above it and stay pressable on their own. The root carries data-selected, data-disabled, data-pressable 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 cards, dismissing one hands its focus to the fallback the list's parts name for it instead of dropping it to the page.

Card.CardView

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

interface CardView<Message> {
  readonly title?: string | undefined
  readonly headingLevel?: 2 | 3 | 4 | 5 | 6 | undefined
  readonly description?: string | undefined
  readonly content?: Html | undefined
  readonly image?: Html | undefined
  readonly media?: Html | undefined
  readonly action?: Html | undefined
  readonly footer?: Html | undefined
  readonly press?: Press<Message> | undefined
  readonly label?: string | undefined
  readonly selected?: boolean | undefined
  readonly disabled?: boolean | undefined
  readonly dismiss?: CardDismiss<Message> | undefined
  readonly recoveryPart?: string | undefined
  readonly words?: Partial<CardWords> | undefined
  readonly style?: NamedStyle<typeof CardSlots> | undefined
  readonly mixins?: MixinList<Message> | undefined
}

A card in one call: the regions it has, what pressing it does, its state, a style for its slots, and mixins beside the style. No upstream component stands behind it; this is the whole implementation.

Card.CardWords

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

interface CardWords {
  readonly dismiss: string
  readonly dismissAlone: string
  readonly dismissMark: string
  readonly newTab: string
}

The fixed text a card draws: the dismiss button's name ({name} is the title or label; dismissAlone when the card has neither), its mark, and what a link opening a new tab says.

Card.configure

function · packages/mixins-ui/src/card.ts:317

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

The application's own Card: base for every use, presets chosen at a use with preset, and the call over both. A preset's style reaches a group's cards too; its groupStyle and fluid are the group's own.

Card.fluid

const · packages/mixins-ui/src/card/fluid.ts:15

const fluid = { resting, mount }

One highlight that follows the pointer to the nearest card in a group, in place of a hover on each; a press in a gap presses the highlighted card. Pass it as Card.group's fluid: a group given none draws no highlight and ships none of this.

Card.group

function · packages/mixins-ui/src/card.ts:251

function group<Message>(
  options: CardGroupView<Message>,
  h: HtmlBuilder<Message>,
): Html

Card.view

function · packages/mixins-ui/src/card.ts:112

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

Card.words

const · packages/mixins-ui/src/card.ts:53

const words = { dismiss, dismissAlone, dismissMark, newTab }