-
Notifications
You must be signed in to change notification settings - Fork 2
/
Header.tsx
119 lines (105 loc) · 2.76 KB
/
Header.tsx
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
import React from 'react';
import Link from 'next/link';
import { Logo } from '../../assets';
import { media } from '@styles/theme';
import styled from 'styled-components';
import { useRouter } from 'next/router';
import Image from 'next/image';
import sizeMe from 'react-sizeme';
import { ISizeProps } from 'types/main';
import MobileHeader from './MobileHeader';
interface IStyledProps {
current: boolean;
}
const Header = (props: ISizeProps) => {
const router = useRouter();
const currentPath = router.pathname;
const { width } = props.size;
const isMobile = width <= 880 ? true : false;
const onClickLogo = () => {
document.location.href = '/';
};
return (
<>
{isMobile ? (
<MobileHeader />
) : (
<Positioner>
<WhiteBackground>
<LogoWrap current={currentPath === '/'} onClick={onClickLogo}>
<Image src={Logo} id="Logo" alt="colfume logo" />
</LogoWrap>
<Layout>
<Category>
<Link href="/product" passHref>
<CategoryBtn id="Product" current={currentPath === '/product'}>
Product
</CategoryBtn>
</Link>
<Link href="/test" passHref>
<CategoryBtn id="ColorTest" current={currentPath === '/test'}>
Color Test
</CategoryBtn>
</Link>
<Link href="/search" passHref>
<CategoryBtn id="Search" current={currentPath === '/search'}>
Search
</CategoryBtn>
</Link>
</Category>
</Layout>
</WhiteBackground>
</Positioner>
)}
</>
);
};
const Positioner = styled.div`
display: flex;
position: fixed;
top: 0;
z-index: 1;
`;
const WhiteBackground = styled.div`
border-bottom: 0.2rem solid ${({ theme }) => theme.colors.gray2};
background: ${({ theme }) => theme.colors.white};
width: 100vw;
height: 7.2rem;
`;
const Layout = styled.div`
display: flex;
width: 100%;
height: 7.2rem;
`;
const LogoWrap = styled.div<IStyledProps>`
position: fixed;
top: 1.62rem;
margin-left: 5%;
cursor: pointer;
@media all and (min-width: 1025px) {
width: 14rem;
}
`;
const Category = styled.div`
display: flex;
margin: auto;
#Product {
width: 10rem;
}
#ColorTest {
width: 12.7rem;
}
#Search {
width: 8.8rem;
}
`;
const CategoryBtn = styled.span<IStyledProps>`
margin: 0 3rem;
border-bottom: 0.1rem solid ${props => (props.current ? '#3e3e3e' : 'transparent')};
cursor: pointer;
text-align: center;
line-height: 2.674rem;
font-family: 'Junge';
font-size: 2.2rem;
`;
export default sizeMe({ monitorHeight: true })(Header);