citylist.tsx 2.96 KB
Newer Older
Kim, MinGyu's avatar
Kim, MinGyu committed
1
import React, { MouseEventHandler, useState } from "react";
백승민's avatar
theme1    
백승민 committed
2

백승민's avatar
백승민 committed
3
4
type CityProps = {
  handleClick: MouseEventHandler;
Kim, MinGyu's avatar
Kim, MinGyu committed
5
};
백승민's avatar
백승민 committed
6

Kim, MinGyu's avatar
Kim, MinGyu committed
7
export default function Citylist({ handleClick }: CityProps) {
Kim, MinGyu's avatar
Kim, MinGyu committed
8
9
  const [active, setActive] = useState(0);

백승민's avatar
css    
백승민 committed
10
11
  const onactive = "text-start  px-5 py-2 whitespace-nowrap w-full border-b-4 md:border-b-0 md:border-r-4 border-sky-500";
  const offactive = "text-start  px-5 py-2 whitespace-nowrap w-full  ";
Kim, MinGyu's avatar
Kim, MinGyu committed
12
13
14
15
16

  const clickActive = (a: number) => {
    setActive(a);
  };

백승민's avatar
백승민 committed
17
  return (
백승민's avatar
css    
백승민 committed
18
19
    <div className="overflow-auto w-full  flex flex-row md:flex-col md:mr-24">
      {/* <div className="text-start px-5 py-2 bg-white whitespace-nowrap">
Kim, MinGyu's avatar
Kim, MinGyu committed
20
        도시
백승민's avatar
css    
백승민 committed
21
      </div> */}
Kim, MinGyu's avatar
Kim, MinGyu committed
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
      <div onClick={() => clickActive(1)}>
        <button
          id={"Seoul"}
          onClick={handleClick}
          className={active === 1 ? onactive : offactive}
        >
          서울
        </button>
      </div>
      <div onClick={() => clickActive(2)}>
        <button
          id={"Busan"}
          onClick={handleClick}
          className={active === 2 ? onactive : offactive}
        >
          부산
        </button>
      </div>
      <div onClick={() => clickActive(3)}>
        <button
          id={"Incheon"}
          onClick={handleClick}
          className={active === 3 ? onactive : offactive}
        >
          인천
        </button>
      </div>
      <div onClick={() => clickActive(4)}>
        <button
          id={"Daegoo"}
          onClick={handleClick}
          className={active === 4 ? onactive : offactive}
        >
          대구
        </button>
      </div>
      <div onClick={() => clickActive(5)}>
        <button
          id={"Gwangjoo"}
          onClick={handleClick}
          className={active === 5 ? onactive : offactive}
        >
          광주
        </button>
      </div>
      <div onClick={() => clickActive(6)}>
        <button
          id={"Daejeon"}
          onClick={handleClick}
          className={active === 6 ? onactive : offactive}
        >
          대전
        </button>
      </div>
      <div onClick={() => clickActive(7)}>
        <button
          id={"Woolsan"}
          onClick={handleClick}
          className={active === 7 ? onactive : offactive}
        >
          울산
        </button>
      </div>
      <div onClick={() => clickActive(8)}>
        <button
          id={"Sejong"}
          onClick={handleClick}
          className={active === 8 ? onactive : offactive}
        >
          세종
        </button>
      </div>
      <div onClick={() => clickActive(9)}>
        <button
          id={"Dokdo"}
          onClick={handleClick}
          className={active === 9 ? onactive : offactive}
        >
          독도
        </button>
      </div>
      <div onClick={() => clickActive(10)}>
        <button
          id={"Jeju"}
          onClick={handleClick}
          className={active === 10 ? onactive : offactive}
        >
          제주
        </button>
      </div>
Kim, MinGyu's avatar
Kim, MinGyu committed
112
113
    </div>
    // Citylist Page
백승민's avatar
백승민 committed
114
  );
Kim, MinGyu's avatar
Kim, MinGyu committed
115
}