Passed
Push — master ( f602d8...7b3414 )
by Huu-Phat
02:55 queued 11s
created

modules/home/components/certification/CertIcon.js   A

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 141
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
eloc 45
mnd 1
bc 1
fnc 0
dl 0
loc 141
ccs 25
cts 25
cp 1
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
rs 10
1
import React from 'react'
2
import styled from 'styled-components/macro'
3
import Icon from '~/modules/home/components/common/Icon'
4
import PropTypes from 'prop-types'
5
6 2
const CertIcon = ({ id, itemSelected, name }) => {
7 4
  return itemSelected == id ? (
8
    <ActiveIcon name={name} />
9
  ) : (
10
    <InactiveIcon name={name} />
11
  )
12
}
13
14 2
CertIcon.propTypes = {
15
  id: PropTypes.number,
16
  itemSelected: PropTypes.any,
17
  name: PropTypes.string
18
}
19
20
export default CertIcon
21
22
const ItemIcon = styled(Icon)`
23
  top: 0;
24
  left: 50%;
25
  display: block;
26
  width: 180px;
27
  height: 180px;
28
  margin-left: 104%;
29
  text-align: center;
30 4
  background-color: ${props => props.theme.colors.colorLight};
31 4
  border: 1px solid ${props => props.theme.colors.colorLight};
32
  border-radius: 50%;
33 4
  box-shadow: 3px 4px 8px -4px ${props => props.theme.colors.colorDark};
34
  transition: all 0.5s;
35
36
  @media screen and (max-width: 992px) {
37
    width: 160px;
38
    height: 160px;
39
    margin-left: 35%;
40
  }
41
42
  @media screen and (max-width: 768px) {
43
    width: 125px;
44
    height: 125px;
45
    margin-left: 5%;
46
  }
47
48
  @media screen and (max-width: 576px) {
49
    width: 120px;
50
    height: 120px;
51
    margin-left: 20%;
52
  }
53
54
  @media screen and (max-width: 480px) {
55
    width: 90px;
56
    height: 90px;
57
    margin-left: 15%;
58
  }
59
60
  @media screen and (max-width: 375px) {
61
    width: 80px;
62
    height: 80px;
63
    margin-left: -53%;
64
  }
65
66
  @media screen and (max-width: 320px) {
67
    width: 70px;
68
    height: 70px;
69
    margin-left: -40%;
70
  }
71
72
  &::before {
73 4
    font-family: ${props => props.theme.fonts.fontCert};
74
    font-style: normal;
75
    font-weight: normal;
76
    font-size: 80px;
77
    line-height: 180px;
78 4
    color: ${props => props.theme.colors.colorLight};
79
    cursor: default;
80
    transition: all 0.5s;
81
82
    @media screen and (max-width: 992px) {
83
      font-size: 70px;
84
      line-height: 160px;
85
    }
86
87
    @media screen and (max-width: 768px) {
88
      font-size: 63px;
89
      line-height: 127px;
90
    }
91
92
    @media screen and (max-width: 576px) {
93
      font-size: 56px;
94
      line-height: 114px;
95
    }
96
97
    @media screen and (max-width: 480px) {
98
      font-size: 47px;
99
      line-height: 88px;
100
    }
101
102
    @media screen and (max-width: 375px) {
103
      font-size: 40px;
104
      line-height: 79px;
105
    }
106
107
    @media screen and (max-width: 320px) {
108
      font-size: 35px;
109
      line-height: 71px;
110
    }
111
  }
112
`
113
114
const InactiveIcon = styled(ItemIcon)`
115
  &::before {
116 3
    text-shadow: -1px -1px 0 ${props => props.theme.colors.colorDark},
117 3
      0 -1px 0 ${props => props.theme.colors.colorDark},
118 3
      1px -1px 0 ${props => props.theme.colors.colorDark},
119 3
      1px 0 0 ${props => props.theme.colors.colorDark},
120 3
      1px 1px 0 ${props => props.theme.colors.colorDark},
121 3
      0 1px 0 ${props => props.theme.colors.colorDark},
122 3
      -1px 1px 0 ${props => props.theme.colors.colorDark},
123 3
      -1px 0 0 ${props => props.theme.colors.colorDark};
124
  }
125
`
126
127
const ActiveIcon = styled(ItemIcon)`
128 1
  border-color: ${props => props.theme.colors.colorAccent};
129
130
  &::before {
131 1
    text-shadow: -1px -1px 0 ${props => props.theme.colors.colorAccent},
132 1
      0 -1px 0 ${props => props.theme.colors.colorAccent},
133 1
      1px -1px 0 ${props => props.theme.colors.colorAccent},
134 1
      1px 0 0 ${props => props.theme.colors.colorAccent},
135 1
      1px 1px 0 ${props => props.theme.colors.colorAccent},
136 1
      0 1px 0 ${props => props.theme.colors.colorAccent},
137 1
      -1px 1px 0 ${props => props.theme.colors.colorAccent},
138 1
      -1px 0 0 ${props => props.theme.colors.colorAccent};
139
  }
140
`
141