-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RN: Add Bottom Sheet Select Control Componet (#28543)
* Add BottomSheetSubSheet Component * Fix SubSheet button prompt * Add Bottom Sheet Select Control * Add Button Width Select Control * Move SafeAreaView * Update packages/components/src/mobile/bottom-sheet/sub-sheet/README.md Co-authored-by: Gerardo Pacheco <[email protected]> * Fix values Co-authored-by: Gerardo Pacheco <[email protected]> * Correct the Readme.md * Update to use the absolute imports * Add styles for select control * Fix the width spacing when using the full width alignment * Fix the min width overflow * Adding comments for clarity * Mobile - Buttons block - Fix issues with full width and safe area * Mobile - BottomSheet - Select control - Fix style import * Mobile - Buttons block - fix tests Co-authored-by: Gerardo Pacheco <[email protected]>
- Loading branch information
Showing
12 changed files
with
444 additions
and
33 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
90 changes: 90 additions & 0 deletions
90
packages/components/src/mobile/bottom-sheet-select-control/README.md
This file contains 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,90 @@ | ||
# BottomSheetSelectControl | ||
|
||
`BottomSheetSelectControl` allows users to select an item from a single-option menu just like [`SelectControl`](/packages/components/src/select-control/readme.md), | ||
However, instead of opening up the selection in a modal, the selection opens up in a BottomSheet. | ||
|
||
### Usage | ||
|
||
```jsx | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { BottomSheetSelectControl } from '@wordpress/components'; | ||
import { useState } from '@wordpress/compose'; | ||
|
||
const options = [ | ||
{ | ||
key: 'small', | ||
name: 'Small', | ||
style: { fontSize: '50%' }, | ||
}, | ||
{ | ||
key: 'normal', | ||
name: 'Normal', | ||
style: { fontSize: '100%' }, | ||
}, | ||
{ | ||
key: 'large', | ||
name: 'Large', | ||
style: { fontSize: '200%' }, | ||
}, | ||
{ | ||
key: 'huge', | ||
name: 'Huge', | ||
style: { fontSize: '300%' }, | ||
}, | ||
]; | ||
|
||
function MyCustomSelectControl() { | ||
const [ fontSize, setFontSize ] = useState(); | ||
return ( | ||
<BottomSheetSelectControl | ||
label="Font Size" | ||
options={ options } | ||
onChange={ ( { selectedItem } ) => setFontSize( selectedItem ) } | ||
/> | ||
); | ||
} | ||
|
||
function MyControlledCustomSelectControl() { | ||
const [ fontSize, setFontSize ] = useState( options[ 0 ] ); | ||
return ( | ||
<BottomSheetSelectControl | ||
label="Font Size" | ||
options={ options } | ||
onChange={ ( { selectedItem } ) => setFontSize( selectedItem ) } | ||
value={ options.find( ( option ) => option.key === fontSize.key ) } | ||
/> | ||
); | ||
} | ||
``` | ||
|
||
### Props | ||
|
||
#### label | ||
|
||
The label for the control. | ||
|
||
- Type: `String` | ||
- Required: Yes | ||
|
||
#### options | ||
|
||
The options that can be chosen from. | ||
|
||
- Type: `Array<{ key: String, name: String, ...rest }>` | ||
- Required: Yes | ||
|
||
#### onChange | ||
|
||
Function called with the control's internal state changes. The `selectedItem` property contains the next selected item. | ||
|
||
- Type: `Function` | ||
- Required: No | ||
|
||
#### value | ||
|
||
Can be used to externally control the value of the control, like in the `MyControlledCustomSelectControl` example above. | ||
|
||
- Type: `Object` | ||
- Required: No |
Oops, something went wrong.