Skip to content

Conversation

@msaktype
Copy link
Owner

@msaktype msaktype commented Dec 23, 2025

What

Add the following functions to define dynamic more easily

  • dynamic.px()
  • dynamic.num()
  • dynamic.opacity()
  • dynamic.var()

Example

dynamic.px()

dynamic: {
  w: d.px("width"),
}

dynamic.var()

import { dynamic as d } from "windctrl";

const card = windctrl({
  base: "relative",
  dynamic: {
    x: d.var("--x"),
    y: d.var("--y"),
  },
});

// Usage
<div
  className={card().className}
  style={{
    "--x": `${mouseX}px`,
    "--y": `${mouseY}px`,
  }}
/>

Why

dynamic: {
  w: (val) =>
    typeof val === "number" ? { style: { width: `${val}px` } } : val,
},

to define a function like this is kind of hard, and there is a tendency for CSS properties to require dynamic value changes

@msaktype msaktype marked this pull request as ready for review December 23, 2025 02:10
@msaktype msaktype merged commit f07f09e into dev Dec 23, 2025
@msaktype msaktype deleted the dynamic-presets branch December 23, 2025 02:22
@msaktype msaktype mentioned this pull request Dec 23, 2025
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants