SubNav.js 6.79 KB
Newer Older
Kim, Subin's avatar
Kim, Subin committed
1
import React, { useState, useEffect, useRef } from 'react';
Kim, Subin's avatar
Kim, Subin committed
2
import { Redirect } from 'react-router-dom';
Kim, Subin's avatar
Kim, Subin committed
3
import { Navbar, Nav, NavDropdown } from 'react-bootstrap';
Kim, Subin's avatar
Kim, Subin committed
4
5

function SubNav() {
Kim, Subin's avatar
Kim, Subin committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
    const [toggle, setToggle] = useState({ "dress": false, "outer": false, "top": false, "pants": false, "skirt": false, "training": false, "shoes": false });

    function handleMouseEnter(id) {
        setToggle({ [id]: true })
    }

    function handleMouseLeave(id) {
        setToggle({ [id]: false })
    }

    function handleToggle(id) {
        setToggle({ [id]: !toggle[`${id}`] })
    }

    function handleClick(url) {
        return <Redirect to={url} />
Kim, Subin's avatar
Kim, Subin committed
22
    }
Kim, Subin's avatar
Kim, Subin committed
23
24

    return (
이재연's avatar
이재연 committed
25
        <Navbar sticky="top" className="flex-nowrap" style={{ top: "62px", paddingTop: "0", paddingBottom: "0", backgroundColor: "#fff", overflowX: "auto" }}>
Kim, Subin's avatar
Kim, Subin committed
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
            <style type="text/css">
                {`
                .nav-link, .nav-link:hover, .nav-link:active {
                    color: #91877F;
                }
                
                .dropdown-toggle:after {
                    display: none;
                }

                .dropdown-menu {
                    background-color: #91877F;
                }

                .dropdown-item {
                    color: #f8f9fa;
                }

                .dropdown-item:focus, .dropdown-item:hover {
                    color: #91877F;
                }

                .dropdown-item:active {
                    background-color: #f8f9fa;
                }
                `}
            </style>
            <Nav>
                <NavDropdown title="DRESS" onMouseEnter={() => handleMouseEnter("dress")} onMouseLeave={() => handleMouseLeave("dress")} show={toggle.dress} toggle={() => handleToggle("dress")} onClick={() => handleClick("/dress")}>
                    <NavDropdown.Item href="/dress/long">LONG DRESS</NavDropdown.Item>
                    <NavDropdown.Item href="/dress/short">SHORT DRESS</NavDropdown.Item>
                    <NavDropdown.Item href="/dress/knit">KNIT DRESS</NavDropdown.Item>
                    <NavDropdown.Item href="/dress/shirt">SHIRT DRESS</NavDropdown.Item>
                    <NavDropdown.Item href="/dress/pattern">PATTERN DRESS</NavDropdown.Item>
                    <NavDropdown.Item href="/dress/bustier">BUSTIER DRESS</NavDropdown.Item>
                    <NavDropdown.Item href="/dress/two-piece">TWO-PIECE DRESS</NavDropdown.Item>
                </NavDropdown>
                <NavDropdown title="OUTER" onMouseEnter={() => handleMouseEnter("outer")} onMouseLeave={() => handleMouseLeave("outer")} show={toggle.outer} toggle={() => handleToggle("outer")} onClick={() => handleClick("/outer")}>
                    <NavDropdown.Item href="/outer/padded-jacket">PADDED JACKET</NavDropdown.Item>
                    <NavDropdown.Item href="/outer/jacket">JACKET</NavDropdown.Item>
                    <NavDropdown.Item href="/outer/jumper">JUMPER</NavDropdown.Item>
                    <NavDropdown.Item href="/outer/coat">COAT</NavDropdown.Item>
                    <NavDropdown.Item href="/outer/fleece">FLEECE</NavDropdown.Item>
                    <NavDropdown.Item href="/outer/cardigan_vest">CARDIGAN / VEST</NavDropdown.Item>
                </NavDropdown>
                <NavDropdown title="TOP" onMouseEnter={() => handleMouseEnter("top")} onMouseLeave={() => handleMouseLeave("top")} show={toggle.top} toggle={() => handleToggle("top")} onClick={() => handleClick("/top")}>
                    <NavDropdown.Item href="/top/knit">KNIT</NavDropdown.Item>
                    <NavDropdown.Item href="/top/hoody">HOODY</NavDropdown.Item>
                    <NavDropdown.Item href="/top/blouse">BLOUSE</NavDropdown.Item>
                    <NavDropdown.Item href="/top/shirt">SHIRT</NavDropdown.Item>
                    <NavDropdown.Item href="/top/sweatshirt">SWEATSHIRT</NavDropdown.Item>
                    <NavDropdown.Item href="/top/long-sleeve-shirt">LONG SLEEVE SHIRT</NavDropdown.Item>
                    <NavDropdown.Item href="/top/short-sleeved-shirt_sleeveless-shirt">SHORT SLEEVE / SLEEVELESS SHIRT</NavDropdown.Item>
                </NavDropdown>
                <NavDropdown title="PANTS" onMouseEnter={() => handleMouseEnter("pants")} onMouseLeave={() => handleMouseLeave("pants")} show={toggle.pants} toggle={() => handleToggle("pants")} onClick={() => handleClick("/pants")}>
                    <NavDropdown.Item href="/pants/jeans">JEANS</NavDropdown.Item>
                    <NavDropdown.Item href="/pants/skinny-jeans">SKINNY JEANS</NavDropdown.Item>
                    <NavDropdown.Item href="/pants/banding">BANDING PANTS</NavDropdown.Item>
                    <NavDropdown.Item href="/pants/wide-fit">WIDE-FIT PANTS</NavDropdown.Item>
                    <NavDropdown.Item href="/pants/boot-cut">BOOT-CUT PANTS</NavDropdown.Item>
                    <NavDropdown.Item href="/pants/straight-fit">STRAIGHT-FIT PANTS</NavDropdown.Item>
                    <NavDropdown.Item href="/pants/wide-fit">WIDE-FIT PANTS</NavDropdown.Item>
                    <NavDropdown.Item href="/pants/shorts">SHORTS</NavDropdown.Item>
                    <NavDropdown.Item href="/pants/trousers">TROUSERS</NavDropdown.Item>
                    <NavDropdown.Item href="/pants/leggings">LEGGINGS</NavDropdown.Item>
                    <NavDropdown.Item href="/pants/jumpsuit_overalls">JUMPSUIT / OVERALLS</NavDropdown.Item>
                </NavDropdown>
                <NavDropdown title="SKIRT" onMouseEnter={() => handleMouseEnter("skirt")} onMouseLeave={() => handleMouseLeave("skirt")} show={toggle.skirt} toggle={() => handleToggle("skirt")} onClick={() => handleClick("/skirt")}>
                    <NavDropdown.Item href="/skirt/long">LONG SKIRT</NavDropdown.Item>
                    <NavDropdown.Item href="/skirt/midi">MIDI SKIRT</NavDropdown.Item>
                    <NavDropdown.Item href="/skirt/mini">MINI SKIRT</NavDropdown.Item>
                </NavDropdown>
                <Nav.Item>
                    <Nav.Link href="/training">TRAINING</Nav.Link>
                </Nav.Item>
                <NavDropdown title="SHOES" onMouseEnter={() => handleMouseEnter("shoes")} onMouseLeave={() => handleMouseLeave("shoes")} show={toggle.shoes} toggle={() => handleToggle("shoes")} onClick={() => handleClick("/shoes")}>
                    <NavDropdown.Item href="/skirt/sneakers_slip-on">SNEAKERS / SLIP-ON</NavDropdown.Item>
                    <NavDropdown.Item href="/skirt/flat_loafer">FLAT / LOAFER</NavDropdown.Item>
                    <NavDropdown.Item href="/skirt/heel_pump">HEEL / PUMP</NavDropdown.Item>
                    <NavDropdown.Item href="/skirt/boots">BOOTS</NavDropdown.Item>
                    <NavDropdown.Item href="/skirt/sandal_slipper">SANDAL / SLIPPER</NavDropdown.Item>
                </NavDropdown>
            </Nav>
        </Navbar>
Kim, Subin's avatar
Kim, Subin committed
110
111
112
113
    )
}

export default SubNav