|
11 | 11 | } from 'date-fns';
|
12 | 12 | import Dot from '../components/dot.svelte';
|
13 | 13 | import { browser } from '$app/environment';
|
14 |
| - import * as Lockr from "lockr" |
15 |
| -
|
| 14 | + import * as Lockr from 'lockr'; |
| 15 | + import ColorPicker from 'svelte-awesome-color-picker'; |
16 | 16 |
|
17 | 17 | function changeBg() {
|
18 | 18 | document.querySelector(':root').style.setProperty('--bg-color', '#ffffff');
|
|
119 | 119 | let viewID = $derived(timerange + unit + colsName);
|
120 | 120 |
|
121 | 121 | function save() {
|
122 |
| - console.log("SAVING!") |
123 |
| - Lockr.set(viewID + "_notes", currentNotes) |
124 |
| - Lockr.set(viewID + "_colors", currentColors) |
| 122 | + console.log('SAVING!'); |
| 123 | + Lockr.set(viewID + '_notes', currentNotes); |
| 124 | + Lockr.set(viewID + '_colors', currentColors); |
125 | 125 | }
|
126 | 126 |
|
127 | 127 | function reset() {
|
128 |
| - Lockr.rm(viewID + "_notes") |
129 |
| - Lockr.rm(viewID + "_colors") |
130 |
| - currentColors = new Array(30).fill('') |
131 |
| - currentNotes = new Array(30).fill('') |
| 128 | + Lockr.rm(viewID + '_notes'); |
| 129 | + Lockr.rm(viewID + '_colors'); |
| 130 | + currentColors = new Array(30).fill(''); |
| 131 | + currentNotes = new Array(30).fill(''); |
| 132 | + } |
| 133 | +
|
| 134 | + function getVar(varName) { |
| 135 | + if (browser) { |
| 136 | + return window.getComputedStyle(document.documentElement).getPropertyValue(varName); |
| 137 | + } else { |
| 138 | + return "#FFFFFF" |
| 139 | + } |
132 | 140 | }
|
133 | 141 |
|
134 | 142 | $effect(() => {
|
135 |
| - currentColors = Lockr.get(viewID + "_colors", new Array(30).fill('')) |
136 |
| - currentNotes = Lockr.get(viewID + "_notes", new Array(30).fill('')) |
137 |
| - }) |
| 143 | + currentColors = Lockr.get(viewID + '_colors', new Array(30).fill('')); |
| 144 | + currentNotes = Lockr.get(viewID + '_notes', new Array(30).fill('')); |
| 145 | + }); |
138 | 146 |
|
139 | 147 | $inspect(currentColors);
|
140 | 148 | </script>
|
|
188 | 196 | <br />
|
189 | 197 |
|
190 | 198 | <label for="time-range" class="text-text">showing</label>
|
191 |
| - <select name="time-range" id="time-range" class="bg-inactive text-text p-1 rounded-lg hover:bg-primary hover:text-inactive transition-all duration-300" bind:value={timerange}> |
| 199 | + <select |
| 200 | + name="time-range" |
| 201 | + id="time-range" |
| 202 | + class="bg-inactive text-text hover:bg-primary hover:text-inactive rounded-lg p-1 transition-all duration-300" |
| 203 | + bind:value={timerange} |
| 204 | + > |
192 | 205 | <option value="hour">this hour</option>
|
193 | 206 | <option value="day">this day</option>
|
194 | 207 | <option value="week">this week</option>
|
|
197 | 210 | </select>
|
198 | 211 |
|
199 | 212 | <label for="dot-is" class="text-text">with each dot being</label>
|
200 |
| - <select name="dot-is" id="dot-is" class="bg-inactive text-text p-1 rounded-lg hover:bg-primary hover:text-inactive transition-all duration-300" bind:value={unit}> |
| 213 | + <select |
| 214 | + name="dot-is" |
| 215 | + id="dot-is" |
| 216 | + class="bg-inactive text-text hover:bg-primary hover:text-inactive rounded-lg p-1 transition-all duration-300" |
| 217 | + bind:value={unit} |
| 218 | + > |
201 | 219 | <option value="min">a minute</option>
|
202 | 220 | <option value="hour">an hour</option>
|
203 | 221 | <option value="day">a day</option>
|
|
207 | 225 | </select>
|
208 | 226 |
|
209 | 227 | <label for="cols" class="text-text">and each row representing</label>
|
210 |
| - <select name="cols" id="dot-is" class="bg-inactive text-text p-1 rounded-lg hover:bg-primary hover:text-inactive transition-all duration-300" bind:value={colsName}> |
| 228 | + <select |
| 229 | + name="cols" |
| 230 | + id="dot-is" |
| 231 | + class="bg-inactive text-text hover:bg-primary hover:text-inactive rounded-lg p-1 transition-all duration-300" |
| 232 | + bind:value={colsName} |
| 233 | + > |
211 | 234 | <option value="hour">an hour</option>
|
212 | 235 | <option value="day">a day</option>
|
213 | 236 | <option value="week">a week</option>
|
|
217 | 240 |
|
218 | 241 | <br />
|
219 | 242 |
|
220 |
| - <button class="bg-inactive text-text mt-2 mr-2 px-3 rounded-lg py-1 hover:bg-primary hover:text-inactive transition-all duration-300 " onclick={save}>save notes and colors to this view</button> |
221 |
| - <button class="bg-inactive text-text mt-2 mr-2 px-3 rounded-lg py-1 hover:bg-primary hover:text-inactive transition-all duration-300 " onclick={reset}>reset saved data for this view</button> |
| 243 | + <button |
| 244 | + class="bg-inactive text-text hover:bg-primary hover:text-inactive mt-2 mr-2 rounded-lg px-3 py-1 transition-all duration-300" |
| 245 | + onclick={save}>save notes and colors to this view</button |
| 246 | + > |
| 247 | + <button |
| 248 | + class="bg-inactive text-text hover:bg-primary hover:text-inactive mt-2 mr-2 rounded-lg px-3 py-1 transition-all duration-300" |
| 249 | + onclick={reset}>reset saved data for this view</button |
| 250 | + > |
| 251 | + |
| 252 | + <br /> |
| 253 | + |
| 254 | + <button |
| 255 | + class="bg-inactive text-text hover:bg-primary hover:text-inactive mt-2 mr-2 rounded-lg px-3 py-1 transition-all duration-300" |
| 256 | + popovertarget="theming-menu">open theming menu</button |
| 257 | + > |
| 258 | + |
| 259 | + <div |
| 260 | + popover |
| 261 | + class="bg-bg border-text absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 flex-row items-center gap-3 rounded-xl border-1 p-4 transition-all backdrop:backdrop-blur-sm open:flex overflow-visible" |
| 262 | + id="theming-menu" |
| 263 | + > |
| 264 | + <div class="picker flex flex-col gap-3 *:hover:font-extrabold *:transition-all *:duration-175"> |
| 265 | + <ColorPicker hex={getVar("--bg-color")} label="Background" onInput={(event) => {document.querySelector(':root').style.setProperty('--bg-color', event.hex)}}/> |
| 266 | + <ColorPicker hex={getVar("--inactive-color")} label="Inactive" onInput={(event) => {document.querySelector(':root').style.setProperty('--inactive-color', event.hex)}}/> |
| 267 | + <ColorPicker hex={getVar("--active-color")} label="Active" onInput={(event) => {document.querySelector(':root').style.setProperty('--active-color', event.hex)}}/> |
| 268 | + <ColorPicker hex={getVar("--red-color")} label="Red" onInput={(event) => {document.querySelector(':root').style.setProperty('--red-color', event.hex)}}/> |
| 269 | + <ColorPicker hex={getVar("--yellow-color")} label="Yellow" onInput={(event) => {document.querySelector(':root').style.setProperty('--yellow-color', event.hex)}}/> |
| 270 | + <ColorPicker hex={getVar("--green-color")} label="Green" onInput={(event) => {document.querySelector(':root').style.setProperty('--green-color', event.hex)}}/> |
| 271 | + <ColorPicker hex={getVar("--blue-color")} label="Blue" onInput={(event) => {document.querySelector(':root').style.setProperty('--blue-color', event.hex)}}/> |
| 272 | + |
| 273 | + </div> |
| 274 | + |
| 275 | +</div> |
222 | 276 | </div>
|
| 277 | + |
| 278 | +<style> |
| 279 | + .picker { |
| 280 | + --cp-bg-color: var(--bg-color); |
| 281 | + --cp-border-color: var(--text-color); |
| 282 | + --cp-text-color: var(--text-color); |
| 283 | + --cp-input-color: var(--inactive-color); |
| 284 | + --cp-button-hover-color: var(--active-color); |
| 285 | + --slider-width: 20px; |
| 286 | + --picker-indicator-size: 15px; |
| 287 | + --focus-color: var(--active-color); |
| 288 | + --picker-z-index: 100 |
| 289 | + } |
| 290 | +</style> |
0 commit comments