-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set props through style plugin (#6599)
See #6574 for a long-form writeup on the full background of this PR. ## The problem addressed on this PR The normalisation step cannot easily handle commands/actions removing properties from elements. ## Fix Instead of working around the limitation of the normalisation step, this PR introduces an approach where the style plugins themselves implement setting/removing style props on elements, and the `SetProperty` / `DeleteProperty` command uses the style plugin API to set/remove style props. The PR deals with patching props that are removed during a canvas interaction (details in #6574, TLDR: if `gap` is removed with the gap control, it needs to be set to `0px` while the interaction is in progress, otherwise the value from the Tailwind class will be applied which would be janky). This is an under-the-hood PR, no user-facing functionality is added. ### Details - Updated the `StylePlugin` interface with the `updateStyles` function, which can be used to set/delete element styles. The inline style plugin and the Tailwind style plugin are updated accordingly - Injected `StylePlugin.updateStyles` into `runSetProperty` and `runDeleteProperties` via the new `runStyleUpdateForStrategy` function. This function encapsulates a performance-related feature: if an interaction is ongoing, it sets props in the inline style prop (and patches removed props), so updates are real-time, and when an interaction is done, it uses the active plugin. This trick works because the active strategy is re-run on interaction finish, producing the right patches for a style update. - The machinery dealing with zeroing props is added. The entrypoint for adding the zeroed props is `patchRemovedProperties` (called from `dispatch-strategies.tsx`, and the entrypoint for recording which props need to be zeroed is `runStyleUpdateMidInteraction` - The code related to the normalisation step is removed - `UpdateClassListCommand` is removed and turned into a helper function (since it's not called as a command anymore, just as a helper in the Tailwind style plugin) **Manual Tests:** I hereby swear that: - [x] I opened a hydrogen project and it loaded - [x] I could navigate to various routes in Play mode
- Loading branch information
Showing
19 changed files
with
545 additions
and
597 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
101 changes: 0 additions & 101 deletions
101
editor/src/components/canvas/commands/update-class-list-command.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.