Repository navigation
Idea: a hooks-first API for Solid 2, apart from Motion's conventions #966
Replies: 3 comments
|
Update, 2026-11-25. I've rewritten the post above with where the prototype is now. The ideas kept their numbers. What changed since the first version:
Three questions I'd most like an answer to, all new, at the end of the post:
A short answer to any one of them helps. So does "I'd never use this". |
|
Update, 2026-11-26. Two things since the last one: a rename, and one more thing built. The post above has both. A part is a rune now, and A rune can carry behaviour as well as motion (idea 4c). It takes a const closesOnEscape = (close: () => void) =>
createRune({
ref: (subject) => {
const onKey = (event: KeyboardEvent) => {
if (event.key !== "Escape") return
event.preventDefault()
close()
}
subject.addEventListener("keydown", onKey)
return () => subject.removeEventListener("keydown", onKey)
},
})
const panel = createWard({ show: open }, rise, closesOnEscape(close))
Two questions I'd most like a view on now. Question 7: does |
|
Update, 2026-12-01. The post above has all of this, each under its idea. The short version: a drag's behaviour is a rune now, and the API has a rule it's held to. What a drag does is a rune (idea 4e). A function rune's ward hands it the ward's drag, const sortable = (value: string) =>
createRune((ward) => {
const [held, setHeld] = createSignal(false)
const mine = ward.drag.measured()
ward.drag.onSample((sample) => {
if (sample.phase === "start") setHeld(true)
if (sample.phase === "end") setHeld(false)
// …past a neighbour's middle, it takes its place
})
return { layout: true, drag: "y", lifted: held }
})
const rows = createWards(order, (row) => sortable(row.item))Wardic's own Reorder is one such behaviour, Grips (idea 4f): A rune that carries an API (idea 4g). A hook of yours can hand back one value that's both a rune and something to call, the way const carousel = createCarousel(slides.length) // yours: createRuneWith(rune, { next, prev, index })
const track = createWard({ drag: "x" }, carousel) // a rune, beside your own
<button onClick={carousel.next}>Next</button> // and its APIThe rule (a new section above the ideas): ward and rune are the language; capabilities ship as runes; utilities are built from both. The ward and the rune stay small and mean the same in every Environment. A utility is built from them alone, as you'd build it: on the branch, Measured. The hooks' ward is now the ward itself, and on its own it's as fast as today's. But the hooks' first chunk is 7.9% over today's for the same fade. On the branch, an app still on today's API is 19.0 KB bigger than on Three questions I'd most like a view on now. Question 12: would you write a drag's behaviour yourself, and is |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Wardic's Solid API today is Motion for React's:
w.divwith motion props, variants that pass down the tree,<AnimatePresence>, and a<WardicProvider>at the root.This is an idea for writing Wardic on Solid 2 with hooks. A ward is spread on a plain element, and everything else (following, entering and leaving, lists, layout, dragging) is a key of its config or a small hook. There is no provider, and nothing to set up: you import
createWardand call it. The few components left (w.<tag>,<Presence>for what its author doesn't take away themselves,<Reorder.*>) are utilities written from the same hooks you'd use, nothing more.Where I'd like it to go: if this holds up, hooks become the way to write Wardic on Solid 2, and the component API is phased out over time. A developer shouldn't need to learn Wardic's components, Features or providers to animate something. Nothing is being removed now, and that direction is part of what I'm asking about.
It departs from Motion's conventions on purpose. Motion's API is shaped by React's tree and re-renders. Solid has signals and hooks that own state, and I think Wardic can read more plainly on Solid if it's allowed to stop following Motion there. I'd like to know whether you agree before any of it ships.
The point is composition. Motion becomes plain values, runes, that you join into one element's ward, and behaviour becomes small hooks you build bigger ones from, the way you already compose signals and memos. The example below is the whole idea on one page.
I've prototyped it on a throwaway branch, and all 36 of the storefront's non-3D examples now run on it. Nothing here is decided, and every name is open.
What it looks like
A shop: products that grow in, lift under the pointer and zoom their photo, a filter that takes some of them out, and a details panel for the one you pick.
What composes here:
createRuneso it's typed, completed and checked where it's written, not where a ward takes it.fadeIn,growandriseeach say something about entering; joined, they're one entrance, theirinitialandanimatemerged key by key.lift,press,tilt(6)andspring(400)add how the card answers the pointer, and the last part how it moves in a list. All eight are one ward, on one<li>, and no wrapper component holds them.tiltis a function of the ward it's part of. It's handed that ward, listens to its hover, keeps its own state, and what it returns joins the ward's config. Whoever uses it writestilt(6)and knows none of that.fadeInandriseagain, on a slower spring. A rune with a setting is a function that returns one.createZoommakes a ward for it and reads the card's hover through a sensor. It knows nothing about cards or shops: give it any ward.createShopiscreateWards,createWard,createPresenceand a signal. It returns what the markup needs, and can be typed, tested and reused with nothing rendered.w.*, no<AnimatePresence>, no provider, and no Feature is listed: hover, press and layout arrive because the configs use them.The same page today needs a
<WardicProvider>at the root with its Features, an<AnimatePresence mode="popLayout">around the list and another withmode="wait"around the details, and the motion written as props onw.li,w.imgandw.aside, where sharing it means wrapping components.This example is on the branch as a test, so it compiles and renders on a server as printed. Each mechanism in it also runs in the storefront's converted examples; the page as a whole hasn't been run in a browser.
What I'm asking
The ideas are numbered so a reply can name one.
At a glance
<WardicProvider env={…}>around the app, and a list of FeaturescreateWardand call itcreateWardic(features)forwmakeWard, only for a page that says more<w.div animate={…} />const card = createWard({ animate: … }), then<div {...card} />refof its own, written beside the motionref: handed its Subject while it's on show, and listed among the runes that move itrole,tabindexandaria-attributes written on the element, beside the motion propsprops: its element's attributes, set through the ward's spreadReorder.Item), oronDrag*callbacks you wire upward.dragdragControlsanddragListener={false}for a handlecreateGrip(row): the element a row is dragged bycreateRuneWith(rune, api): one value that's a rune and an APIvariantsfollows its parent in the treefollow: leader, said where the ward is madetransition: { staggerChildren, delayChildren, staggerDirection, when }followers: { stagger, delay, from, order }<AnimatePresence>around a conditional child, withexitshow: openon the wardexitmeans it's removed at onceexit, it leaves the way it camemode="popLayout",anchorX,anchorYpop: true, orpop: "bottom-right"<AnimatePresence>around a list, or a router's outletcreateWards(list, …), orcreateWards({ value }, …)<AnimatePresence mode="wait">around a keyed childcreatePresence(ward, value)onExitComplete, or a presence handle'sexiting()ward.exiting(),ward.next("exitComplete")<AnimatePresence>around what you don't take away yourself (a router's page, children)<Presence pop>,<Presence wait><AnimatePresence custom>, for a leaving child that takes no new propscustom: it's still there as it leaves<AnimatePresence propagate>, for a list inside a dialogfollow: the list's wards follow the dialog'sw.create(Component)around a component library's partReorder.GroupandReorder.ItemcreateReorder({ each, onReorder }): the list a rune, each row's drag a behaviour (list.item)<AnimatePresence initial={false}>initial: falseon a list,enter: falseon a wardcreateXhook that owns the motion and its stateonHoverStartandonHoverEndinto statecreateHover(card), a sensor given the wardisPending(() => card.settled())for "is it animating"card.animating(),card.hovering()and the rest, on the ward<LazyWardic features={() => import(…)}>card.when("ready")says when it has comeuseAnimationFrame, motion valuesframekey on the ward (not built)layoutId,<LayoutGroup>layoutward that flies between elements (not built)The rule
What holds the ideas together, and what a new one is judged against:
w.<tag>overcreateWard,<Presence>over its presence scope,<Reorder.*>overcreateReorder.<Show>hides it, the server's count,touch-action, its keys and focus are traps you'd fall into writing your own.So the question for any new idea is the same: can it be built from the public ward and rune? Then it's a utility, and Wardic builds it that way. If its hard parts are an Environment's, it's a capability rune.
The ideas
1. Nothing to set up
No provider, no instance, no list of Features. The page runs in the browser's own Environment, and each ward brings the Features its config uses:
whileHoverbrings hover,dragbrings drag, a layout prop brings layout. Each Feature is a chunk of its own, fetched the first time a ward on the page uses it, so a page ships the code of what it uses. A server render has them all at once.The names follow Solid's:
create*is called in a component, besidecreateSignalandcreateMemo.Built. All but one of the storefront's converted examples import the hooks and nothing else; the one names a Feature as a load of its own, to show holding one back. Two costs, both measured or known:
A gesture's Feature arrives a moment after the page opens, and the gesture does nothing until it has. Entrances need no Feature. How long that moment is hasn't been measured. A ward says when it's over, through the
nextandwhenit already has for its other events:"ready"happens once, so it's kept: asked for after it, it's there at once.It needed three small module splits in dom and core, done on the branch: code that only a Feature uses sat in modules every app imports, so it rode along in the first chunk. With them, listing nothing costs what listing your Features does today (125.7 KB gzip against 125.6). They also make today's lazy-routed apps 0.6 KB smaller.
2.
makeWard, only for a page that says moreOne call, in a module, returns the same hooks. It's for a test's Environment, a setting a provider took, or an app that wants its Features in its own bundle with nothing fetched later. Given
elements, it returnswtoo, for an app still renderingw.*.Built.
3.
createWard, spread on a plain elementA kept ward exists today (
w.ward(config)). On the branch, whatcreateWardreturns is that ward itself: one ward, the hooks' reads on the same shared members every ward has.w.<tag>is still there, as a utility that makes its element's ward withcreateWard, for an app that would rather write motion as props.Built, and timed against today's on 2026-11-28, before behaviours (4e) were added: one ward mounts 2 to 3% faster and retargets within 5%, and a list of rows enters 2 to 4.5% and leaves about 10% faster than the same list under
<AnimatePresence>.Departs from Motion: no
motion.div. The element is yours, and the ward is a value you can pass around, read (card.read("x")) and listen to (card.when("dragEnd")).4. Runes
A ward is made of runes: it takes any number of configs, and joins them. (They were called parts, and the function
createPart, until 2026-11-26.)A later rune wins a key. Targets,
transition,styleand each variant merge their keys, so two runes can add to the same variant.createRune(config)hands back the config itself and does nothing else. It's there for the types: a rune kept in a constant is completed and checked where it's written, a misspelt key is an error there, andtype: "spring"needs noas const. A rune written in the ward's own call ({ follow: grid }above) is checked by that call, and a plain object is still a part.A rune that needs its ward is
createRune((ward) => config), which works as a plugin does: it's handed the ward it's part of, can listen to it (ward.when("hover")), read it and give it to a sensor, and what it returns joins the ward's config. Its function is a hook's body, run once for each ward that takes the part, so it's where a rune keeps signals and effects of its own. It can't add members to the ward. A hook of yours that hands back a rune with something to call beside it makes one value of both withcreateRuneWith(4g).A rune is fixed once it's made. What changes is an accessor or a store in it, and what depends on the ward is a function rune. Its keys are the ones it was made with.
Departs from Motion: Motion has no such thing; you spread prop objects, and a later object replaces an earlier one's
variantswhole.Built. A few examples join two runes: a
showbeside a shared fade, or a banner's line with a hover and a press added. One uses a function rune: the spotlight card's turn toward the pointer.4b. A rune's keys: Wardic's own, and each Environment's
A rune's keys are of two kinds, and its types now say which.
initial,animate,exit,variants,transition,custom,inherit;whileHover,whileTap,whileFocus,whileInView,whileDrag;show,enter,follow,followers.style,layoutandlayoutId,pop,viewport,dragand how it's set. A scene: its owndrag(it has az), and its Subject. A scene takes Wardic's keys too, except the four it has nothing for:whileFocus,whileInView,followandfollowers.A rune's type is the keys it has and no others, so a rune made of Wardic's keys alone fits a ward on the page and a ward in a scene, and a key a ward doesn't take is an error where the rune is given. (
scenebelow is the hooks a Stage hands out: see 18 and Other Environments.)Nothing marks a rune as the page's or a scene's, and there's no third
createRunefor runes meant to travel: the ward that's given a rune checks the keys in it. A list checks its rows' runes the same way (createWards, a scene's too, andcreateReorder), including what a function of the row gives.Departs from Motion: Motion's props are one set, and nothing in a prop's name or type says whether it's about the motion or about the element.
The values a target names are each Environment's too. In a scene,
animatenames what that scene's Subject takes, and nothing of the page's. A ward that has its Subject is checked by that Subject's own values, so a light can't name a material's:A rune meant for both names what both animate (
x,y,scale,opacity), and what a value means stays yours to know: a page'syis in pixels, a scene's in its own units. The package that brings an Environment says what its Subjects take; three.js is the one that does so far.Built, in the types only. Nothing runs differently. One cost: a helper that's generic in the rune it passes on (
<R extends Rune>(rune: R) => createWard(rune)) no longer compiles, since a ward can't check keys it doesn't know yet. A helper that takes aRuneis fine. Another: the checker does three to five times the work for each ward that it did before the values were checked. Whether that shows in how long a check takes is still to be measured on a quiet machine.4c. A rune's
ref: what it does to its SubjectA rune carries behaviour as well as motion, through a
ref: a function handed the thing its ward animates (its Subject), which returns whatever undoes it.refruns, in the order the runes are listed, and so does one you write on the element yourself.refis the half for each Subject.refisn't: a signal read inside it is read once, and Solid warns about that read the same way.refwritten for an element is a type error there.One thing to know when listening: a listener a
refadds to its Subject hears a click, a key or a pointer event before any handler written in the markup, on that element or inside it, because Solid hears those from the root. So it takes an event withpreventDefault(), which those handlers can then see, and never withstopPropagation().Departs from Solid: Solid's own
refruns before the element is in the page and can't clean up after itself. This one runs after, and returns its cleanup.Built. Three of the storefront's examples each had the same seven lines listening for Escape; they share one rune now. A drag's samples, which drag-to-reorder written as a rune once had to reach for in private, are a behaviour's now (4e).
4d. A rune's
props: what it sets on its SubjectA rune can say what its element is as well as how it moves, through
props: its attributes, set through the same spread that carries the ward'srefandstyle.role,tabindex,id, eacharia-attribute, and anydata-one. A misspelt name is an error where it's written.falseandundefinedleave the attribute off.aria-attributes that are lists of ids (aria-describedbyand five more), which join: one rune describing an element doesn't remove another's description.Three things it refuses, each with an error that says what to do instead:
onClick). In a spread, your own handler of the same name would replace it, or be replaced, silently. A rune listens in itsref.class. A spread'sclassreplaces the element's own, so the first rune with a class would wipeclass="card". A rune marks a state with adata-attribute, which a stylesheet or Tailwind reads as it is.styleandref, which stay a rune's own keys: the ward animates one and runs the other.A scene has no
props: its Subject is your own object, with no markup to spread into.Departs from Motion, which has no place for this: attributes sit on the component beside the motion props, and travel with nothing.
Built. The cart drawer's ward takes one rune,
modal(close), for what it's said to be and for closing on Escape, where its markup wrote the attributes and a hook listened. It fits two dialogs of the storefront's three. In the third the dialog's ward follows the thing that comes and goes and has no end of its own, so each half goes on its own ward.4e. A behaviour: a rune that drives a drag
A function rune's ward hands it the ward's drag,
ward.drag, so what a drag does is a rune too:onSample(fn): each of the drag's samples, a start, its moves and an end, with its point, its offset, its step and its velocity. An end says how it ended,endedBy: let go, taken away by the page (apointercancel, a touch the page scrolled by, which no longer flings), or lost.onKey(fn, { describedBy }),onBlur(fn),onPress(fn): what a keyboard reorder listens to. GivendescribedBy, the ward becomes a tab stop described by it.measured(): its box as the layout measures it, its offset while dragged, and a version that moves with each new measure.lifted, a key beside them: raised above its neighbours until it lands, for anylayoutward.Behaviour and animation are separate runes that meet at that plain contract. Wardic's reorder is one behaviour (
list.item, 11e), and one of yours can take its place, written with anything you like. Readingward.dragbrings the drag Feature, asdragin a config does, and a listener ends with its rune's owner.Departs from Motion, where what a drag does belongs to a component (
Reorder.Item), or to callbacks you wire up beside it.Built, with the reorder above as a test, and Wardic's own Reorder rebuilt as a behaviour. Timed against today's
Reorder.Item, its rows mount 13.5% faster at 100 items, at par at 50, and 11% slower at 1,000, with 10% more memory a row. A behaviour of your own costs a row about 0.5 KB more than Wardic's, which takes a shortcut its behaviour can promise: it reads nothing but its drag.4f. Grips: the element a row is dragged by
touch-action, and the row's goes.<Reorder.Grip>is the same thing as a utility, found through its item.Departs from Motion, which starts a drag from elsewhere imperatively, with
dragControlsanddragListener={false}. A grip is a rune: there are no controls to make and pass around.Built, in the wishlist. It's the first capability rune (The rule): what it does is the page's, and each trap in it is Wardic's to get right, not yours. Those are a grip a
<Show>hides, which tells itsrefnothing; the server's count;touch-action; and the focus after a keyboard move.4g.
createRuneWith: a rune that carries an APIcreateRune(fn)).animate) is refused.createReorder's list is made this way: the group's rune, withitembeside it.Departs from Motion, which has nothing like it. It's what gives a utility of yours the shape Wardic's own have.
Built.
5.
follow: following is said, not inheritedA follower takes its leader's variant names for every prop it doesn't set itself. It doesn't matter where either is rendered.
Departs from Motion, twice:
variantsfollows the nearest ancestor that has them. Here it's a key.whileTap="pressed", say) silently stops following and loses its stagger slot. Here its own props are its own, and the rest still come from its leader.Built, with one limit: a follower's own name doesn't pass on to followers of its own.
6.
followers: the timing of a groupstaggerChildren: 0.06stagger: 0.06delayChildren: 0.1delay: 0.1staggerDirection: -1from: "last"when: "beforeChildren"order: "leader-first"when: "afterChildren"order: "followers-first"Departs from Motion: the timing has its own key, where Motion puts it inside the parent's
transition. Motion's keys still work.Built. A staggered group still plays from the server's CSS, before the JavaScript loads.
7.
show: a ward enters and leaves by itselfWhile
saved()is true it's shown. When it turns false, the ward animates to itsexitand then setsdisplay: none. The ward stays alive throughout, so turningsavedback on mid-exit just turns it round.toast.mounted()stays true until the exit has landed, for a<Show when={toast.mounted()}>that takes the element off the page instead.toast.shown()is false from the moment it starts to leave.Departs from Motion: no
<AnimatePresence>. Presence belongs to the ward, not to a parent that holds a removed node.Built, with one rule I didn't expect:
showdoesn't suit a layout element (layout,layoutId). A hidden element measures as an empty box at the page's corner, and slides from there when it's shown again. A layout element that comes and goes should be idea 10 or 11, which make a new element each time.8. With no
exit, it leaves the way it cameUnder
show,exitdefaults toinitial.exit: falseleaves at once.Departs from Motion, where no
exitmeans removed at once. Most enter and exit pairs mirror each other, so the common case loses a prop.Built.
9.
popA leaving ward is taken out of the flow where it is, so what's after it moves up at once.
truepins it by its top left. A corner's name pins it by that corner, for a container that resizes as it goes.Departs from Motion: one key on the thing that leaves, where Motion has
mode="popLayout",anchorXandanchorYon the presence.Built.
10.
createWards: a ward for each item of a listAn item that leaves the list stays in
rows()until its exit has landed. Each row hasitemandindex(). The first argument is the list, or{ each, key, initial }. What follows are runes, a description of the motion, listed one after another (a spread is for putting a ward on an element), and the hook makes a ward from them for each row: a list has many on the page at once, so there's no one ward to give it.One value is a list too:
createWards({ value }, …)gives a row for the value now and one for the value it replaced, until that has gone. Both are on the page at once, which is how a page turns under a router:The leaving page is popped out of the flow, the next is in place at once, and a
layoutIdthe two share flies between them. The wards are the layout's, since a navigation ends everything the leaving page made, and each page's root is its ward's Subject (subject): the layout moves an element it didn't render, with nothing wrapped around it. A Stage's rows take their Subject the same way.Two limits come with a Subject on the page: it's one element, and a server can't give it a starting style, so what's there as the page opens has no entrance.
subjectisn't the router's. It's for any element you move and didn't render: a component that takes one child and adds motion to it, with no wrapper.The storefront has one of each: tiles that lift, a gift note that folds away, a delivery estimate that changes.
Departs from Motion: no
<AnimatePresence>around the list or the outlet, and nomode. Two things on the page at once are rows (withpop, Motion'spopLayout; without,sync); one after the other iscreatePresence(wait).Built, in nine examples.
11.
createPresence: one thing at a timeThe motion is a ward, made by
createWardas any other, andcreatePresenceis given it, as a sensor is. You spread the ward you made, andshown()is the value on the page: the last one until it has left, then the new one. A value ofundefined,nullorfalseshows nothing, socreatePresence(answer, open)is also one optional thing that comes and goes, with a new element each time.Departs from Motion: this is
mode="wait"around a keyed child, as a hook of its own.It's one ward throughout: it leaves with the last value and comes back on the next one's element, entering from its
initial. So anything made on it carries across values:createHover(panel)reads whichever panel is on the page, andpanel.when("settled")hears each one land.A group leaves together when the presence is given the ward the others follow. In the storefront's product view, the presence's ward is the view's frame, which only names its states; the backdrop and the text follow it and fade by those names, and the view stays until they've gone.
layoutIdtwins inside a leaving ward are handed to their others as it starts to leave, so the card's photo flies home while the view fades around it.Built, in six examples.
The ward hears its own exit. It's made where the element's owner is, so it outlives the element, which a component's ward can't:
exiting()is true from the moment it starts to leave until it has gone."exitStart"and"exitComplete"come through thenext,eachandwhena ward already has for its landings and gestures. An exit it turns round from doesn't complete; one with nowhere to leave to completes at once. The same on ashowward and on a list's row.Built.
The name is taken today:
@wardic/solidhas acreatePresence()that hears an<AnimatePresence>'s exits. With a ward hearing its own, this hook keeps the name, and that handle is only for the boundary'sref(below):createPresenceRef().11b.
<Presence>: one boundary, for what you don't take away yourselfA hook covers a thing whose coming and going you write. A router's page isn't that: a navigation ends the page and everything it made, so nothing inside it can keep it on the page. Children handed to your component, and another library's component, are the same. For those there's one component, around them:
popandwaitare the hooks' words for the same two things; with neither, a child enters beside the one leaving.enter={false}is a ward'senter: false, said for everything inside. Its exits are heard through itsref:Same idea as Motion's
<AnimatePresence>, which it is underneath, withpopandwaitformode. Solid draws the same line: its values arecreate*hooks, and its boundaries are components (<Show>,<Loading>,<Errored>).Built, in one example (the catalogue's two routes).
11c.
customandpropagatehave nothing to doBoth are props of a presence, and both work round something a hook's ward doesn't have.
A presence takes
custombecause a child that has left can't be handed anything new: the presence passes the leaving slide the way you went. A slide's ward here is the hook's, still there while its slide leaves, so both slides read the one accessor:A ward that's leaving keeps the
customit left with, as a presence's child does, so a change of direction mid-slide doesn't turn it back.A nested presence takes
propagateso a list inside a dialog runs its exits as the dialog leaves, and the dialog waits. Here the list's wards follow the dialog's ward, and that's all of it:Built, in two examples (the gallery, and the quick view).
11d. A component library's parts need nothing
Today a third-party component takes motion through a wrapper,
const Guide = w.create(Dialog.Content). A ward is arefand astyle, and a library's part hands both on to the element it renders, so a ward is spread on the part as on an element:The library still moves the focus in and back, keeps Tab inside and closes on Escape;
forceMountandcreatePresencekeep its parts on the page while they leave.Built, in three examples (Kobalte's dialog, select and tabs).
11e.
createReorder: a list its visitor reordersThe list is yours:
eachis its order, andonReorderis handed the new one as an item is dragged past another or moved from the keyboard. What comes back is the group, which is a rune: spread it on the list's element alone, or give it to a ward beside your own (createWard(fade, list)). The rows are plaincreateWardsrows, andlist.item(value)is the behaviour (4e) that makes a row one of the group's: its drag, its keys, its place in the list. The group still hasmove(item, toIndex)and itsholdStart,reorderEndandholdEnd, heard throughnext,eachandwhen, and akeyfor an app that makes its items again.In the storefront's wishlist a row is four runes beside its behaviour, and it's dragged by its grip (4f):
Same idea as today's
reorderGroupandreorderItem, which this is built on, with the drag's part made a rune you could replace. A row that leaves the list leaves by its exit, with no<AnimatePresence>round it.<Reorder.Group>,<Reorder.Item>and<Reorder.Grip>are utilities over it, and today's Reorder tests pass on them.Built, in one example (the shared wishlist).
12. No entrance for what's there as the page opens
What's there as the page opens has no entrance, and what comes later does. A list says it for its rows, since it makes them. One ward says it of itself, with
enter: false, whether it comes and goes byshowor by a presence: a ward decides how it starts as it's made, and its presence is made after it.Same idea as Motion's
<AnimatePresence initial={false}>, moved to the hook and the ward. Two names for it here,initial: falseandenter: false, which is one too many: see the open questions.Built.
13.
createX: a hook that owns the motion and its stateThis is the point of the whole idea, and what the example at the top shows on one page. The motion, its state and its gestures live in one hook, and the component under it is markup. Every converted example is written this way, and
createWardreads as one more primitive inside it.Two patterns came out of writing them:
grid.card(),reveal.piece()).reftakes its props fromward.with({ ref }).createShop(shown)withshownacreateMemoover the filter, or a row'screateMemo(() => open() === order.id). The list is then worked out once a change, and a row hears its own turn and not every other row's.Departs from Motion, where motion lives in a component's props.
14. Gesture state through a sensor
Where a hook needs a gesture as state, it reads a sensor given the ward:
createHover,createPress,createDrag.card.when("dragEnd")stays for what needs the event itself.Exists today. The idea is to make it the rule. Two gaps: no sensor gives a Batch's hovered member, or a Reorder group's held item.
15. State reads on the ward
hovering(),pressing(),dragging(),viewing(),focusing()andanimating(). Each gesture's is what its sensor reads when it's given the ward, reached from the ward;animating()replacesisPending(() => card.settled()), which nobody would guess. The sensors of idea 14 stay, for an element with no ward and for a drag's samples.Nothing is made until one is read: the first read makes its signal, listens to the ward's own events, and asks for its gesture's Feature, so a ward that never reads
hovering()fetches nothing for it. On a server each isfalse.A function rune reads them of the ward it's handed, which is where a behaviour written once wants them:
The ward a function rune is handed is its ward in full: it also reads whether it's shown, on the page and leaving (
shown(),mounted(),exiting()), and hears its exits and its readiness. So a behaviour can follow the thing it's on as it comes and goes:These three are right wherever they're read, an effect made in the rune's own body included, though that body runs before its ward is finished.
Built, on the hooks' wards.
16. A
framekey (not built)Called every frame, and Wardic writes what it returns. Its value is the key's resting value, so an
animateor a gesture on the same key wins while it runs. Because it's a key, a rune can carry it, on the page and in a three.js scene alike.Departs from Motion, which has
useAnimationFrameand motion values, apart from the element.17. One
layoutward that flies (not built)A ward is an identity. One
layoutward that lands on a new element as its old one leaves could fly between them, with nolayoutIdand no<LayoutGroup>.layoutIdwould stay for a flight between two different wards.18. Scenes without
<WardicStage>(tried, not built)const { createWard } = stage, with runes andframeon a scene's wards. A scene's enter and exit would stay as they are (createSceneObject, Batches). The hooks have been run over a Stage's ward on plain objects: see Other Environments.19. Types
Two checks the prototype's loose types leave out, both shown to work in a types-only experiment:
card.read("opacity")typed across every rune.One is built: a rune's type is the keys it has, and each ward and each list checks the keys of the runes it's given (4b).
What stays
main:w.*,<WardicProvider>,<AnimatePresence>,<LayoutGroup>andReorder, as they are, for as long as this is an idea. An app that uses none of the hooks is unchanged. Phasing them out would be its own decision, made in the open, once the hooks cover what they do.w.<tag>,<Presence>,<Reorder.*>), and today's tests pass on them. An app still on today's API costs more there (What the prototype showed).initial,animate,exit,variants,transition,whileHover,whileTap,drag,layout.What the prototype showed
It works on a real app. All 36 of the storefront's non-3D examples, and the shell around them, run on the hooks: 33 converted, and three that never used a component. Two of them, lists of hundreds drawn as one Batch, sit under the
<Presence>boundary. The storefront's smoke test passes the same routes asmain.On a server too. Entrances still play from the first paint, staggered ones included, and two requests at once keep their rules apart.
Size, gzip, for the same fade:
domAnimationlisteddomAnimationlisted (before nothing needed setting up)On top of the first chunk, a ward fetches a Feature when it first uses one: hover, press or focus 3.8 KB, colours beyond sRGB 4.7, pan 6.4, drag 12.4, layout 24.4.
The examples found nine bugs, which says where the design has edges:
showaccessor that re-ran with the same answer counted as a change.customit left with, as a presence does.Not measured yet: runtime speed.
What it doesn't cover yet
<Presence>above it. Two examples use it that way. A hook form isn't tried.<WardicStage>(idea 18).<WardicConfig>is still a component in two places: at the root, for a reduced-motion setting that's per request on a server, and round one example's drag, fortransformPagePoint.Other Environments
The hooks you import from
@wardic/solidare the DOM's: they run in the browser's Environment, load the DOM's Features, and hide and pin through CSS. There's no prop to hand them a different one, on purpose.Another Environment would ship an entry of its own with the same hook names. A three.js scene already has its own entry today, with its own
ward:I tried it. The same hooks run over a Stage on plain objects, with no DOM at all: runes,
show, a list's rows and one value at a time all carried over, with three small seams. What didn't carry is what's the page's:follow(a scene's variants pass down its graph),popand hiding, and Features. The types say so now: a scene's hooks refuse those keys where a rune is given (4b). One real difference came out of it: on a Stage a ward moves its Subject from the moment it's made, so a presence there takes a config where the page's takes a ward.A terminal UI such as OpenTUI would be a Stage of this kind over its renderables. It isn't close: its Solid bindings are on Solid 1.9 today, and these hooks are Solid 2 only.
Open questions
showhides,createPresenceandcreateWardsremove. Is that split clear, or should there be one way for a thing to come and go?exitdefaulting toinitial. Helpful, or a surprise to anyone who knows Motion?ward.hovering()), and add to its config. It can't add members to the ward, or hand a value back to the code that made it. Is that enough for what you'd call a plugin?createWard,createWards,createPresenceandcreateRune(createPartuntil 2026-11-26: does "a ward is made of runes" read better to you, and does the word's other life in Svelte get in the way?);makeWard;followandfollowers,show,mountedandshown,pop,enter. The glossary already uses Lead and Follower for the twolayoutIdtwins. And one idea has two names: a list'sinitial: falseand a ward'senter: false. Should a list sayenter: falsetoo?ref(4c): a function handed its Subject once it's on the page, undone once it isn't on show. Would you write behaviours this way, and isrefthe word you'd expect? One thing it doesn't reach yet: joining a group, which is why drag-to-reorder is still a hook of its own. Attributes are a rune'spropsnow (4d).animate,variants,transition, thewhile*targets,show,follow) are Wardic's and mean the same on a page and in a scene. What goes on the thing being animated (style,layout,pop,drag,ref, and on the pageprops) is each Environment's, typed for its own Subject: an element, or a mesh. So are the values a target names. Two calls that could go either way:dragis the Environment's whilewhileDragis Wardic's, andfollowis Wardic's though a scene doesn't take it. Does the line sit where you'd draw it?event.preventDefault(), and Wardic's own gestures already stand down for a key something handled. Is the browser's own mark enough, or have you needed to take an event without cancelling its default?classand without handlers (4d). A rune marks a state with adata-attribute and listens in itsref. Would you missclassin a rune? And would you rather unknown attribute names passed, at the cost of a misspelt one passing too?The prototype is on a local branch. I can push it if running the storefront would help.
All reactions