mastodon/app/javascript/mastodon/features/ui/components/messaging/contacts-list.js

91 lines
2.1 KiB
JavaScript
Raw Normal View History

2019-12-21 15:16:13 +01:00
import React from 'react';
import PropTypes from 'prop-types';
2019-12-18 16:16:08 +01:00
export default class ContactsList extends React.PureComponent {
2019-12-18 16:16:08 +01:00
static propTypes = {
showList : PropTypes.bool,
contactList : PropTypes.array,
conversationList: PropTypes.array,
};
static defaultProps = {
showList : true,
contactList: ['machin', 'bidule', 'chuck norris'],
};
2019-12-18 16:16:08 +01:00
constructor(props) {
super(props);
this.state = {
showList : true,
contactList : ['machin', 'bidule', 'chuck norris'],
conversationList: ['machin', 'bidule', 'chuck norris'],
};
2019-12-18 16:16:08 +01:00
}
submitCompose() {
console.log('submit message');
}
toggleList = () => {
console.log('toggle');
this.setState((state) => {
console.log('state.showList', state.showList);
return {
showList: !state.showList,
};
});
};
2019-12-18 16:16:08 +01:00
render() {
2019-12-21 15:16:13 +01:00
// return (
// <div >
// liste de contacts
2019-12-21 15:16:13 +01:00
// </div >
// );
const renderedList = this.state.contactList.forEach(elem => {
return (
<li className='contact-item'>
{elem}
</li >
);
});
2019-12-21 15:16:13 +01:00
return (
<div className='messaging-container'>
<div className='messaging-box'>
<div className='title column-header'>
2019-12-21 15:16:13 +01:00
<i
role='img'
className='fa fa-envelope column-header__icon fa-fw'
/>
Messaging box
2019-12-21 15:16:13 +01:00
</div >
<div className='user-list column-header'>
<h2 className='title'>la liste de {this.state.contactList.lengh} contacts
2019-12-21 15:16:13 +01:00
<button
className='btn btn-primary'
onClick={this.toggleList}
>
<i className='fa fa-caret-up' />
</button >
</h2 >
{this.state.showList && (
<div className='contact-list-container'>
<h3 >show list</h3 >
<ul className='contact-list'>
{renderedList}
</ul >
</div >
)}
</div >
2019-12-21 15:16:13 +01:00
</div >
</div >
);
2019-12-18 16:16:08 +01:00
}
}