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

type ThemeProps = {
  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 Theme({ handleClick }: ThemeProps) {
Kim, MinGyu's avatar
Kim, MinGyu committed
8
9
  const [active, setActive] = useState(0);

Lee Soobeom's avatar
Lee Soobeom committed
10
  const onactive = "whitespace-nowrap px-5 text-lime-500 ";
Kim, MinGyu's avatar
Kim, MinGyu committed
11
12
13
14
15
16
  const offactive = "whitespace-nowrap px-5 ";

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

백승민's avatar
theme1    
백승민 committed
17
  return (
Kim, MinGyu's avatar
Kim, MinGyu committed
18
    <div className=" overflow-x-auto flex rounded py-2 md:py-4 md:pl-3 shadow-lg divide-x-2 bg-white">
Lee Soobeom's avatar
Lee Soobeom committed
19
      <div onClick={() => clickActive(1)} className="px-0 md:px-2">
Kim, MinGyu's avatar
Kim, MinGyu committed
20
21
22
23
24
25
26
27
        <button
          id={"surfing"}
          onClick={handleClick}
          className={active === 1 ? onactive : offactive}
        >
          서핑
        </button>
      </div>
Lee Soobeom's avatar
Lee Soobeom committed
28
      <div onClick={() => clickActive(2)} className="px-0 md:px-2">
Kim, MinGyu's avatar
Kim, MinGyu committed
29
30
31
32
33
34
35
36
        <button
          id={"activity"}
          onClick={handleClick}
          className={active === 2 ? onactive : offactive}
        >
          액티비티
        </button>
      </div>
Lee Soobeom's avatar
Lee Soobeom committed
37
      <div onClick={() => clickActive(3)} className="px-0 md:px-2">
Kim, MinGyu's avatar
Kim, MinGyu committed
38
39
40
41
42
43
44
45
        <button
          id={"camping"}
          onClick={handleClick}
          className={active === 3 ? onactive : offactive}
        >
          캠핑
        </button>
      </div>
Lee Soobeom's avatar
Lee Soobeom committed
46
      <div onClick={() => clickActive(4)} className="px-0 md:px-2">
Kim, MinGyu's avatar
Kim, MinGyu committed
47
48
49
50
51
52
53
54
        <button
          id={"skiing"}
          onClick={handleClick}
          className={active === 4 ? onactive : offactive}
        >
          스키
        </button>
      </div>
Lee Soobeom's avatar
Lee Soobeom committed
55
      <div onClick={() => clickActive(5)} className="px-0 md:px-2">
Kim, MinGyu's avatar
Kim, MinGyu committed
56
57
58
59
60
61
62
63
        <button
          id={"boat"}
          onClick={handleClick}
          className={active === 5 ? onactive : offactive}
        >
          보트
        </button>
      </div>
Lee Soobeom's avatar
Lee Soobeom committed
64
      <div onClick={() => clickActive(6)} className="px-0 md:px-2">
Kim, MinGyu's avatar
Kim, MinGyu committed
65
66
67
68
69
70
71
72
        <button
          id={"desert"}
          onClick={handleClick}
          className={active === 6 ? onactive : offactive}
        >
          사막
        </button>
      </div>
Lee Soobeom's avatar
Lee Soobeom committed
73
      <div onClick={() => clickActive(7)} className="px-0 md:px-2">
Kim, MinGyu's avatar
Kim, MinGyu committed
74
75
76
77
78
79
80
81
        <button
          id={"golf"}
          onClick={handleClick}
          className={active === 7 ? onactive : offactive}
        >
          골프
        </button>
      </div>
Lee Soobeom's avatar
Lee Soobeom committed
82
      <div onClick={() => clickActive(8)} className="px-0 md:px-2">
Kim, MinGyu's avatar
Kim, MinGyu committed
83
84
85
86
87
88
89
90
        <button
          id={"cave"}
          onClick={handleClick}
          className={active === 8 ? onactive : offactive}
        >
          동굴
        </button>
      </div>
Lee Soobeom's avatar
Lee Soobeom committed
91
      <div onClick={() => clickActive(9)} className="px-0 md:px-2">
Kim, MinGyu's avatar
Kim, MinGyu committed
92
93
94
95
96
97
98
99
        <button
          id={"history"}
          onClick={handleClick}
          className={active === 9 ? onactive : offactive}
        >
          문화재
        </button>
      </div>
Lee Soobeom's avatar
Lee Soobeom committed
100
      <div onClick={() => clickActive(10)} className="px-0 md:px-2">
Kim, MinGyu's avatar
Kim, MinGyu committed
101
102
103
104
105
106
107
108
        <button
          id={"zoo"}
          onClick={handleClick}
          className={active === 10 ? onactive : offactive}
        >
          동물원
        </button>
      </div>
Lee Soobeom's avatar
Lee Soobeom committed
109
      <div onClick={() => clickActive(11)} className="px-0 md:px-2">
Kim, MinGyu's avatar
Kim, MinGyu committed
110
111
112
113
114
115
116
117
        <button
          id={"cycling"}
          onClick={handleClick}
          className={active === 11 ? onactive : offactive}
        >
          사이클링
        </button>
      </div>
백승민's avatar
백승민 committed
118
119
    </div>
  );
Kim, MinGyu's avatar
Kim, MinGyu committed
120
}