Skip to content

[pull] main from tldraw:main#131

Merged
pull[bot] merged 1 commit intocode:mainfrom
tldraw:main
Aug 11, 2025
Merged

[pull] main from tldraw:main#131
pull[bot] merged 1 commit intocode:mainfrom
tldraw:main

Conversation

@pull
Copy link
Copy Markdown

@pull pull Bot commented Aug 11, 2025

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 : )

### 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>
@pull pull Bot locked and limited conversation to collaborators Aug 11, 2025
@pull pull Bot added the ⤵️ pull label Aug 11, 2025
@pull pull Bot merged commit 8568741 into code:main Aug 11, 2025
@pull pull Bot had a problem deploying to deploy-staging August 11, 2025 15:13 Error
@pull pull Bot had a problem deploying to deploy-production August 11, 2025 15:13 Failure
@pull pull Bot had a problem deploying to deploy-staging August 11, 2025 15:13 Error
@pull pull Bot had a problem deploying to vsce publish August 11, 2025 15:13 Failure
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant