Arealist.svelte
3.8 KB
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<script>
import { fly } from 'svelte/transition'
import SideBar from './SideBar.svelte';
var icon_show = true;
var sidebar_show = false;
function showBar() {
sidebar_show = true;
}
function hide() {
if (window.scrollY < 400) {
icon_show = true;
} else {
icon_show = false;
sidebar_show = false;
}
}
import { DISTRICTS } from '../Data/district'
import { District, City, Changed } from '../Stores/DistrictStore'
export var moveTo;
let curDisrict = {"미선택" : ["미선택"]};
let curCity = "미선택";
$: if(Object.keys(curDisrict)[0] != "미선택") {
District.set(Object.keys(curDisrict)[0]);
} else {
District.set("");
};
$: if(curCity != "미선택") {
City.set(curCity);
} else {
City.set("");
}
function setDistrict(district) {
curDisrict = district;
if(Object.keys(curDisrict)[0] == "세종특별자치시")
curCity = "세종특별자치시";
else
curCity = "미선택";
moveTo(Object.keys(curDisrict)[0], curCity);
Changed.set(true);
}
function setCity(city) {
curCity = city;
moveTo(Object.keys(curDisrict)[0], curCity);
Changed.set(true);
}
</script>
<style>
.sidebtn {
border-radius: 5px;
border: 0px;
width: 70px;
height: 70px;
position: fixed;
left: -20px;
top: 120px;
padding-right: 10px;
text-align: right;
background-color: #b71c1c;
color: #ffffff;
box-shadow: 0 10px 20px rgb(0 0 0 / 15%);
}
.sidebtn:focus {
background-color: #ef5350;
}
.sidebtn:hover {
background-color: #d32f2f;
}
.areas {
display: flex;
border-bottom: #999999 solid 1px;
width: 100%;
flex-wrap: wrap;
justify-content: space-evenly;
}
.areatitle {
display: inline-block;
text-align:center;
width: 200px;
}
.district {
display: inline-block;
text-align:center;
width: 125px;
margin: 5px;
border: 1px solid black;
border-radius: 5px;
padding-top: 5px;
padding-bottom: 5px;
}
.district:hover {
background-color: #ffebee;
}
.district:focus {
background-color: #ffcdd2;
}
.district.selected{
background-color: #ffcdd2;
}
.city {
display: inline-block;
text-align:center;
width: 125px;
margin: 5px;
border: 1px solid black;
border-radius: 5px;
padding-top: 5px;
padding-bottom: 5px;
}
.city:hover {
background-color: #ffebee;
}
.city:focus {
background-color: #ffcdd2;
}
.city.selected{
background-color: #ffcdd2;
}
</style>
<svelte:window on:scroll={hide}></svelte:window>
{#if (icon_show)}
<button class="sidebtn"
transition:fly="{{ x : -50, duration : 400}}"
on:click={showBar}>
지역<br>선택
</button>
{/if}
<SideBar bind:show={sidebar_show}>
<div class="areas">
<div class="areatitle">광역시/도</div>
{#each DISTRICTS.data as d}
<div class="{Object.keys(curDisrict)[0] == Object.keys(d)[0] ? 'district selected' : 'district'}"
on:click={() => {setDistrict(d)}}>
{Object.keys(d)[0]}
</div><br>
{/each}
</div><br>
<div class="areas">
<div class="areatitle">시/군/구</div>
{#each curDisrict[Object.keys(curDisrict)[0]] as c}
<div class="{curCity == c ? 'city selected' : 'city'}"
on:click={() => {setCity(c)}}>
{c}
</div><br>
{/each}
</div>
</SideBar>