Components

Marquee

Content that scrolls on without a seam, held by a pointer, by focus or by its press.

Previews are drawn in the theme you made.

Edit it
spacing
edges
scheme
direction

Basic #

Acme
Globex
Initech
Umbrella
Hooli
Stark
Acme
Globex
Initech
Umbrella
Hooli
Stark
import { Bundles, Marquee, MarqueeSlots, Recipes } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

const CUSTOMERS = ['Acme', 'Globex', 'Initech', 'Umbrella', 'Hooli', 'Stark']

// What it measured and whether it is paused are the marquee's Model, placed by
// `Bundles.Marquee`. It draws as many copies as fill the strip, pauses under
// the pointer or focus, and keeps a press to pause it for good.
export default example({
  title: 'Basic',
  slots: MarqueeSlots,
  recipe: Recipes.Marquee,
  state: Bundles.Marquee.with({ id: 'customers' }),
  view: ({ style, model, onMessage, h }) =>
    Marquee.view(
      {
        model,
        onMessage,
        label: 'Our customers',
        items: CUSTOMERS.map(name => h.strong([], [name])),
        speed: 40,
        style,
      },
      h,
    ),
})

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

The other way #

#design
#effect
#foldkit
#typescript
#accessibility
#css
#design
#effect
#foldkit
#typescript
#accessibility
#css
import { Bundles, Marquee, MarqueeSlots, Recipes } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

const TAGS = ['#design', '#effect', '#foldkit', '#typescript', '#accessibility', '#css']

// `side: 'end'` moves toward the inline end, rightward left to right; under
// `dir="rtl"` both sides turn with the page.
export default example({
  title: 'The other way',
  slots: MarqueeSlots,
  recipe: Recipes.Marquee,
  state: Bundles.Marquee.with({ id: 'tags' }),
  view: ({ style, model, onMessage, h }) =>
    Marquee.view(
      {
        model,
        onMessage,
        label: 'Trending topics',
        items: TAGS.map(tag => h.span([], [tag])),
        side: 'end',
        speed: 30,
        style,
      },
      h,
    ),
})

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

Vertical #

Release 1.2 is out
New docs site
Meetup on Friday
Release 1.2 is out
New docs site
Meetup on Friday
import { Style } from 'foldkit-mixins'
import { Bundles, Marquee, MarqueeSlots, Recipes } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

// Upright, a marquee is as tall as you make it: `extend` gives the root a
// height, and `side: 'top'` moves the lines up.
const Tall = Recipes.Marquee.extend({ base: { root: Style.self({ blockSize: '8rem' }) } })

export default example({
  title: 'Vertical',
  slots: MarqueeSlots,
  recipe: Tall,
  state: Bundles.Marquee.with({ id: 'news' }),
  view: ({ style, model, onMessage, h }) =>
    Marquee.view(
      {
        model,
        onMessage,
        label: 'Latest news',
        items: ['Release 1.2 is out', 'New docs site', 'Meetup on Friday'].map(line =>
          h.span([], [line]),
        ),
        side: 'top',
        speed: 20,
        style,
      },
      h,
    ),
})

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

Starts paused #

Northwind
Contoso
Fabrikam
Tailspin
Woodgrove
Northwind
Contoso
Fabrikam
Tailspin
Woodgrove
import { Bundles, Marquee, MarqueeSlots, Recipes } from 'foldkit-mixins-ui'
import { example } from '../../gallery/example.js'

const SPONSORS = ['Northwind', 'Contoso', 'Fabrikam', 'Tailspin', 'Woodgrove']

// `paused: true` places it held, until a reader presses play; `words` names
// the press. `delay` waits before the first move once it plays, and
// `loopCount` stops it after three rounds.
export default example({
  title: 'Starts paused',
  slots: MarqueeSlots,
  recipe: Recipes.Marquee,
  state: Bundles.Marquee.with({ id: 'sponsors', paused: true }),
  view: ({ style, model, onMessage, h }) =>
    Marquee.view(
      {
        model,
        onMessage,
        label: 'Sponsors',
        items: SPONSORS.map(name => h.strong([], [name])),
        delay: 1,
        loopCount: 3,
        words: { pause: 'Hold the sponsors', play: 'Run the sponsors' },
        style,
      },
      h,
    ),
})

In your application: recipe goes to forSlots, state to Bundle.withChild, 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 ↗