-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IMPROVEMENT] User status icons (#2991)
* Add status and teams * Update icons, icon size and getUsersPresence * Minor changes * Refactor RoomTypeIcon * Minor tweaks * Update unit tests * Minor fixes * Fix styles * Small refactor * Update jest Co-authored-by: Diego Mello <diegolmello@gmail.com>
- Loading branch information
1 parent
8bc8a07
commit 25b7115
Showing
26 changed files
with
1,465 additions
and
549 deletions.
There are no files selected for viewing
1,702 changes: 1,345 additions & 357 deletions
1,702
__tests__/__snapshots__/Storyshots.test.js.snap
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,37 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { View } from 'react-native'; | ||
import { STATUS_COLORS, themes } from '../../constants/colors'; | ||
import { CustomIcon } from '../../lib/Icons'; | ||
import { STATUS_COLORS } from '../../constants/colors'; | ||
|
||
const Status = React.memo(({ | ||
status, size, style, theme, ...props | ||
}) => ( | ||
<View | ||
style={ | ||
[ | ||
style, | ||
{ | ||
borderRadius: size, | ||
width: size, | ||
height: size, | ||
backgroundColor: STATUS_COLORS[status] ?? STATUS_COLORS.offline, | ||
borderColor: themes[theme].backgroundColor | ||
} | ||
]} | ||
{...props} | ||
/> | ||
)); | ||
status, size, style, ...props | ||
}) => { | ||
const name = `status-${ status }`; | ||
const isNameValid = CustomIcon.hasIcon(name); | ||
const iconName = isNameValid ? name : 'status-offline'; | ||
const calculatedStyle = [{ | ||
width: size, height: size, textAlignVertical: 'center' | ||
}, style]; | ||
|
||
return ( | ||
<CustomIcon | ||
style={calculatedStyle} | ||
size={size} | ||
name={iconName} | ||
color={STATUS_COLORS[status] ?? STATUS_COLORS.offline} | ||
{...props} | ||
/> | ||
); | ||
}); | ||
|
||
Status.propTypes = { | ||
status: PropTypes.string, | ||
size: PropTypes.number, | ||
style: PropTypes.any, | ||
theme: PropTypes.string | ||
style: PropTypes.any | ||
}; | ||
Status.defaultProps = { | ||
status: 'offline', | ||
size: 16, | ||
theme: 'light' | ||
size: 32 | ||
}; | ||
|
||
export default Status; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,19 @@ | ||
import React from 'react'; | ||
import React, { memo } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { connect } from 'react-redux'; | ||
|
||
import Status from './Status'; | ||
import { withTheme } from '../../theme'; | ||
|
||
class StatusContainer extends React.PureComponent { | ||
static propTypes = { | ||
style: PropTypes.any, | ||
size: PropTypes.number, | ||
status: PropTypes.string, | ||
theme: PropTypes.string | ||
}; | ||
const StatusContainer = memo(({ style, size = 32, status }) => <Status size={size} style={style} status={status} />); | ||
|
||
static defaultProps = { | ||
size: 16 | ||
} | ||
|
||
render() { | ||
const { | ||
style, size, status, theme | ||
} = this.props; | ||
return <Status size={size} style={style} status={status} theme={theme} />; | ||
} | ||
} | ||
StatusContainer.propTypes = { | ||
style: PropTypes.any, | ||
size: PropTypes.number, | ||
status: PropTypes.string | ||
}; | ||
|
||
const mapStateToProps = (state, ownProps) => ({ | ||
status: state.meteor.connected ? (state.activeUsers[ownProps.id] && state.activeUsers[ownProps.id].status) : 'offline' | ||
status: state.meteor.connected ? (state.activeUsers[ownProps.id] && state.activeUsers[ownProps.id].status) : 'loading' | ||
}); | ||
|
||
export default connect(mapStateToProps)(withTheme(StatusContainer)); | ||
export default connect(mapStateToProps)(StatusContainer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.