Skip to content

Commit

Permalink
[RNMobile] Display lock icon in disabled state of Cell component (#…
Browse files Browse the repository at this point in the history
…50907)

* Add lock icon component

* Display lock icon in `Cell` component

* Update bottom sheet cell components to display lock icon properly

* Update `Cell` component placeholder color for disabled state

* Update component name of radio cell
  • Loading branch information
fluiddot authored May 24, 2023
1 parent 8fd6740 commit 19594cd
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 8 deletions.
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;
}

1 comment on commit 19594cd

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 19594cd.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5074105655
📝 Reported issues:

Please sign in to comment.