|
| 1 | +<link rel="preconnect" href="https://fonts.googleapis.com"> |
| 2 | +<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> |
| 3 | +<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap" rel="stylesheet"> |
1 | 4 | <style> |
2 | | - html, |
| 5 | + * { |
| 6 | + box-sizing: border-box; |
| 7 | + } |
| 8 | + |
| 9 | + html { |
| 10 | + font-family: Inter; |
| 11 | + scroll-padding-top: 80px; |
| 12 | + } |
3 | 13 | body { |
4 | | - padding: 0; |
5 | 14 | margin: 0; |
6 | 15 | } |
7 | 16 |
|
8 | 17 | div { |
9 | 18 | display: flex; |
10 | 19 | gap: 0.5rem; |
| 20 | + height: 40px; |
| 21 | + align-items: center; |
| 22 | + justify-content: center; |
| 23 | + background-color: #2C2C2C; |
| 24 | + position: sticky; |
| 25 | + top: 0px; |
11 | 26 | } |
12 | 27 |
|
13 | 28 | table { |
14 | | - width: 100vw; |
| 29 | + margin-top: 8px; |
| 30 | + width: 100%; |
| 31 | + border-collapse: collapse; |
| 32 | + } |
| 33 | + |
| 34 | + thead { |
| 35 | + position: sticky; |
| 36 | + top: 40px; |
| 37 | + height: 40px; |
| 38 | + background-color: #FFFFFF; |
| 39 | + } |
| 40 | + |
| 41 | + td { |
| 42 | + text-align: center; |
| 43 | + } |
| 44 | + |
| 45 | + button { |
| 46 | + height: 32px; |
| 47 | + line-height: 30px; |
| 48 | + max-width: 200px; |
| 49 | + border-radius: 6px; |
| 50 | + border: 1px solid rgba(255, 255, 255, 0.8); |
| 51 | + background-color: initial; |
| 52 | + color: #ffffff; |
| 53 | + font-family: Inter; |
| 54 | + font-weight: 500; |
| 55 | + padding: 0; |
| 56 | + } |
| 57 | + |
| 58 | + |
| 59 | + button[type=submit] { |
| 60 | + padding: 0px 11px; |
| 61 | + border: none; |
| 62 | + background-color: #18A0FB; |
| 63 | + color: #FFFFFF; |
| 64 | + } |
| 65 | + |
| 66 | + button[type=button] { |
| 67 | + padding: 0px 11px; |
| 68 | + } |
| 69 | + |
| 70 | + button[type=reset] { |
| 71 | + width: 32px; |
| 72 | + line-height: 32px; |
| 73 | + display: inline-grid; |
| 74 | + place-items: center; |
| 75 | + color: #333333; |
| 76 | + fill: #333333; |
| 77 | + border: none; |
| 78 | + border-radius: 2px; |
| 79 | + } |
| 80 | + |
| 81 | + button[type=reset]:hover { |
| 82 | + background-color: rgba(0, 0, 0, 0.06); |
15 | 83 | } |
16 | 84 |
|
17 | 85 | input, |
18 | 86 | select { |
19 | 87 | width: 100%; |
20 | 88 | } |
21 | 89 |
|
22 | | - input[type=button] { |
23 | | - width: 1.5rem; |
24 | | - height: 1.5rem; |
25 | | - display: inline-grid; |
26 | | - place-items: center; |
| 90 | + input[type=text] { |
| 91 | + background-color: #FFFFFF; |
| 92 | + color: rgba(0, 0, 0, 0.8); |
| 93 | + font-family: Inter; |
| 94 | + border: none; |
| 95 | + padding: 7px; |
| 96 | + border-radius: 2px; |
| 97 | + border-color: rgba(0, 0, 0, 0.1); |
| 98 | + border-style: solid; |
| 99 | + border-width: 1px; |
| 100 | + } |
| 101 | + |
| 102 | + input[type=text]:focus, |
| 103 | + input[type=text]:focus-visible { |
| 104 | + border-color: #18A0FB; |
| 105 | + outline-color: #18A0FB; |
| 106 | + outline-width: 1px; |
| 107 | + } |
| 108 | + |
| 109 | + input[type=checkbox] { |
| 110 | + width: auto; |
| 111 | + } |
| 112 | + |
| 113 | + select { |
| 114 | + height: 32px; |
| 115 | + border-radius: 2px; |
| 116 | + border: 1px solid rgba(0, 0, 0, 0.1); |
| 117 | + } |
| 118 | + |
| 119 | + select:active, |
| 120 | + select:focus, |
| 121 | + select:focus-visible { |
| 122 | + border-color: #18A0FB; |
| 123 | + outline-color: #18A0FB; |
| 124 | + outline-width: 1px; |
| 125 | + } |
| 126 | + |
| 127 | + .drag-target-top { |
| 128 | + border-top: 2px solid black; |
| 129 | + } |
| 130 | + |
| 131 | + .drag-target-bottom { |
| 132 | + border-bottom: 2px solid black; |
27 | 133 | } |
28 | 134 | </style> |
29 | 135 | <script src="https://unpkg.com/vue@3"></script> |
|
43 | 149 | </tr> |
44 | 150 | </thead> |
45 | 151 | <tbody> |
46 | | - <tr ref="columns" v-for="(column, index) in columns" draggable="true" @dragend="dragEnd" @dragover="dragOver"> |
| 152 | + <tr ref="columns" v-for="(column, index) in columns" draggable="true" @dragstart="dragStart" @dragend="dragEnd" |
| 153 | + @dragover="dragOver" @dragleave="dragLeave"> |
47 | 154 | <td> |
48 | 155 | <input v-model="column.name" type="text" /> |
49 | 156 | </td> |
|
105 | 212 | <input v-model="column.nullable" type="checkbox" /> |
106 | 213 | </td> |
107 | 214 | <td> |
108 | | - <input type="button" @click="remove(index)" value="-" /> |
| 215 | + <button type="reset" @click="remove(index)"> |
| 216 | + <svg width="12" height="16" viewBox="0 0 12 16" fill="none" xmlns="http://www.w3.org/2000/svg"> |
| 217 | + <path |
| 218 | + d="M0 3H1.5M12 3H10.5M3.5 3V2.5C3.5 1.67157 4.17157 1 5 1H7C7.82843 1 8.5 1.67157 8.5 2.5V3M3.5 3H8.5M3.5 3H1.5M8.5 3H10.5M10.5 3V13.5C10.5 14.3284 9.82843 15 9 15H3C2.17157 15 1.5 14.3284 1.5 13.5V3M4.5 6.5V10.5M7.5 6.5V10.5" |
| 219 | + stroke="black" /> |
| 220 | + </svg> |
| 221 | + </button> |
109 | 222 | </td> |
110 | 223 | </tr> |
111 | 224 | </tbody> |
|
117 | 230 | return { |
118 | 231 | columns: [], |
119 | 232 | row: null, |
| 233 | + changedRow: null, |
120 | 234 | } |
121 | 235 | }, |
122 | 236 | mounted() { |
|
141 | 255 | remove(index) { |
142 | 256 | this.columns.splice(index, 1) |
143 | 257 | }, |
| 258 | + dragStart(event) { |
| 259 | + this.changedRow = event.currentTarget |
| 260 | + }, |
144 | 261 | dragEnd(event) { |
145 | 262 | let rows = this.$refs.columns |
146 | 263 | let newIndex = rows.indexOf(this.row) |
|
150 | 267 | this.columns.splice(newIndex, 0, currentColumn[0]) |
151 | 268 | }, |
152 | 269 | dragOver(event) { |
| 270 | + let rows = this.$refs.columns |
| 271 | + |
| 272 | + this.row = event.currentTarget |
| 273 | + |
| 274 | + let newIndex = rows.indexOf(this.row) |
| 275 | + let prevIndex = rows.indexOf(this.changedRow) |
| 276 | + |
| 277 | + let targetClass = "" |
| 278 | + if (newIndex == prevIndex) { |
| 279 | + return |
| 280 | + } |
| 281 | + |
| 282 | + if (newIndex < prevIndex) { |
| 283 | + targetClass = "drag-target-top" |
| 284 | + } else { |
| 285 | + targetClass = "drag-target-bottom" |
| 286 | + } |
| 287 | + |
| 288 | + this.row.classList.add(targetClass) |
| 289 | + }, |
| 290 | + dragLeave(event) { |
153 | 291 | this.row = event.currentTarget |
| 292 | + |
| 293 | + this.row.classList.remove("drag-target-bottom", "drag-target-top") |
154 | 294 | } |
155 | 295 | }, |
156 | 296 | }).mount("article") |
|
0 commit comments