File size: 2,958 Bytes
f5071ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import React from 'react';
import styled from 'styled-components';

import UserAvatar from '../../components/UserAvatar';
import ActivityIcon from '../../icons/Activity';
import LibraryIcon from '../../icons/Library';
import StoreIcon from '../../icons/Store';
import PersonWavingIcon from '../../icons/PersonWaving';
import closeIconUrl from '../../icons/close.svg';

import colors from '../../utils/colors';
import data from '../../data';

const StyledPrivateChannels = styled.div`
  margin: 20px 0 8px;

  .header {
    margin-top: 12px;
    padding: 9px 20px;

    font-size: 0.77em;
    text-transform: uppercase;
    color: #fff;
    opacity: 0.3;
  }
`;

const StyledChannel = styled.div`
  padding: 8px;
  margin: 1px 0 1px 8px;
  height: ${props => (props.smallHeight ? 40 : 42)}px;

  display: flex;
  align-items: center;
  font-size: 0.95em;

  color: #fff;
  cursor: pointer;
  border-radius: 3px;

  &.active {
    background-color: ${colors.privateChannelSelectedBackground};

    .avatar-wrapper .status {
      border-color: rgb(68, 72, 78);
    }
  }

  :hover .close {
    display: block;
  }

  :hover:not(.active) {
    background-color: ${colors.grayLight};

    .avatar-wrapper .status {
      border-color: ${colors.grayLight};
    }
  }

  &.active,
  &:hover {
    svg,
    span {
      opacity: 1;
      color: #fff;
    }
  }

  svg {
    margin-right: 18px;
    width: 24px;
    height: 24px;
    opacity: 0.6;
  }

  span {
    color: ${colors.channelName};
  }

  .avatar-wrapper {
    margin-right: 12px;
  }

  .username {
    flex: 1 1 auto;
  }

  .close {
    border: 0;
    width: 18px;
    height: 18px;
    display: none;
    justify-self: flex-end;

    background: url(${closeIconUrl}) 50% no-repeat;
    background-size: 18px 18px;
    opacity: 0.3;
    cursor: pointer;
  }
`;

const PrivateChannels = ({ selectedChannelId, onChannelClick }) => (
  <StyledPrivateChannels>
    <StyledChannel>
      <ActivityIcon />
      <span>Activity</span>
    </StyledChannel>
    <StyledChannel>
      <LibraryIcon />
      <span>Library</span>
    </StyledChannel>
    <StyledChannel>
      <StoreIcon />
      <span>Store</span>
    </StyledChannel>
    <StyledChannel>
      <PersonWavingIcon />
      <span>Friends</span>
    </StyledChannel>

    <div className="header">Direct Messages</div>

    {data.directMessages.map(directMessage => {
      const user = data.users[directMessage.userId];

      return (
        <StyledChannel
          key={directMessage.id}
          className={directMessage.id === selectedChannelId ? 'active' : ''}
          onClick={() => onChannelClick(null, directMessage.id)}
          smallHeight
        >
          <UserAvatar className="avatar-wrapper" avatarUrl={user.avatar} />
          <span className="username">{user.username}</span>
          <button className="close" />
        </StyledChannel>
      );
    })}
  </StyledPrivateChannels>
);

export default PrivateChannels;