diff --git a/src/components/Avatar.js b/src/components/Avatar.js index 133def4f1e5f..45feb62b707c 100644 --- a/src/components/Avatar.js +++ b/src/components/Avatar.js @@ -1,4 +1,3 @@ -import _ from 'underscore'; import React, {PureComponent} from 'react'; import {Image} from 'react-native'; import PropTypes from 'prop-types'; @@ -30,10 +29,10 @@ class Avatar extends PureComponent { return ( ); } diff --git a/src/components/MultipleAvatars.js b/src/components/MultipleAvatars.js index b446942563ae..6b7ac3e167e8 100644 --- a/src/components/MultipleAvatars.js +++ b/src/components/MultipleAvatars.js @@ -1,55 +1,36 @@ import React, {memo} from 'react'; import PropTypes from 'prop-types'; import {Image, Text, View} from 'react-native'; -import globalStyles from '../styles/styles'; +import styles from '../styles/styles'; import Avatar from './Avatar'; const propTypes = { // Array of avatar URL avatarImageURLs: PropTypes.arrayOf(PropTypes.string), - // Whether this option is currently in focus so we can modify its style - optionIsFocused: PropTypes.bool, - // Set the sie of avatars size: PropTypes.oneOf(['default', 'small']), - // Styles to override the basic component styles - styles: PropTypes.shape({ - // Style for First Avatar on Multiple Avatars - // eslint-disable-next-line react/forbid-prop-types - singleAvatar: PropTypes.object, - - // Style for Second Avatar on Multiple Avatars - // eslint-disable-next-line react/forbid-prop-types - secondAvatar: PropTypes.object, + // Style for Second Avatar + // eslint-disable-next-line react/forbid-prop-types + secondAvatarStyle: PropTypes.arrayOf(PropTypes.object), - // Style for avatar Container - // eslint-disable-next-line react/forbid-prop-types - emptyAvatar: PropTypes.object, - }), }; const defaultProps = { avatarImageURLs: [], - optionIsFocused: false, size: 'default', - styles: {}, + secondAvatarStyle: [styles.secondAvatarHovered], }; const MultipleAvatars = ({ - avatarImageURLs, optionIsFocused, size, styles, + avatarImageURLs, size, secondAvatarStyle, }) => { - const avatarContainerStyles = [ - size === 'small' ? globalStyles.emptyAvatarSmall : globalStyles.emptyAvatar, styles.emptyAvatar, - ]; - const singleAvatarStyles = [ - size === 'small' ? globalStyles.singleAvatarSmall : globalStyles.singleAvatar, styles.singleAvatar, - ]; + const avatarContainerStyles = size === 'small' ? styles.emptyAvatarSmall : styles.emptyAvatar; + const singleAvatarStyles = size === 'small' ? styles.singleAvatarSmall : styles.singleAvatar; const secondAvatarStyles = [ - size === 'small' ? globalStyles.secondAvatarSmall : globalStyles.secondAvatar, - optionIsFocused ? globalStyles.focusedAvatar : globalStyles.avatar, - styles.secondAvatar, + size === 'small' ? styles.secondAvatarSmall : styles.secondAvatar, + ...secondAvatarStyle, ]; if (!avatarImageURLs.length) { @@ -86,8 +67,8 @@ const MultipleAvatars = ({ style={singleAvatarStyles} > {`+${avatarImageURLs.length - 1}`} diff --git a/src/components/OptionsList.js b/src/components/OptionsList.js index e1f2629136c0..091b7d6f1b2c 100644 --- a/src/components/OptionsList.js +++ b/src/components/OptionsList.js @@ -8,6 +8,9 @@ import optionPropTypes from './optionPropTypes'; import SectionList from './SectionList'; const propTypes = { + // option Background Color + optionBackgroundColor: PropTypes.string, + // Style for hovered state // eslint-disable-next-line react/forbid-prop-types optionHoveredStyle: PropTypes.object, @@ -71,6 +74,7 @@ const propTypes = { }; const defaultProps = { + optionBackgroundColor: undefined, optionHoveredStyle: undefined, contentContainerStyles: [], sections: [], @@ -153,6 +157,7 @@ class OptionsList extends Component { option={item} mode={this.props.optionMode} showTitleTooltip={this.props.showTitleTooltip} + backgroundColor={this.props.optionBackgroundColor} hoverStyle={this.props.optionHoveredStyle} optionIsFocused={!this.props.disableFocusOptions && this.props.focusedIndex === (index + section.indexOffset)} diff --git a/src/pages/home/HeaderView.js b/src/pages/home/HeaderView.js index a6c355ff1766..40e07a82daef 100644 --- a/src/pages/home/HeaderView.js +++ b/src/pages/home/HeaderView.js @@ -87,7 +87,10 @@ const HeaderView = (props) => { }} style={[styles.flexRow, styles.alignItemsCenter, styles.flex1]} > - + {hovered => ( @@ -112,6 +121,7 @@ const OptionRow = ({ styles.justifyContentBetween, styles.sidebarLink, styles.sidebarLinkInner, + {backgroundColor}, optionIsFocused ? styles.sidebarLinkActive : null, hovered && !optionIsFocused ? hoverStyle : null, ]} @@ -128,14 +138,12 @@ const OptionRow = ({ && ( ) } diff --git a/src/pages/home/sidebar/SidebarLinks.js b/src/pages/home/sidebar/SidebarLinks.js index 593af80cc973..7f24fa96180e 100644 --- a/src/pages/home/sidebar/SidebarLinks.js +++ b/src/pages/home/sidebar/SidebarLinks.js @@ -19,6 +19,7 @@ import {getDefaultAvatar} from '../../../libs/actions/PersonalDetails'; import KeyboardSpacer from '../../../components/KeyboardSpacer'; import CONST from '../../../CONST'; import {participantPropTypes} from './optionPropTypes'; +import themeColors from '../../../styles/themes/default'; const propTypes = { // Toggles the navigation menu open and closed @@ -145,6 +146,7 @@ class SidebarLinks extends React.Component { Navigation.navigate(ROUTES.getReportRoute(option.reportID)); this.props.onLinkClick(); }} + optionBackgroundColor={themeColors.sidebar} hideSectionHeaders showTitleTooltip disableFocusOptions={this.props.isSmallScreenWidth} diff --git a/src/styles/styles.js b/src/styles/styles.js index 9ef88778a851..2ba713405aba 100644 --- a/src/styles/styles.js +++ b/src/styles/styles.js @@ -865,6 +865,11 @@ const styles = { borderColor: 'transparent', }, + secondAvatarHovered: { + backgroundColor: themeColors.sidebarHover, + borderColor: themeColors.sidebarHover, + }, + secondAvatarSmall: { position: 'absolute', right: -13, @@ -915,8 +920,8 @@ const styles = { }, focusedAvatar: { - backgroundColor: themeColors.pillBG, - borderColor: themeColors.pillBG, + backgroundColor: themeColors.border, + borderColor: themeColors.border, }, emptyAvatar: { @@ -1405,6 +1410,12 @@ function getZoomSizingStyle(isZoomed) { }; } +function getSecondAvatarStyle(parentBGColor) { + return { + backgroundColor: parentBGColor, + borderColor: parentBGColor, + }; +} export default styles; export { getSafeAreaPadding, @@ -1415,4 +1426,5 @@ export { getNavigationModalCardStyle, getZoomCursorStyle, getZoomSizingStyle, + getSecondAvatarStyle, };