feat: smooth enter/exit animations for conditional controls#31
Open
Mekwek wants to merge 7 commits into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Wraps every control in
Panel.tsxwith amotion.divthat carries a marker class (.dialkit-control-wrap, plus.dialkit-control-wrap-folderfor folders) and animates enter/exit via a sharedCONTROL_ANIMpreset. Adds CSS rules intheme.cssthat 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. Addswidth: 100%to.dialkit-buttonso action buttons still stretch inside the wrapper. Smooths themargin-topboundary 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 +AnimatePresenceapproach entirely internal to the component.Why
Controls that appear/disappear via
visibleWhen(from PR #30) now animate smoothly instead of popping in/out. TheTransitionControlmode 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 intomain, the diff here will automatically shrink to just the animation-specific changes. Please merge PR #30 first.This PR introduces a
motion.divwrapper around every control inside.dialkit-folder-inner. Any custom themes that target DialKit internals via direct-child (>), adjacent-sibling (+), or:first/last/nth-childselectors will need to update. The wrapper carries.dialkit-control-wrap(and.dialkit-control-wrap-folderfor folders) which can be targeted directly. Seetheme.cssin 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)/conditionaldemo exercises all animation paths (scalar enter/exit, folder enter/exit, TransitionControl mode swap, preset switching)