Skip to content

feat: smooth enter/exit animations for conditional controls#31

Open
Mekwek wants to merge 7 commits into
joshpuckett:mainfrom
Mekwek:feat/conditional-visibility-animation
Open

feat: smooth enter/exit animations for conditional controls#31
Mekwek wants to merge 7 commits into
joshpuckett:mainfrom
Mekwek:feat/conditional-visibility-animation

Conversation

@Mekwek
Copy link
Copy Markdown

@Mekwek Mekwek commented Apr 10, 2026

What changed

Wraps every control in Panel.tsx with a motion.div that carries a marker class (.dialkit-control-wrap, plus .dialkit-control-wrap-folder for folders) and animates enter/exit via a shared CONTROL_ANIM preset. Adds CSS rules in theme.css that rewrite the adjacent-folder divider collapse and last-child folder reset to match the wrapped DOM structure, using plain adjacent-sibling combinators against the marker class. Adds width: 100% to .dialkit-button so action buttons still stretch inside the wrapper. Smooths the margin-top boundary snap on unmount with a 0.2s transition scoped to folder wrappers.

Adds a mode-swap animation to TransitionControl (Easing / Time / Physics) using a column-reverse + AnimatePresence approach entirely internal to the component.

Why

Controls that appear/disappear via visibleWhen (from PR #30) now animate smoothly instead of popping in/out. The TransitionControl mode swap also gets the same polish.

Depends on PR #30

This PR builds on top of PR #30 (feat/conditional-visibility). The diff currently includes PR #30's changes — once PR #30 merges into main, the diff here will automatically shrink to just the animation-specific changes. Please merge PR #30 first.

⚠️ Breaking change for consumers with custom CSS

This PR introduces a motion.div wrapper around every control inside .dialkit-folder-inner. Any custom themes that target DialKit internals via direct-child (>), adjacent-sibling (+), or :first/last/nth-child selectors will need to update. The wrapper carries .dialkit-control-wrap (and .dialkit-control-wrap-folder for folders) which can be targeted directly. See theme.css in this PR for examples.

This is opt-in — you can merge PR #30 for the core visibility feature without this DOM change.

Validation

  • npm run build
  • npm run typecheck ✓ (pre-existing Svelte DialRoot error unrelated)
  • PhotoStack demo pixel-diffed against live joshpuckett.me — identical at rest
  • Release demo pixel-diffed against live — identical
  • /conditional demo exercises all animation paths (scalar enter/exit, folder enter/exit, TransitionControl mode swap, preset switching)
  • Tested on a production app with ~30 visibility rules across /sandbox and board canvas mode — no regressions

Eric Kwekem and others added 7 commits April 10, 2026 15:05
Adds a store-layer conditional visibility feature so controls can be
shown or hidden based on other controls' values in the same panel.

- New withVisibility(control, rule) helper and VisibleWhen type,
  exported from react / solid / svelte / vue entry points
- Store-level evaluation: filterByVisibility runs on registerPanel,
  updatePanel, updateValue, loadPreset, and clearActivePreset
- Empty folders are pruned recursively when all children become hidden
- Hidden controls retain their values across hide/show cycles
- Example demo at /conditional exercises scalar, array, boolean,
  nested folder, and transition control visibility in combination

Also fixes updateTransitionMode not auto-saving the mode to the active
preset or baseValues (same pattern as the loadPreset fix; discovered
while testing the demo across multiple preset versions).

Fully opt-in — configs without the withVisibility wrapper behave
exactly as before. Zero DOM changes, zero CSS changes, no impact on
existing theme customizations or consumers with custom DialKit styles.

A follow-up PR adds smooth enter/exit animations for conditional
controls without introducing any DOM wrapping layer.
Wraps every control in Panel.tsx with a motion.div that carries a
marker class (.dialkit-control-wrap, plus .dialkit-control-wrap-folder
for folders) and animates enter/exit via a shared CONTROL_ANIM preset.
Adds CSS rules in theme.css that rewrite the adjacent-folder divider
collapse and last-child folder reset to match the wrapped DOM
structure, using plain adjacent-sibling combinators against the marker
class. Adds width: 100% to .dialkit-button so action buttons still
stretch inside the wrapper. Smooths the margin-top boundary snap on
unmount with a 0.2s transition scoped to folder wrappers.

Adds a mode-swap animation to TransitionControl (Easing / Time /
Physics) using a column-reverse + AnimatePresence approach entirely
internal to the component.

BREAKING CHANGE for consumers with custom CSS that targets
.dialkit-folder-inner internals via direct-child, adjacent-sibling,
or :first/last/nth-child selectors. Such themes will need to update
their selectors to account for the motion.div wrapper (easiest:
target .dialkit-control-wrap or .dialkit-control-wrap-folder). This
is why the animation feature ships as a separate PR stacked on top
of the store-layer feature — consumers can merge the store feature
without the DOM change.
…tall

Upstream dialkit publishes dist/ via npm but doesn't commit it to git.
When theca pins this fork via 'github:Mekwek/dialkit#<sha>', CI clones
the repo and finds no dist/, breaking the import.

prepare runs after the consumer's install command, with devDeps
available. It invokes the existing build script (tsup + svelte-package),
producing dist/ in node_modules/dialkit ready for theca to resolve.

This commit lives only on the fork. When upstream publishes
withVisibility to npm, theca reverts to dialkit@^1.x.x and this fork
is abandoned.
…stall resolves binaries

When theca installs this fork via 'github:Mekwek/dialkit#<sha>', bun
runs the prepare script but does not put node_modules/.bin on PATH for
the script's environment. Calling 'tsup' or 'svelte-package' bare fails
with command-not-found.

Reference the binaries through ./node_modules/.bin/ explicitly so the
script resolves them deterministically. The user-facing 'build' script
keeps the friendlier PATH-based form for local dev.
bun does not install nested devDependencies before running the prepare
script for git-resolved packages, so the previous prepare-based approach
failed with 'tsup: command not found' (the binary lives in dialkit's own
devDeps which bun skips).

Commit the built dist/ artifacts directly to this fork branch so
consumers can clone-and-use without any build step. This is acceptable
because the fork branch is a single-purpose throwaway — when upstream
dialkit publishes withVisibility, theca reverts to dialkit@^1.x.x and
this fork is abandoned.
Add an opt-in folderMode prop ('independent' | 'accordion') on DialRoot/Panel.
In accordion mode only one top-level folder stays open at a time; opening one
closes the other. Folder gains a controlled (open/onToggle) mode that Panel
coordinates, scoped to depth-0 folders so nested folders stay independent.
PresetManager always opened downward and truncated near the viewport
bottom. Port SelectControl's space-below check so it flips above, matching
the value dropdowns.
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.

1 participant