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

[No QA] Fix the padding on the subscript avatar #18275

Merged
merged 4 commits into from
May 2, 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
4 changes: 3 additions & 1 deletion src/components/MultipleAvatars.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ const defaultProps = {
};

const MultipleAvatars = (props) => {
let avatarContainerStyles = props.size === CONST.AVATAR_SIZE.SMALL ? styles.emptyAvatarSmall : styles.emptyAvatar;
let avatarContainerStyles = props.size === CONST.AVATAR_SIZE.SMALL
? [styles.emptyAvatarSmall, styles.emptyAvatarMarginSmall]
: [styles.emptyAvatar, styles.emptyAvatarMargin];
const singleAvatarStyles = props.size === CONST.AVATAR_SIZE.SMALL ? styles.singleAvatarSmall : styles.singleAvatar;
const secondAvatarStyles = [
props.size === CONST.AVATAR_SIZE.SMALL ? styles.secondAvatarSmall : styles.secondAvatar,
Expand Down
1 change: 0 additions & 1 deletion src/components/OptionRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ class OptionRow extends Component {
secondaryAvatar={this.props.option.icons[1]}
mainTooltip={this.props.option.ownerEmail}
secondaryTooltip={this.props.option.subtitle}
size={CONST.AVATAR_SIZE.DEFAULT}
backgroundColor={
hovered && !this.props.optionIsFocused
? hoveredBackgroundColor
Expand Down
63 changes: 39 additions & 24 deletions src/components/SubscriptAvatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ const propTypes = {

/** Background color used for subscript avatar border */
backgroundColor: PropTypes.string,

/** Removes margin from around the avatar, used for the chat view */
noMargin: PropTypes.bool,
};

const defaultProps = {
Expand All @@ -37,36 +40,48 @@ const defaultProps = {
backgroundColor: themeColors.componentBG,
mainAvatar: {},
secondaryAvatar: {},
noMargin: false,
};

const SubscriptAvatar = props => (
<View style={props.size === CONST.AVATAR_SIZE.SMALL ? styles.emptyAvatarSmall : styles.emptyAvatar}>
<Tooltip text={props.mainTooltip}>
<Avatar
source={props.mainAvatar.source}
size={props.size === CONST.AVATAR_SIZE.SMALL ? CONST.AVATAR_SIZE.SMALL : CONST.AVATAR_SIZE.DEFAULT}
name={props.mainAvatar.name}
type={props.mainAvatar.type}
/>
</Tooltip>
<View style={[
props.size === CONST.AVATAR_SIZE.SMALL ? styles.secondAvatarSubscriptCompact : styles.secondAvatarSubscript,
StyleUtils.getBackgroundAndBorderStyle(props.backgroundColor),
StyleUtils.getAvatarBorderStyle(props.size, props.secondaryAvatar.type),
]}
>
<Tooltip text={props.secondaryTooltip}>
const SubscriptAvatar = (props) => {
const containerStyle = props.size === CONST.AVATAR_SIZE.SMALL ? styles.emptyAvatarSmall : styles.emptyAvatar;

// Default the margin style to what is normal for small or normal sized avatars
let marginStyle = props.size === CONST.AVATAR_SIZE.SMALL ? styles.emptyAvatarMargin : styles.emptyAvatarMarginSmall;

// Some views like the chat view require that there be no margins
if (props.noMargin) {
marginStyle = {};
}
return (
<View style={[containerStyle, marginStyle]}>
<Tooltip text={props.mainTooltip}>
<Avatar
source={props.secondaryAvatar.source}
size={props.size === CONST.AVATAR_SIZE.SMALL ? CONST.AVATAR_SIZE.SMALL_SUBSCRIPT : CONST.AVATAR_SIZE.SUBSCRIPT}
fill={themeColors.iconSuccessFill}
name={props.secondaryAvatar.name}
type={props.secondaryAvatar.type}
source={props.mainAvatar.source}
size={props.size === CONST.AVATAR_SIZE.SMALL ? CONST.AVATAR_SIZE.SMALL : CONST.AVATAR_SIZE.DEFAULT}
name={props.mainAvatar.name}
type={props.mainAvatar.type}
/>
</Tooltip>
<View style={[
props.size === CONST.AVATAR_SIZE.SMALL ? styles.secondAvatarSubscriptCompact : styles.secondAvatarSubscript,
StyleUtils.getBackgroundAndBorderStyle(props.backgroundColor),
StyleUtils.getAvatarBorderStyle(props.size, props.secondaryAvatar.type),
]}
>
<Tooltip text={props.secondaryTooltip}>
<Avatar
source={props.secondaryAvatar.source}
size={props.size === CONST.AVATAR_SIZE.SMALL ? CONST.AVATAR_SIZE.SMALL_SUBSCRIPT : CONST.AVATAR_SIZE.SUBSCRIPT}
fill={themeColors.iconSuccessFill}
name={props.secondaryAvatar.name}
type={props.secondaryAvatar.type}
/>
</Tooltip>
</View>
</View>
</View>
);
);
};

SubscriptAvatar.displayName = 'SubscriptAvatar';
SubscriptAvatar.propTypes = propTypes;
Expand Down
3 changes: 2 additions & 1 deletion src/pages/home/report/ReportActionItemSingle.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ const ReportActionItemSingle = (props) => {
<SubscriptAvatar
mainAvatar={{source: avatarSource, type: CONST.ICON_TYPE_AVATAR}}
secondaryAvatar={ReportUtils.getIcons(props.report, {})[0]}
mainTooltip={props.report.ownerEmail}
mainTooltip={actorEmail}
secondaryTooltip={ReportUtils.getReportName(props.report)}
noMargin
/>
) : (
<Tooltip text={actorEmail}>
Expand Down
10 changes: 8 additions & 2 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -1816,17 +1816,23 @@ const styles = {
},

emptyAvatar: {
marginRight: variables.avatarChatSpacing,
height: variables.avatarSizeNormal,
width: variables.avatarSizeNormal,
},

emptyAvatarSmall: {
marginRight: variables.avatarChatSpacing - 4,
height: variables.avatarSizeSmall,
width: variables.avatarSizeSmall,
},

emptyAvatarMargin: {
marginRight: variables.avatarChatSpacing,
},

emptyAvatarMarginSmall: {
marginRight: variables.avatarChatSpacing - 4,
},

modalViewContainer: {
alignItems: 'center',
flex: 1,
Expand Down