Live values
A reading bar for the studio's story
Scroll through how the Lagoon glaze is made, and a bar along the top fills as you read, the minutes left beside it.
Two glazes, one kiln
Every Lagoon Vase starts as a plain stoneware body, thrown on the wheel and left to dry for a week under a loose sheet of plastic, so its walls dry evenly and nothing cracks at the rim.
It gets two glazes, not one. The first is a pale celadon that we dip; the second, a deep cobalt blue, is poured over it from the shoulder down while the vase turns slowly on a banding wheel.
Letting the heat decide
At 1,280 degrees both glazes melt. The cobalt is heavier and runs down through the celadon, carrying it with it in streaks, and where the two meet they mix into the greens the vase is named for.
We can choose how thick each coat is and where the pour starts, but not where the glazes go after that. The kiln decides. That's why no two vases are alike, and why we open the kiln slowly.
A firing takes eleven hours to climb and two days to cool. Opened too soon, the glaze crazes: fine cracks run through it as it cools faster than the clay beneath.
Choosing the ones that stay
Not every firing gives us vases we sell. A glaze that ran too far pools at the foot and fuses the vase to its shelf; one that ran too little stays a flat, even blue. We keep the ones in between.
Each of those is checked for pinholes, sanded at the foot, and filled with water overnight to be sure it holds. Then it's photographed on the same white sheet as every other piece in the shop.
Looking after one
The glaze is glass, so it's watertight and wipes clean. Wash it by hand in warm water; a dishwasher's detergent dulls the surface over the years.
If you want to see the runs at their best, put it where light comes from the side: the thicker streaks catch it, and the thin ones let the pale glaze through.
Reduced motion: Nothing changes: the bar is where the scroll is, not an animation of its own.
Why
A long read is easier to start when you can see how long it is, and easier to finish when you can see how far you've come. A bar that fills as you scroll says both at a glance, and the minutes left say it in words.
createScroll gives the panel's scroll as live values: how far it's scrolled, and the progress through its range, from 0 to 1, set within the scroll's own event. The bar takes the progress as its scaleX, drawn from its left edge, and follows the scroll frame by frame. createTransform maps the same progress to the minutes left. Leave out container, and it's the page's scroll.
The code
On Foldkit the panel's Mount asks Wardic.scroll({ container }) for the panel's progress, on the Handle's Features.scroll, and feeds an Atom at module scope that the bar binds in w.Style; the minutes left are Atom.map of the same progress, bound in w.Text.
import { LAGOON_ARTICLE } from "@wardic/example-storefront-shared/stories"
import * as Effect from "effect/Effect"
import * as Atom from "effect/reactivity/Atom"
import * as Schema from "effect/Schema"
import { defineMessageUnion } from "foldkit/message"
import * as Mount from "foldkit/mount"
import { defineView } from "foldkit/submodel"
import { feed, onWardic, scroll } from "~/lib/live.ts"
import { wardic } from "~/lib/wardic.ts"
import { definePage, type PageEnv } from "~/page.ts"
// The Live values, Atoms at module scope (ADR-0071, decision 16): how far the article's panel is
// scrolled, from 0 to 1, which the panel's Mount feeds and the bar binds; and the minutes left, read
// from the same progress, which the head's text binds.
const progress = Atom.make(0)
const minutesLeft = Atom.map(progress, (at) => `${Math.ceil(LAGOON_ARTICLE.minutes * (1 - at))} min left`)
const Data = Schema.Struct({})
const Model = Schema.Struct({})
type Model = typeof Model.Type
const Message = defineMessageUnion({ Reading: {} })
type Message = typeof Message.Type
/**
* The panel's Mount: its scroll as Live values (`Wardic.scroll`), set within the scroll's own
* event, held while the panel is on the page. Leave out `container`, and it's the page's scroll.
*/
const Read = Mount.define("ReadingScroll", {
messages: [Message.Reading],
execute: ({ element }) =>
onWardic(
Effect.gen(function* () {
const { scrollYProgress } = yield* scroll({ container: element })
yield* feed(scrollYProgress, progress)
return Message.Reading()
}),
),
})
const view = defineView<Model, Message, PageEnv>((_model, _env, h) => {
const w = wardic.html(h)
return h.div([h.Class("reading")], [
h.div([h.Class("reading-head")], [h.strong([], [LAGOON_ARTICLE.title]), w.span([h.Class("muted"), h.AriaLive("polite"), w.Text(minutesLeft)])]),
// The bar is the scroll itself, scaled across from its left edge: no animation of its own.
w.div([h.Class("reading-bar"), w.Style({ scaleX: progress })]),
h.div(
[h.Class("reading-panel"), h.OnMount(Read()), h.Tabindex(0), h.AriaLabel(LAGOON_ARTICLE.title)],
LAGOON_ARTICLE.sections.map((section) => h.section([], [h.h3([], [section.heading]), ...section.paragraphs.map((paragraph) => h.p([], [paragraph]))])),
),
])
})
export default definePage({
id: "reading-progress",
Data,
Model,
Message,
load: Effect.succeed({}),
init: (): Model => ({}),
update: (model, message) => Message.match(message, { Reading: () => ({ model }) }),
view,
})