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

cleanup for GSD layout #2104

Merged
merged 9 commits into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 3 additions & 4 deletions src/components/Avatar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import _ from 'underscore';
import React, {PureComponent} from 'react';
import {Image} from 'react-native';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -31,10 +30,10 @@ class Avatar extends PureComponent {
<Image
ref={el => this.image = el}
source={{uri: this.props.source}}
style={_.union([
style={[
this.props.size === 'small' ? styles.avatarSmall : styles.avatarNormal,
this.props.style,
])}
...this.props.style,
]}
/>
);
}
Expand Down
40 changes: 13 additions & 27 deletions src/components/MultipleAvatars.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
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 = {
Expand All @@ -14,42 +14,28 @@ const propTypes = {
// 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
secondAvatarStyle: PropTypes.object,

// Style for Second Avatar on Multiple Avatars
// eslint-disable-next-line react/forbid-prop-types
secondAvatar: 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: {},
};

const MultipleAvatars = ({
avatarImageURLs, optionIsFocused, size, styles,
avatarImageURLs, optionIsFocused, 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,
optionIsFocused ? styles.focusedAvatar : styles.avatar,
secondAvatarStyle,
];

if (!avatarImageURLs.length) {
Expand Down Expand Up @@ -86,8 +72,8 @@ const MultipleAvatars = ({
style={singleAvatarStyles}
>
<Text style={size === 'small'
? globalStyles.avatarInnerTextSmall
: globalStyles.avatarInnerText}
? styles.avatarInnerTextSmall
: styles.avatarInnerText}
>
{`+${avatarImageURLs.length - 1}`}
</Text>
Expand Down
7 changes: 1 addition & 6 deletions src/pages/home/sidebar/OptionRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,7 @@ const OptionRow = ({
avatarImageURLs={option.icons}
optionIsFocused={optionIsFocused}
size={mode === 'compact' ? 'small' : 'default'}
styles={hovered && !optionIsFocused && {
secondAvatar: {
backgroundColor: themeColors.sidebarHover,
borderColor: themeColors.sidebarHover,
},
}}
secondAvatarStyle={hovered && !optionIsFocused && styles.secondAvatarHovered}
parasharrajat marked this conversation as resolved.
Show resolved Hide resolved
/>
)
}
Expand Down
5 changes: 5 additions & 0 deletions src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,11 @@ const styles = {
borderColor: 'transparent',
},

secondAvatarHovered: {
backgroundColor: themeColors.sidebarHover,
borderColor: themeColors.sidebarHover,
},

secondAvatarSmall: {
position: 'absolute',
right: -13,
Expand Down