Start on Solid 1

Wardic's binding for Solid 1 (1.9) is @wardic/solid/v1, and it works in a plain Solid app and in SolidStart, rendered on the server or not. It's deprecated and frozen for features: it takes fixes, and goes at Wardic's next major. Solid 2's binding is the root, @wardic/solid: see Start.

Moving to 2.0

Until @wardic/solid 2.0, its root was Solid 1's binding. At 2.0 it's Solid 2's, and Solid 1's moved to /v1, its API as it was. A Solid 1 app moves with its imports alone:

-import { createWardic, domAnimation } from "@wardic/solid"
+import { createWardic, domAnimation } from "@wardic/solid/v1"

Every import from @wardic/solid changes, and nothing else. Every name /v1 exports is marked @deprecated, so your editor strikes it through: that's the binding, not the name, and it works until the major that removes /v1. @wardic/core, @wardic/dom and @wardic/test stay on 1.x.

Moving to Solid 2 itself is moving to the root: the same elements and animation props, built on Solid 2's reactivity, with Motion's callback props told as a ward's events. Where a reference page's Solid 2 and Solid 1 differ, it says how.

Install

npm install @wardic/solid @wardic/dom effect solid-js@1
pnpm add @wardic/solid @wardic/dom effect solid-js@1
yarn add @wardic/solid @wardic/dom effect solid-js@1
bun add @wardic/solid @wardic/dom effect solid-js@1

effect and solid-js are peers: Wardic uses the copies your app has. solid-js@1 keeps a new app on Solid 1, now that npm's latest is Solid 2.

The provider

Every Wardic element sits under one WardicProvider. It takes the environment Wardic runs in: DomLive in a browser.

import { DomLive } from "@wardic/dom"
import { WardicProvider } from "@wardic/solid/v1"
import { render } from "solid-js/web"

render(
  () => (
    <WardicProvider env={DomLive}>
      <App />
    </WardicProvider>
  ),
  document.getElementById("app")!,
)

In SolidStart, put it in app.tsx, around the router's root, so every page shares one:

import { Router } from "@solidjs/router"
import { FileRoutes } from "@solidjs/start/router"
import { DomLive } from "@wardic/dom"
import { WardicProvider } from "@wardic/solid/v1"
import { Suspense } from "solid-js"

export default function App() {
  return (
    <Router
      root={(props) => (
        <WardicProvider env={DomLive}>
          <Suspense>{props.children}</Suspense>
        </WardicProvider>
      )}
    >
      <FileRoutes />
    </Router>
  )
}

Your app's Features

What an element does beyond animating its values, a gesture, layout or a colour space, is a Feature, code a page ships only if it asks for it. Choose your app's once, in a module of their own: domAnimation is hover, press, focus and in-view.

// src/lib/wardic.ts
import { createWardic, domAnimation } from "@wardic/solid/v1"

export const { w } = createWardic(domAnimation)

Import w from it, not from @wardic/solid/v1. Its elements take those Features' props, and a prop of another is a type error that names it. These guides import it as ~/lib/wardic.ts, SolidStart's alias for src; in a plain Vite app, import it by its path.

Your first element

A w.* element takes Motion's props: it animates from initial to animate, and to its whileHover target while the pointer is over it.

Live demo
enter/solid2.tsx
import { createWard } from "@wardic/solid/hooks"

/** A card that rises into place as it mounts, and lifts under the pointer. */
export default function Enter() {
  const card = createWard({
    initial: { opacity: 0, y: 24 },
    animate: { opacity: 1, y: 0 },
    whileHover: { y: -4, scale: 1.02 },
    transition: { type: "spring", stiffness: 260, damping: 22 },
  })
  return (
    <div class="sample-card" {...card}>
      Hello, Wardic
    </div>
  )
}
enter/solid1.tsx
import { w } from "~/lib/wardic.ts"

/** A card that rises into place as it mounts, and lifts under the pointer. */
export default function Enter() {
  return (
    <w.div
      class="sample-card"
      initial={{ opacity: 0, y: 24 }}
      animate={{ opacity: 1, y: 0 }}
      whileHover={{ y: -4, scale: 1.02 }}
      transition={{ type: "spring", stiffness: 260, damping: 22 }}
    >
      Hello, Wardic
    </w.div>
  )
}
enter/foldkit.ts
import type { Html, HtmlBuilder } from "foldkit/html"
import { wardic } from "~/lib/wardic.ts"

/** A card that rises into place as it mounts, and lifts under the pointer. */
export const view = <Message,>(h: HtmlBuilder<Message>): Html => {
  const w = wardic.html(h)
  return w.div(
    [
      h.Class("sample-card"),
      w.Initial({ opacity: 0, y: 24 }),
      w.Animate({ opacity: 1, y: 0 }),
      w.WhileHover({ y: -4, scale: 1.02 }),
      w.Transition({ type: "spring", stiffness: 260, damping: 22 }),
    ],
    ["Hello, Wardic"],
  )
}
enter/motion.tsx
import * as m from "motion/react-m"

/** A card that rises into place as it mounts, and lifts under the pointer. */
export default function Enter() {
  return (
    <m.div
      className="sample-card"
      initial={{ opacity: 0, y: 24 }}
      animate={{ opacity: 1, y: 0 }}
      whileHover={{ y: -4, scale: 1.02 }}
      transition={{ type: "spring", stiffness: 260, damping: 22 }}
    >
      Hello, Wardic
    </m.div>
  )
}

The same motion can go on an element of your own, with a ward: w.createWard(config) spread onto it, or the use:w directive.

import { w } from "~/lib/wardic.ts"

export function Card() {
  const card = w.createWard({ initial: { opacity: 0 }, animate: { opacity: 1 } })
  return <div class="card" {...card()} />
}

Only what a page uses

A page that drags or lays out makes an instance of its own, in a module only its pages import, so the pages that don't never load drag or layout:

// src/lib/wardic-drag.ts
import { createWardic, domAnimation, drag } from "@wardic/solid/v1"

export const { w } = createWardic([domAnimation, drag])

Shipping less has the rest: loading a Feature later, and the sections a LazyWardic makes.

Rendered on the server

On a server-rendered page, an element arrives in the HTML already at initial, so it never flashes at its target first. Its entrance plays from the first paint, before the JavaScript has loaded, and the client takes it over mid-flight when it hydrates.

Next