Components

Frame

A tray that holds several panels, with a heading, an action and a note: alerts, rows, a list of items.

Previews are drawn in the theme you made.

Edit it
variant
padding
spacing
radius
scheme
direction

A tray of panels #

Deployments

Everything shipped this week.

Production, from main, 4 minutes ago

Preview, from the billing branch, yesterday

Production, from main, 2 days ago

Updated just now
import { Button, Frame, FrameSlots, Recipes } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

const Quiet = Recipes.Button.style({ tone: 'neutral', variant: 'outline', size: 'sm' })

// A tray with a heading, an action and a note, holding one panel for each
// thing that belongs with the others. Each panel is a surface of its own, so
// what it holds needs no border.
export default example({
  title: 'A tray of panels',
  slots: FrameSlots,
  recipe: Recipes.Frame,
  view: ({ style, h }) =>
    Frame.view(
      {
        title: 'Deployments',
        description: 'Everything shipped this week.',
        action: Button.view({ label: 'View all', style: Quiet }, h),
        panels: [
          h.p([], ['Production, from main, 4 minutes ago']),
          h.p([], ['Preview, from the billing branch, yesterday']),
          h.p([], ['Production, from main, 2 days ago']),
        ],
        footer: h.span([], ['Updated just now']),
        style,
      },
      h,
    ),
})

In your application: recipe goes to forSlots, and the body of view is the call. example is this site’s harness.

Alerts in a frame #

Needs attention

Your card expires next month

The last backup failed

Retry it now.

import { Alert, Frame, FrameSlots, Recipes } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

const Notice = Recipes.Alert.style({ tone: 'warning' })
const Failure = Recipes.Alert.style({ tone: 'danger' })

// Composition: the frame places what it is given and understands none of it.
// Each Alert is drawn by its own widget, in its own tone.
export default example({
  title: 'Alerts in a frame',
  slots: FrameSlots,
  recipe: Recipes.Frame,
  pins: { variant: 'outline', padding: 'none' },
  view: ({ style, h }) =>
    Frame.view(
      {
        title: 'Needs attention',
        panels: [
          Alert.view({ layout: 'inline', title: 'Your card expires next month', style: Notice }, h),
          Alert.view(
            {
              layout: 'inline',
              title: 'The last backup failed',
              description: 'Retry it now.',
              style: Failure,
            },
            h,
          ),
        ],
        style,
      },
      h,
    ),
})

In your application: recipe goes to forSlots, and the body of view is the call. example is this site’s harness.

Rows in a frame #

Team

Ada Lovelace
Engineer
Grace Hopper
Engineer
Alan Turing
Engineer
import { Frame, FrameSlots, Item, Recipes } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

const Row = Recipes.Item.style({ density: 'compact' })

// One Item to a panel: the panel is the surface, the Item the row.
export default example({
  title: 'Rows in a frame',
  slots: FrameSlots,
  recipe: Recipes.Frame,
  pins: { padding: 'none' },
  view: ({ style, h }) =>
    Frame.view(
      {
        title: 'Team',
        panels: ['Ada Lovelace', 'Grace Hopper', 'Alan Turing'].map(name =>
          Item.view({ title: name, description: 'Engineer', style: Row }, h),
        ),
        style,
      },
      h,
    ),
})

In your application: recipe goes to forSlots, and the body of view is the call. example is this site’s harness.

Configure once #

Compact

One

Two

Roomy

One

Two

import { Frame, FrameSlots, Recipes } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

// Stated once, at module scope: the look every frame of the application
// starts from, and a named preset over it.
const Tray = Recipes.Frame.style({ spacing: 'compact' })
const Roomy = Recipes.Frame.style({ spacing: 'roomy', variant: 'outline' })

const AppFrame = Frame.configure({
  base: { style: Tray, headingLevel: 4 },
  presets: { roomy: { style: Roomy } },
})

export default example({
  title: 'Configure once',
  slots: FrameSlots,
  recipe: Recipes.Frame,
  view: ({ h }) =>
    h.div(
      [],
      [
        AppFrame.view({ title: 'Compact', panels: [h.p([], ['One']), h.p([], ['Two'])] }, h),
        AppFrame.view(
          { title: 'Roomy', panels: [h.p([], ['One']), h.p([], ['Two'])], preset: 'roomy' },
          h,
        ),
      ],
    ),
})

In your application: recipe goes to forSlots, and the body of view is the call. example is this site’s harness.

Usage

Each example above is a module of its own, shown whole and run as shown, over the theme module Create a theme writes. The page hands it the style picked above.

The recipe ↗This code ↗