-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[RNMobile] Update image size UI control #19232
Changes from all commits
95e7430
c70193b
82ab9d3
31caac7
c4be661
697ab01
9e71910
9aa8aa7
12ebc85
559fb21
d6be598
34820b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { findIndex } from 'lodash'; | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import Cell from './cell'; | ||
|
||
export default function BottomSheetCyclePickerCell( props ) { | ||
const { value, options, onChangeValue, ...cellProps } = props; | ||
|
||
const nextOptionValue = () => { | ||
return options[ ( selectedOptionIndex + 1 ) % options.length ].value; | ||
}; | ||
|
||
const selectedOptionIndex = findIndex( options, [ 'value', value ] ); | ||
const optionsContainsValue = | ||
options.length > 0 && selectedOptionIndex !== -1; | ||
|
||
return ( | ||
<Cell | ||
onPress={ () => | ||
optionsContainsValue && onChangeValue( nextOptionValue() ) | ||
} | ||
editable={ false } | ||
value={ | ||
optionsContainsValue && options[ selectedOptionIndex ].name | ||
} | ||
{ ...cellProps } | ||
/> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CycleSelectControl | ||
=================== | ||
|
||
`CycleSelectControl` is an experimental alternative to SelectControl for mobile. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import CyclePickerCell from '../bottom-sheet/cycle-picker-cell'; | ||
|
||
function CycleSelectControl( { | ||
help, | ||
instanceId, | ||
label, | ||
multiple = false, | ||
onChange, | ||
options = [], | ||
className, | ||
hideLabelFromVision, | ||
...props | ||
} ) { | ||
const id = `inspector-select-control-${ instanceId }`; | ||
|
||
return ( | ||
<CyclePickerCell | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure I see the benefit in having both a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think I'd prefer to keep it this way for now. It matches other Control / BottomSheet Cell pairs like ToggleControl / SwitchCell and I think there may be implications later on related to cross platform controls, where the control might become independent of where it lives in the UI. This issue has some interesting conversation on that topic #18018 |
||
label={ label } | ||
hideLabelFromVision={ hideLabelFromVision } | ||
id={ id } | ||
help={ help } | ||
className={ className } | ||
onChangeValue={ onChange } | ||
aria-describedby={ !! help ? `${ id }__help` : undefined } | ||
multiple={ multiple } | ||
options={ options } | ||
{ ...props } | ||
/> | ||
); | ||
} | ||
|
||
export default CycleSelectControl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to accommodate this change - #19800