Repository navigation
Conversation
…code toggles A state effect now takes `elementStyles`: declarations the state sets on other elements of its key, each found by a selector inside the key's element, as an effect's `selector` is. The state still toggles once per trigger, however many elements it styles. A state effect in `config.effects` that no interaction or sequence references declares the look of a state code toggles (`toggleEffect`), named by its `effectId` or its entry's id. `generate()` writes it, and the runtime renders it when its key's element connects. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Description
Feature: two additions to state effects (
transition/transitionProperties).1.
elementStyles: a state that styles other elements of its key.selectoris resolved inside the key's element, the same way an effect'sselectoris.generate()writes one more state rule per entry. The rule is under the same:is(:state(<effectId>), :--<effectId>)/[data-interact-effect~="<effectId>"]selectors as the target's own rule, andcreateTransitionCSSrenders the same rules at runtime.2. States that code toggles.
config.effectsthat no interaction or sequence references now declares the look of a state that code toggles withtoggleEffect. It is named by itseffectId, or else by its entry's id (getCodeStates).generate()writes its rules.add()renders them when the key's element connects. It honors the effect's media conditions, re-rendering through a media-query listener when they change, and its selector condition.Today both are dropped.
elementStylesisn't part ofStateEffect, and nothing caches an effect that no one references, so its look has nowhere to come from.Related Issue
No issue filed. This came up in the Wix viewer (Thunderbolt), which is moving component state styles off its own CSS and into the interact config. Those are the hover, click and other states authored in the editor.
Without these two additions the viewer has to keep its own CSS for both cases.
Checklist
packages/interact/test/stateLooks.spec.tscovers both features ingenerate()and at runtime, plus a referenced state effect staying with its interaction. On this commit,yarn workspace @wix/interact test(496 tests),yarn lintandyarn format:checkpass.ElementStyle,getCodeStates) for now. I'll add the rules/docs pages once the API shape is agreed.Screenshots / Demos
packages/interact/repro/state-looks.html: build withyarn workspace @wix/interact build, serve the repo root, and open the page.elementStylesentry of the same state).selectedfrom code. No interaction sets that state, so its look comes fromconfig.effects.Additional Notes
971a565); it merges cleanly ontomaster(2.5.19).createTransitionCSSwas refactored to build every state rule through one helper (stateRule), so the target's rule and theelementStylesrules share the selector-condition handling. The target's rule output is unchanged.elementStylesname and shape, and whether code-toggled states should be declared explicitly rather than inferred as "unreferenced".🤖 Generated with Claude Code