Scaffold chat click

This commit is contained in:
Alex Gleason 2020-08-25 11:33:51 -05:00
parent 8823743605
commit 7693fb87cc
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
5 changed files with 53 additions and 4 deletions

View File

@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
import { injectIntl, FormattedMessage } from 'react-intl';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { fetchChats } from 'soapbox/actions/chats';
import Account from 'soapbox/components/account';
import ChatListAccount from './chat_list_account';
const mapStateToProps = state => ({
chats: state.get('chats'),
@ -23,6 +23,10 @@ class ChatList extends ImmutablePureComponent {
this.props.dispatch(fetchChats());
}
handleClickChat = () => {
// TODO: Open or focus chat panel
}
render() {
const { chats } = this.props;
@ -34,7 +38,10 @@ class ChatList extends ImmutablePureComponent {
<div className='chat-list__content'>
{chats.toList().map(chat => (
<div className='chat-list-item'>
<Account account={chat.get('account')} />
<ChatListAccount
account={chat.get('account')}
onClick={this.handleClickChat}
/>
</div>
))}
</div>

View File

@ -0,0 +1,38 @@
import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import PropTypes from 'prop-types';
import Avatar from '../../../components/avatar';
import DisplayName from '../../../components/display_name';
import ImmutablePureComponent from 'react-immutable-pure-component';
export default class ChatListAccount extends ImmutablePureComponent {
static propTypes = {
account: ImmutablePropTypes.map.isRequired,
onClick: PropTypes.func,
};
handleClick = () => {
this.props.onClick(this.props.account);
}
render() {
const { account } = this.props;
if (!account) return null;
return (
<div className='account'>
<button className='floating-link' onClick={this.handleClick} />
<div className='account__wrapper'>
<div key={account.get('id')} className='account__display-name'>
<div className='account__avatar-wrapper'>
<Avatar account={account} size={36} />
</div>
<DisplayName account={account} />
</div>
</div>
</div>
);
}
}

View File

@ -327,9 +327,10 @@
.account {
padding: 10px;
position: relative;
&:not(:last-of-type) {
border-bottom: 1px solid var(--brand-color--med);
border-bottom: 1px solid var(--brand-color--med);
}
&.compact {

View File

@ -228,4 +228,8 @@ noscript {
left: 0;
position: absolute;
z-index: 9999;
background: transparent;
border: 0;
margin: 0;
padding: 0;
}

View File

@ -16,7 +16,6 @@
&__content {
background: var(--foreground-color);
padding: 10px;
}
&__actions {