File size: 1,842 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
import React from 'react';
import styled from 'styled-components';
import colors from '../../utils/colors';
import DiscordIcon from '../../icons/Discord';

const StyledGuildIcon = styled.a.attrs({ href: '#' })`
  margin-top: 10px;
  width: 50px;
  height: 50px;

  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;

  background: ${props => (props.selected ? colors.primary : colors.grayNormal)};
  background-image: ${props => props.icon && `url(${props.icon})`};
  background-size: cover;
  background-position: center;
  border-radius: ${props => (props.selected ? '15px' : '50%')};

  transition: 0.3s ease;
  text-decoration: none;
  color: #fff;

  &.add {
    background: transparent;
    border: 1px dashed ${colors.addGuildBorder};
    color: ${colors.addGuildBorder};

    font-weight: 400;
    font-size: 2.1em;

    :hover {
      border-color: hsla(0, 0%, 100%, 0.75);
      color: hsla(0, 0%, 100%, 0.75);
    }
  }

  :hover:not(.add) {
    background-color: ${colors.primary};
    border-radius: 15px;
  }

  ::before {
    content: ' ';
    display: ${props => (props.selected ? 'block' : 'none')};
    width: 10px;
    height: 40px;
    position: absolute;
    left: -15px;
    border-radius: 20px;
    background: #fff;
  }
`;

const HomeIcon = styled(DiscordIcon)`
  color: ${colors.homeIcon};
  width: 100%;
  height: 100%;
  padding: 5px;
`;

const GuildIcon = ({ name, icon, selected, isHome, isAdd, onClick, ...props }) => {
  let content = name;
  if (isHome) {
    content = <HomeIcon />;
  }
  if (isAdd) {
    content = '+';
  }

  return (
    <StyledGuildIcon
      selected={selected}
      icon={icon}
      onClick={onClick}
      className={isAdd ? 'add' : ''}
      {...props}
    >
      {!icon ? content : ''}
    </StyledGuildIcon>
  );
};

export default GuildIcon;