Cleanup user list

This commit is contained in:
Tom Moor
2018-05-24 23:07:44 -07:00
parent e2144051df
commit 54e5037aaf
3 changed files with 58 additions and 73 deletions

View File

@@ -0,0 +1,45 @@
// @flow
import * as React from 'react';
import styled from 'styled-components';
import { color } from 'shared/styles/constants';
import UserMenu from 'menus/UserMenu';
import Avatar from 'components/Avatar';
import ListItem from 'components/List/Item';
import type { User } from '../../../types';
type Props = {
user: User,
isCurrentUser: boolean,
};
const UserListItem = ({ user, isCurrentUser }: Props) => {
return (
<ListItem
key={user.id}
title={user.name}
image={<Avatar src={user.avatarUrl} size={40} />}
subtitle={
<React.Fragment>
{user.username ? user.username : user.email}
{user.isAdmin && <Badge admin={user.isAdmin}>Admin</Badge>}
{user.isSuspended && <Badge>Suspended</Badge>}
</React.Fragment>
}
actions={isCurrentUser ? undefined : <UserMenu user={user} />}
/>
);
};
const Badge = styled.span`
margin-left: 10px;
padding: 2px 6px 3px;
background-color: ${({ admin }) => (admin ? color.primary : color.smokeDark)};
color: ${({ admin }) => (admin ? color.white : color.text)};
border-radius: 2px;
font-size: 11px;
text-transform: uppercase;
font-weight: normal;
`;
export default UserListItem;