feat: implement Toolbar component - #5043
Open
k0ndee wants to merge 4 commits into
Open
Conversation
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.
Motivation
Introduce a new
Toolbarcomponent implementing the Material Design 3 toolbars spec. Reuse theme tokens (shape, color roles, elevation) and follow the same component-tokens pattern as FAB / Checkbox.Spec re-check (M3 toolbars)
Re-checked the M3 toolbars specs:
variants:floating(self-positioned pill,corner.full, elevation level 3) anddocked(full-width bar pinned to the bottom edge,corner.none, no elevation, extends into safe-area insets).floatingsupportshorizontal/verticalorientation;dockedis always horizontal per spec.standard) colors: container/unselected-buttonsurfaceContainer, icon/labelonSurfaceVariant, selected buttonsecondaryContainerwithonSecondaryFixedVariant(light) /onSecondaryContainer(dark) icon.vibrantcolorScheme: container/unselected-buttonprimaryContainer, icon/labelonPrimaryFixedVariant(light) /onPrimaryContainer(dark), selected button falls back tosurfaceContainerwithonSurfaceicon.IconButton/Buttonchildren are auto-recolored to matchcolorSchemeunless they already set their own color (amodeon either opts them out in favor of their own mode-based coloring).Changes
Toolbar/ tokens / utilssrc/components/Toolbar/{Toolbar.tsx,tokens.ts,utils.ts}:variant(floating/docked),orientation(horizontal/vertical, floating-only),colorScheme(standard/vibrant),containerColoroverride,style/contentContainerStyle,testID,aria-label,theme,refToolbarTokens;dockedextends into safe-area insets via margin outsideSurface's box, keeping the 64dp icon band untouchedwithToolbarChildColorsauto-recolors mode-lessIconButton/Buttonchildren percolorScheme, without touching children that already set their own color/modesrc/index.tsxExample / docs / tests
ToolbarExample.tsx) covering both variants, both orientations, both color schemes, over a scrollable listToolbar.test.tsx) covering shape/elevation per variant, color resolution across light/dark themes for both color schemes, and child auto-recoloring behaviorScope note
Per Satyajit Sahoo's recommendation, this implementation is split into a series of PRs for easier review, rather than landing as one large change. This PR is PR 1 of the series:
colorSchemestandard/vibrant. Component, tokens, tests, docs, example.Related issue
Related to #4988
Test plan
yarn typecheck/yarn lint/ Toolbar unit testsVisual verification
Docs screenshots:
docs/public/screenshots/toolbar_*.png.