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

modules/home/components/Home.js   A

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 118
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
eloc 60
mnd 1
bc 1
fnc 0
dl 0
loc 118
ccs 19
cts 19
cp 1
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
rs 10
1
import React from 'react'
2
import { HOME } from '~/modules/home/consts/pages'
3
import styled from 'styled-components/macro'
4
import { Translate } from 'react-localize-redux'
5
import Container from 'react-bootstrap/Container'
6
import Anchor from '~/modules/home/components/common/Anchor'
7
import Typist from '~/modules/home/components/common/Typist'
8
import useWindowDimensions from '~/modules/core/utils/useWindowDimensions'
9
10 1
const Home = () => {
11 1
  const { width } = useWindowDimensions()
12 1
  return (
13
    <HomeSection>
14
      <Anchor id={HOME} />
15
      <Background />
16
      <Overlay>
17
        <Container>
18
          <Header>
19
            <TitleName>
20
              <Translate id="Name" />
21
            </TitleName>
22
            <TitleJob>
23
              <Typist>{getTexts(width)}</Typist>
24
            </TitleJob>
25
          </Header>
26
        </Container>
27
      </Overlay>
28
    </HomeSection>
29
  )
30
}
31
32 1
export const getTexts = width => {
33 3
  const typingTexts = ['Job']
34
35 3
  const secondText = width < 460 ? 'Welcome-short' : 'Welcome'
36 3
  typingTexts.push(secondText)
37
38 6
  return typingTexts.map(item => <Translate key={item} id={item} />)
39
}
40
41
const HomeSection = styled.section`
42
  position: relative;
43
  width: 100%;
44
  overflow: hidden;
45
46
  &::after {
47
    content: '';
48
    position: absolute;
49
    left: 0;
50
    bottom: 0;
51
    display: block;
52
    width: 100%;
53
    height: 0;
54
    clear: both;
55 1
    box-shadow: 0 0 2px 1px ${props => props.theme.colors.colorDark};
56
  }
57
`
58
59
const TitleName = styled.h1`
60
  margin-bottom: 10px;
61
  font-size: 100px;
62 1
  text-shadow: 1px 1px 1px ${props => props.theme.colors.colorDark};
63
  width: fit-content;
64 1
  background: ${props => props.theme.titleBgColor};
65
66
  @media screen and (max-width: 1200px) {
67
    font-size: 75px;
68
  }
69
70
  @media screen and (max-width: 800px) {
71
    font-size: 50px;
72
  }
73
`
74
75
const TitleJob = styled.h2`
76
  width: fit-content;
77 1
  background: ${props => props.theme.titleBgColor};
78 1
  color: ${props => props.theme.colors.colorLight};
79 1
  font-family: ${props => props.theme.fonts.fontTrebuchet};
80 1
  text-shadow: 1px 1px 2px ${props => props.theme.colors.colorDark};
81
`
82
83
const Background = styled.div`
84
  position: absolute;
85
  min-width: 100%;
86
  min-height: 100%;
87
  z-index: 0;
88 1
  background: transparent url(${props => props.theme.images.background}) center
89
    0 no-repeat;
90
  background-attachment: fixed;
91
  background-size: cover;
92
`
93
94
const Overlay = styled.div`
95
  position: relative;
96
  width: 100%;
97
  height: 100%;
98 1
  background-color: ${props => props.theme.images.overlayBgColor};
99
  zoom: 1;
100 1
  background-image: url(${props => props.theme.images.overlay});
101
  background-repeat: repeat;
102
  background-attachment: fixed;
103
`
104
105
const Header = styled.header`
106 1
  padding: ${props => props.theme.headerPadding};
107
  text-align: left;
108
109
  @media screen and (max-width: 800px) {
110
    text-align: center;
111
  }
112
113
  @media screen and (max-width: 600px) {
114
    padding: 100px 0 300px;
115
  }
116
`
117
export default Home
118