Skip to content

Instantly share code, notes, and snippets.

@hieptl
Created November 13, 2021 15:35
Show Gist options
  • Save hieptl/df9fc278c13f3ebb9a376ccd233fe8fc to your computer and use it in GitHub Desktop.
Save hieptl/df9fc278c13f3ebb9a376ccd233fe8fc to your computer and use it in GitHub Desktop.
Sidebar.js - Discord Clone
const Sidebar = (props) => {
const { friend, onItemClicked } = props;
if (!friend) {
return <></>
}
const selectFriend = () => {
onItemClicked(friend);
};
return (
<div className="friends__list-item" onClick={selectFriend}>
<div className="friends__list-item-avatar">
<div className={`friends__list-item-status ${friend.status === 'available' ? 'friends__list-item-status--online' : ''}`}></div>
<img src={friend.avatar} alt="friend-avatar" />
</div>
<span>{friend.name}</span>
</div>
);
};
export default Sidebar;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment