Skip to content
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
4 changes: 4 additions & 0 deletions src/components/MenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Avatar from './Avatar';
import Badge from './Badge';
import CONST from '../CONST';
import menuItemPropTypes from './menuItemPropTypes';
import SelectCircle from './SelectCircle';

const propTypes = {
...menuItemPropTypes,
Expand All @@ -21,6 +22,7 @@ const propTypes = {
const defaultProps = {
badgeText: undefined,
shouldShowRightIcon: false,
shouldShowSelectedState: false,
wrapperStyle: [],
success: false,
icon: undefined,
Expand All @@ -32,6 +34,7 @@ const defaultProps = {
iconFill: undefined,
focused: false,
disabled: false,
isSelected: false,
subtitle: undefined,
iconType: 'icon',
onPress: () => {},
Expand Down Expand Up @@ -124,6 +127,7 @@ const MenuItem = props => (
/>
</View>
)}
{props.shouldShowSelectedState && <SelectCircle isChecked={props.isSelected} />}
</View>
</>
)}
Expand Down
30 changes: 30 additions & 0 deletions src/components/SelectCircle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';
import {View} from 'react-native';
import PropTypes from 'prop-types';
import styles from '../styles/styles';
import Icon from './Icon';
import * as Expensicons from './Icon/Expensicons';
import themeColors from '../styles/themes/default';

const propTypes = {
/** Should we show the checkmark inside the circle */
isChecked: PropTypes.bool,
};

const defaultProps = {
isChecked: false,
};

const SelectCircle = props => (
<View style={[styles.selectCircle, styles.alignSelfCenter]}>
{props.isChecked && (
<Icon src={Expensicons.Checkmark} fill={themeColors.iconSuccessFill} />
)}
</View>
);

SelectCircle.propTypes = propTypes;
SelectCircle.defaultProps = defaultProps;
SelectCircle.displayName = 'SelectCircle';

export default SelectCircle;
6 changes: 6 additions & 0 deletions src/components/menuItemPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ const propTypes = {
/** Boolean whether to display the right icon */
shouldShowRightIcon: PropTypes.bool,

/** Should we make this selectable with a checkbox */
shouldShowSelectedState: PropTypes.bool,

/** Whether this item is selected */
isSelected: PropTypes.bool,

/** A boolean flag that gives the icon a green fill if true */
success: PropTypes.bool,

Expand Down
10 changes: 2 additions & 8 deletions src/pages/home/sidebar/OptionRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ import {optionPropTypes} from './optionPropTypes';
import Icon from '../../../components/Icon';
import * as Expensicons from '../../../components/Icon/Expensicons';
import MultipleAvatars from '../../../components/MultipleAvatars';
import themeColors from '../../../styles/themes/default';
import Hoverable from '../../../components/Hoverable';
import DisplayNames from '../../../components/DisplayNames';
import IOUBadge from '../../../components/IOUBadge';
import colors from '../../../styles/colors';
import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize';
import ExpensifyText from '../../../components/ExpensifyText';
import SelectCircle from '../../../components/SelectCircle';

const propTypes = {
/** Background Color of the Option Row */
Expand Down Expand Up @@ -203,13 +203,7 @@ const OptionRow = (props) => {
</ExpensifyText>
</View>
) : null}
{props.showSelectedState && (
<View style={[styles.selectCircle]}>
{props.isSelected && (
<Icon src={Expensicons.Checkmark} fill={themeColors.iconSuccessFill} />
)}
</View>
)}
{props.showSelectedState && <SelectCircle isChecked={props.isSelected} />}
</View>
</View>
{!props.hideAdditionalOptionStates && (
Expand Down
35 changes: 35 additions & 0 deletions src/stories/MenuItem.stories.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';
import MenuItem from '../components/MenuItem';
import Chase from '../../assets/images/bankicons/chase.svg';
import variables from '../styles/variables';

/**
* We use the Component Story Format for writing stories. Follow the docs here:
*
* https://storybook.js.org/docs/react/writing-stories/introduction#component-story-format
*/
const story = {
title: 'Components/MenuItem',
component: MenuItem,
};

// eslint-disable-next-line react/jsx-props-no-spreading
const Template = args => <MenuItem {...args} />;

// Arguments can be passed to the component by binding
// See: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
const Default = Template.bind({});
Default.args = {
title: 'Alberta Bobbeth Charleson',
description: 'Account ending in 1111',
shouldShowSelectedState: true,
isSelected: true,
icon: Chase,
iconHeight: variables.iconSizeExtraLarge,
iconWidth: variables.iconSizeExtraLarge,
};

export default story;
export {
Default,
};