tldraw/packages
alex adebb680e5
Component-based toolbar customisation API (#3067)
When we went from overrides-based to component based UI customisation
APIs, we didn't do the toolbar because it had some significant extra
complexity around overflowing the contents of the menu into the
dropdown. This is really hard to do at render-time with react - you
can't introspect what a component will return to move some of it into an
overflow.

Instead, this diff runs that logic in a `useLayoutEffect` - we render
all the items into both the main toolbar and the overflow menu, then in
the effect (or if the rendered components change) we use CSS to remove
the items we don't need, check which was last active, etc. Originally, I
wasn't really into this approach - but i've actually found it to work
super well and be very reliable.

### Change Type

- [x] `major` — Breaking change
- [ ] `dependencies` — Changes to package dependencies[^1]
- [ ] `documentation` — Changes to the documentation only[^2]
- [ ] `tests` — Changes to any test code only[^2]
- [ ] `internal` — Any other changes that don't affect the published
package[^2]
- [ ] I don't know

[^1]: publishes a `patch` release, for devDependencies use `internal`
[^2]: will not publish a new version

### Test Plan

1. Test the toolbar at many different sizes with many different 'active
tools'

---------

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
2024-03-12 16:14:28 +00:00
..
assets Update CHANGELOG.md [skip ci] 2024-02-29 18:28:45 +00:00
editor Component-based toolbar customisation API (#3067) 2024-03-12 16:14:28 +00:00
namespaced-tldraw Remove namespaced-tldraw/tldraw.css (#3068) 2024-03-04 17:13:12 +00:00
state Revert throttling of useValue and useStateTracking. (#3129) 2024-03-12 13:57:53 +00:00
store Performance improvements (#2977) 2024-03-11 13:17:31 +00:00
tldraw Component-based toolbar customisation API (#3067) 2024-03-12 16:14:28 +00:00
tlschema Remove dependabot config since it only controls version updates? (#3057) 2024-03-04 13:19:51 +00:00
tlsync Debounce/aggregate tlsync messages (#3012) 2024-03-11 13:33:47 +00:00
utils chore: cleanup multiple uses of FileReader (#3110) 2024-03-12 09:10:18 +00:00
validate Update CHANGELOG.md [skip ci] 2024-02-29 18:28:45 +00:00