Skip to content
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] Display lock icon in disabled state of Cell component #50907

Merged
merged 5 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const BottomSheetSelectControl = ( {
) }
disabled={ disabled }
>
<Icon icon={ chevronRight }></Icon>
{ disabled ? null : <Icon icon={ chevronRight } /> }
</BottomSheet.Cell>
}
showSheet={ showSubSheet }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const BottomSheetTextControl = ( {
placeholder={ cellPlaceholder || placeholder || '' }
disabled={ disabled }
>
<Icon icon={ chevronRight }></Icon>
{ disabled ? null : <Icon icon={ chevronRight } /> }
</BottomSheet.Cell>
}
showSheet={ showSubSheet }
Expand Down
8 changes: 8 additions & 0 deletions packages/components/src/mobile/bottom-sheet/cell.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { withPreferredColorScheme } from '@wordpress/compose';
import styles from './styles.scss';
import platformStyles from './cellStyles.scss';
import TouchableRipple from './ripple';
import LockIcon from './lock-icon';

const isIOS = Platform.OS === 'ios';
class BottomSheetCell extends Component {
Expand Down Expand Up @@ -93,6 +94,7 @@ class BottomSheetCell extends Component {
accessibilityRole,
disabled = false,
disabledStyle = styles.cellDisabled,
showLockIcon = true,
activeOpacity,
onPress,
onLongPress,
Expand Down Expand Up @@ -374,6 +376,7 @@ class BottomSheetCell extends Component {
] }
>
<Icon
lock
icon={ icon }
size={ 24 }
fill={
Expand Down Expand Up @@ -440,6 +443,11 @@ class BottomSheetCell extends Component {
>
{ children }
</View>
{ disabled && showLockIcon && (
<View style={ styles.cellDisabled }>
<LockIcon />
</View>
) }
</View>
{ help && (
<Text style={ [ cellHelpStyle, styles.placeholderColor ] }>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Cell from './cell';
import styles from './styles.scss';

export default function BottomSheetColorCell( props ) {
const { color, withColorIndicator = true, ...cellProps } = props;
const { color, withColorIndicator = true, disabled, ...cellProps } = props;

return (
<Cell
Expand All @@ -22,12 +22,13 @@ export default function BottomSheetColorCell( props ) {
__( 'Double tap to go to color settings' )
}
editable={ false }
disabled={ disabled }
value={ withColorIndicator && ! color && __( 'Default' ) }
>
{ withColorIndicator && color && (
<ColorIndicator color={ color } style={ styles.colorCircle } />
) }
<Icon icon={ chevronRight }></Icon>
{ disabled ? null : <Icon icon={ chevronRight }></Icon> }
</Cell>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* WordPress dependencies
*/
import { Icon, lock } from '@wordpress/icons';
import { usePreferredColorSchemeStyle } from '@wordpress/compose';

/**
* Internal dependencies
*/
import styles from './styles.scss';

export default function LockIcon() {
const iconStyle = usePreferredColorSchemeStyle(
styles.icon,
styles[ 'icon--dark' ]
);

return <Icon icon={ lock } color={ iconStyle.color } style={ iconStyle } />;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.icon {
color: $gray-dark;
margin-left: 6px;
}

.icon--dark {
color: $gray-light;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { usePreferredColorSchemeStyle } from '@wordpress/compose';
import Cell from './cell';
import styles from './styles.scss';

export default function BottomSheetColorCell( props ) {
export default function BottomSheetRadioCell( props ) {
const { selected, ...cellProps } = props;

const selectedIconStyle = usePreferredColorSchemeStyle(
Expand All @@ -29,6 +29,7 @@ export default function BottomSheetColorCell( props ) {
}
editable={ false }
value={ '' }
showLockIcon={ selected }
>
{ selected && (
<Icon icon={ check } style={ selectedIconStyle }></Icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { withPreferredColorScheme } from '@wordpress/compose';
* Internal dependencies
*/
import Cell from './cell';
import LockIcon from './lock-icon';
import styles from './range-cell.scss';
import RangeTextInput from './range-text-input';
import { toFixed } from '../utils';
Expand Down Expand Up @@ -219,6 +220,7 @@ class BottomSheetRangeCell extends Component {
accessible={ false }
valueStyle={ styles.valueStyle }
disabled={ disabled }
showLockIcon={ false }
>
<View style={ containerStyle }>
{ preview }
Expand Down Expand Up @@ -260,6 +262,7 @@ class BottomSheetRangeCell extends Component {
{ children }
</RangeTextInput>
) }
{ disabled && <LockIcon /> }
</View>
</Cell>
</View>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//Bottom Sheet

$cell-disable-opacity: 0.38;

.bottomModal {
justify-content: flex-end;
margin: 0;
Expand Down Expand Up @@ -288,11 +290,11 @@
}

.placeholderColorDisabled {
color: lighten($gray, 20%);
color: rgba($gray-dark, $cell-disable-opacity);
}

.placeholderColorDisabledDark {
color: lighten($gray-dark, 10%);
color: rgba($white, $cell-disable-opacity);
}

.applyButton {
Expand Down Expand Up @@ -327,5 +329,5 @@
}

.cellDisabled {
opacity: 0.3;
opacity: $cell-disable-opacity;
}