-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: add ConnectedButtonGroup component #5074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
oleksandrzavarzin-callstack
wants to merge
16
commits into
callstack:main
Choose a base branch
from
oleksandrzavarzin-callstack:feat/connected-button-group
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 12 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
76e24a5
feat(connected-button-group): add Material Design 3 connected button …
matkoson 91f1f79
test(connected-button-group): cover selection, sizing and colors
matkoson 9a4f5d0
docs(connected-button-group): showcase in example app and theme colors
matkoson 09967f9
fix(connected-button-group): apply disabled container color via opaci…
matkoson db5ae39
fix(connected-button-group): align shapes and roles with M3 spec
matkoson 4fce0ef
refactor(connected-button-group): reuse shared theme utilities
matkoson 91ed2b5
docs(connected-button-group): add docs page and fix deprecation link
matkoson f610393
Merge branch 'callstack:main' into feat/connected-button-group
oleksandrzavarzin-callstack cb5886a
refactor: move types + updated the docs
oleksandrzavarzin-callstack 50cf25f
fix: restore icon to check animation
oleksandrzavarzin-callstack d3d98f3
fix: improve button morph animation stability
oleksandrzavarzin-callstack 78a5b51
refactor: move morphingCorners and other minor corrections
oleksandrzavarzin-callstack 376df7b
refactor: remove connectedButtonGroup from 5.x docs
oleksandrzavarzin-callstack 7eaf3c9
refactor: separate gaps for check & leading icon
oleksandrzavarzin-callstack 09af076
refactor: declare values outside of ConditionalValue
oleksandrzavarzin-callstack 2b80433
Merge remote-tracking branch 'origin/main' into feat/connected-button…
oleksandrzavarzin-callstack File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
122 changes: 122 additions & 0 deletions
122
docs/5.x/docs/components/ConnectedButtonGroup/ConnectedButtonGroup.mdx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| --- | ||
| title: ConnectedButtonGroup | ||
| --- | ||
|
|
||
| import PropTable from '@docs/components/PropTable.tsx'; | ||
| import ExtendsLink from '@docs/components/ExtendsLink.tsx'; | ||
| import ThemeColorsTable from '@docs/components/ThemeColorsTable.tsx'; | ||
| import ScreenshotTabs from '@docs/components/ScreenshotTabs.tsx'; | ||
| import ExtendedExample from '@docs/components/ExtendedExample.tsx'; | ||
|
|
||
| Connected button groups let people select from a set of related options, switch views or sort elements. They are the Material Design 3 successor to `SegmentedButtons`: selected buttons morph to a fully-rounded shape and the group supports single- and multi-select. | ||
|
|
||
| <ScreenshotTabs screenshotData="screenshots/connected-button-group.png" /> | ||
|
|
||
| ## Usage | ||
|
|
||
| ```js | ||
| import * as React from 'react'; | ||
| import { SafeAreaView, StyleSheet } from 'react-native'; | ||
| import { ConnectedButtonGroup } from 'react-native-paper'; | ||
|
|
||
| const MyComponent = () => { | ||
| const [value, setValue] = React.useState('walk'); | ||
|
|
||
| return ( | ||
| <SafeAreaView style={styles.container}> | ||
| <ConnectedButtonGroup | ||
| value={value} | ||
| onValueChange={setValue} | ||
| buttons={[ | ||
| { value: 'walk', label: 'Walking' }, | ||
| { value: 'train', label: 'Transit' }, | ||
| { value: 'drive', label: 'Driving' }, | ||
| ]} | ||
| /> | ||
| </SafeAreaView> | ||
| ); | ||
| }; | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| container: { | ||
| flex: 1, | ||
| alignItems: 'center', | ||
| }, | ||
| }); | ||
|
|
||
| export default MyComponent; | ||
| ``` | ||
|
|
||
| ## Props | ||
|
|
||
| <span /> | ||
|
|
||
| <div> | ||
|
|
||
| ### buttons (required) | ||
|
|
||
| </div> | ||
|
|
||
| <PropTable componentLink="ConnectedButtonGroup/ConnectedButtonGroup" prop="buttons" /> | ||
|
|
||
| <div> | ||
|
|
||
| ### size | ||
|
|
||
| </div> | ||
|
|
||
| <PropTable componentLink="ConnectedButtonGroup/ConnectedButtonGroup" prop="size" /> | ||
|
|
||
| <div> | ||
|
|
||
| ### style | ||
|
|
||
| </div> | ||
|
|
||
| <PropTable componentLink="ConnectedButtonGroup/ConnectedButtonGroup" prop="style" /> | ||
|
|
||
| <div> | ||
|
|
||
| ### testID | ||
|
|
||
| </div> | ||
|
|
||
| <PropTable componentLink="ConnectedButtonGroup/ConnectedButtonGroup" prop="testID" /> | ||
|
|
||
| <div> | ||
|
|
||
| ### theme | ||
|
|
||
| </div> | ||
|
|
||
| <PropTable componentLink="ConnectedButtonGroup/ConnectedButtonGroup" prop="theme" /> | ||
|
|
||
| <span /> | ||
|
|
||
| ## Theme colors | ||
|
|
||
| <ThemeColorsTable | ||
| themeColorsData={{ | ||
| checked: { | ||
| '-': { | ||
| backgroundColor: 'theme.colors.secondaryContainer', | ||
| textColor: 'theme.colors.onSecondaryContainer', | ||
| }, | ||
| }, | ||
| unchecked: { | ||
| '-': { | ||
| backgroundColor: 'theme.colors.surfaceContainer', | ||
| textColor: 'theme.colors.onSurfaceVariant', | ||
| }, | ||
| }, | ||
| disabled: { | ||
| '-': { | ||
| backgroundColor: 'theme.colors.onSurface', | ||
| textColor: 'theme.colors.onSurface', | ||
| }, | ||
| }, | ||
| }} | ||
| componentName="ConnectedButtonGroup" | ||
| /> | ||
|
|
||
| <span /> |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [ | ||
| "ConnectedButtonGroup" | ||
| ] |
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
112 changes: 112 additions & 0 deletions
112
docs/6.x/docs/components/ConnectedButtonGroup/ConnectedButtonGroup.mdx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
| --- | ||
| title: ConnectedButtonGroup | ||
| --- | ||
|
|
||
| import PropTable from '@docs/components/PropTable.tsx'; | ||
| import ExtendsLink from '@docs/components/ExtendsLink.tsx'; | ||
| import ThemeColorsTable from '@docs/components/ThemeColorsTable.tsx'; | ||
| import ScreenshotTabs from '@docs/components/ScreenshotTabs.tsx'; | ||
| import ExtendedExample from '@docs/components/ExtendedExample.tsx'; | ||
|
|
||
| Connected button groups let people select from a set of related options, | ||
| switch views or sort elements. They are the Material Design 3 successor to | ||
| `SegmentedButtons`: selected buttons morph to a fully-rounded shape and the | ||
| group supports single- and multi-select. | ||
|
|
||
|
|
||
|
|
||
|
|
||
| <ScreenshotTabs screenshotData={"screenshots/connected-button-group.png"}/> | ||
|
|
||
|
|
||
| ## Usage | ||
| ```js | ||
| import * as React from 'react'; | ||
| import { SafeAreaView, StyleSheet } from 'react-native'; | ||
| import { ConnectedButtonGroup } from 'react-native-paper'; | ||
|
|
||
| const MyComponent = () => { | ||
| const [value, setValue] = React.useState('walk'); | ||
|
|
||
| return ( | ||
| <SafeAreaView style={styles.container}> | ||
| <ConnectedButtonGroup | ||
| value={value} | ||
| onValueChange={setValue} | ||
| buttons={[ | ||
| { value: 'walk', label: 'Walking' }, | ||
| { value: 'train', label: 'Transit' }, | ||
| { value: 'drive', label: 'Driving' }, | ||
| ]} | ||
| /> | ||
| </SafeAreaView> | ||
| ); | ||
| }; | ||
|
|
||
| const styles = StyleSheet.create({ | ||
| container: { | ||
| flex: 1, | ||
| alignItems: 'center', | ||
| }, | ||
| }); | ||
|
|
||
| export default MyComponent; | ||
| ``` | ||
|
|
||
|
|
||
| ## Props | ||
| <span /> | ||
|
|
||
|
|
||
|
|
||
| <div> | ||
|
|
||
| ### buttons (required) | ||
|
|
||
| </div> | ||
|
|
||
| <PropTable componentLink="ConnectedButtonGroup/ConnectedButtonGroup" prop="buttons" /> | ||
|
|
||
| <div> | ||
|
|
||
| ### size | ||
|
|
||
| </div> | ||
|
|
||
| <PropTable componentLink="ConnectedButtonGroup/ConnectedButtonGroup" prop="size" /> | ||
|
|
||
| <div> | ||
|
|
||
| ### style | ||
|
|
||
| </div> | ||
|
|
||
| <PropTable componentLink="ConnectedButtonGroup/ConnectedButtonGroup" prop="style" /> | ||
|
|
||
| <div> | ||
|
|
||
| ### testID | ||
|
|
||
| </div> | ||
|
|
||
| <PropTable componentLink="ConnectedButtonGroup/ConnectedButtonGroup" prop="testID" /> | ||
|
|
||
| <div> | ||
|
|
||
| ### theme | ||
|
|
||
| </div> | ||
|
|
||
| <PropTable componentLink="ConnectedButtonGroup/ConnectedButtonGroup" prop="theme" /> | ||
|
|
||
|
|
||
|
|
||
| <span /> | ||
|
|
||
|
|
||
| ## Theme colors | ||
|
|
||
| <ThemeColorsTable themeColorsData={{"checked":{"-":{"backgroundColor":"theme.colors.secondaryContainer","textColor":"theme.colors.onSecondaryContainer"}},"unchecked":{"-":{"backgroundColor":"theme.colors.surfaceContainer","textColor":"theme.colors.onSurfaceVariant"}},"disabled":{"-":{"backgroundColor":"theme.colors.onSurface","textColor":"theme.colors.onSurface"}}}} componentName="ConnectedButtonGroup" /> | ||
|
|
||
|
|
||
| <span /> |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| [ | ||
| "ConnectedButtonGroup" | ||
| ] |
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
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.