status-js-desktop/app/components/ChannelBox.js

22 lines
790 B
JavaScript
Raw Permalink Normal View History

2018-11-09 19:11:29 +00:00
// @flow
import React from 'react';
import ListItem from '@material-ui/core/ListItem';
import ListItemText from '@material-ui/core/ListItemText';
2018-11-09 23:22:02 +00:00
import { ChatContext } from '../context';
2018-11-09 19:11:29 +00:00
const ChannelBox = ({ channelName, message }) => (
2018-11-09 23:22:02 +00:00
<ChatContext.Consumer>
2018-11-12 17:50:52 +00:00
{({ setActiveChannel, currentChannel, channels }) =>
<ListItem onClick={() => setActiveChannel(channelName)} selected={currentChannel == channelName} style={{"cursor": "pointer", "padding": "0px 2px"}}>
<ListItemText primary={
<span style={{"color": "white"}}>
{channels[channelName].username ? `${channels[channelName].username}` : `#${channelName}`}
</span>
} secondary={message} />
</ListItem>
2018-11-09 23:22:02 +00:00
}
</ChatContext.Consumer>
2018-11-09 19:11:29 +00:00
);
export default ChannelBox;