citylist.tsx 2.92 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
10
11
12
13
14
15
16
  const [active, setActive] = useState(0);

  const onactive = "text-start  px-5 py-2 underline whitespace-nowrap";
  const offactive = "text-start  px-5 py-2 whitespace-nowrap";

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

백승민's avatar
백승민 committed
17
  return (
18
    <div className="overflow-auto w-full  flex flex-row md:flex-col md:mr-24 bg-red-100 shadow-lg">
Kim, MinGyu's avatar
Kim, MinGyu committed
19
20
21
      <div className="text-start px-5 py-2 bg-white whitespace-nowrap">
        도시
      </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
}