Conversation
### Change selection color based on shape condition This PR adds a new example called "Selection Color Condition" that demonstrates how to dynamically change the selection color based on the types of shapes currently selected. When all selected shapes are rectangles, the selection color will turn red. Otherwise, it will revert to the default blue. This is achieved by: 1. Using `editor.react` to listen for selection changes. 2. Checking if all `editor.getSelectedShapes()` are of type 'geo' and 'rectangle'. 3. Adding/removing a CSS class (`rectangle-selection`) to the editor container. 4. Overriding `--color-selection` and `--color-selection-stroke` CSS variables in `selection-color-condition.css`. The example includes comprehensive documentation in its `README.md` on how to customize the condition for other shape types (e.g., circles, text, or mixed selections). ### Change type - [ ] `bugfix` - [ ] `improvement` - [x] `feature` - [ ] `api` - [ ] `other` ### Test plan 1. Navigate to the "Selection Color Condition" example. 2. Create several rectangle shapes. 3. Select only rectangles: Observe the selection outline and fill turn red. 4. Create other shapes (e.g., circles, text). 5. Select a mix of rectangles and other shapes: Observe the selection color remain default (blue). 6. Select only non-rectangle shapes: Observe the selection color remain default (blue). - [ ] Unit tests - [ ] End to end tests ### Release notes - Added a new example demonstrating how to dynamically change the selection color based on selected shape types. --- <a href="https://cursor.com/background-agent?bcId=bc-3355ce7f-6cb4-4da0-9366-382314cc5a9d"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/open-in-cursor-dark.svg"> <source media="(prefers-color-scheme: light)" srcset="https://cursor.com/open-in-cursor-light.svg"> <img alt="Open in Cursor" src="https://cursor.com/open-in-cursor.svg"> </picture> </a> <a href="https://cursor.com/agents?id=bc-3355ce7f-6cb4-4da0-9366-382314cc5a9d"> <picture> <source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/open-in-web-dark.svg"> <source media="(prefers-color-scheme: light)" srcset="https://cursor.com/open-in-web-light.svg"> <img alt="Open in Web" src="https://cursor.com/open-in-web.svg"> </picture> </a> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: alex <alex@tldraw.com>
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.3)
Can you help keep this open source service alive? 💖 Please sponsor : )