|
9 | 9 | refreshIntervalTimer, |
10 | 10 | DEFAULT_MAGNITUDE_NOTIFICATION_THRESHOLD, |
11 | 11 | magnitudeNotificationThreshold, |
| 12 | + magnitudeColorScale, |
12 | 13 | } from "./store" |
13 | 14 | import { startFeedRefreshInterval } from "./feed" |
14 | 15 | import { tooltip } from "./tooltip" |
15 | 16 | import { setTheme } from "./utils" |
| 17 | + import { MagnitudeColor } from "./types" |
16 | 18 |
|
17 | 19 | let selectedTheme = $theme |
18 | 20 |
|
19 | 21 | $: newRefreshInterval = $refreshInterval |
20 | 22 | $: newMagnitudeNotificationThreshold = $magnitudeNotificationThreshold |
| 23 | + $: newMagnitudeColorScale = $magnitudeColorScale |
21 | 24 |
|
22 | 25 | $: refreshIntervalChanged = newRefreshInterval !== $refreshInterval |
23 | 26 | $: magnitudeNotificationThresholdChanged = newMagnitudeNotificationThreshold !== $magnitudeNotificationThreshold |
24 | | - $: disabled = !refreshIntervalChanged && !magnitudeNotificationThresholdChanged |
| 27 | + $: magnitudeColorScaleChanged = newMagnitudeColorScale !== $magnitudeColorScale |
| 28 | + $: disabled = !refreshIntervalChanged && !magnitudeNotificationThresholdChanged && !magnitudeColorScaleChanged |
25 | 29 |
|
26 | 30 | const preferences = { |
27 | 31 | themes: [ |
|
48 | 52 | if (magnitudeNotificationThresholdChanged) { |
49 | 53 | magnitudeNotificationThreshold.set(newMagnitudeNotificationThreshold || DEFAULT_MAGNITUDE_NOTIFICATION_THRESHOLD) |
50 | 54 | } |
| 55 | +
|
| 56 | + if (magnitudeColorScaleChanged) { |
| 57 | + magnitudeColorScale.set(newMagnitudeColorScale) |
| 58 | + } |
51 | 59 | } |
52 | 60 |
|
53 | 61 | function closeSettings() { |
|
125 | 133 | </div> |
126 | 134 | </div> |
127 | 135 |
|
| 136 | + <!-- Color scale --> |
| 137 | + <div class="flex items-center gap-4 p-2 bg-white dark:bg-gray-800"> |
| 138 | + <div class="w-1/2"> |
| 139 | + <h2 class="text-right">Magnitude color scale</h2> |
| 140 | + </div> |
| 141 | + <div class="w-1/2"> |
| 142 | + <input |
| 143 | + type="checkbox" |
| 144 | + value="1" |
| 145 | + bind:checked={newMagnitudeColorScale} |
| 146 | + class="appearance-none w-6 h-6 rounded bg-white dark:bg-gray-800 border dark:border-gray-600 checked:bg-blue-600 dark:checked:bg-blue-600 checked:border-transparent" |
| 147 | + /> |
| 148 | + </div> |
| 149 | + </div> |
| 150 | + |
| 151 | + <div class="flex items-center justify-center pb-4 bg-white dark:bg-gray-800"> |
| 152 | + {#each Object.keys(MagnitudeColor) as magnitude, i (magnitude)} |
| 153 | + {@const totalMagnitudes = Object.keys(MagnitudeColor).length} |
| 154 | + <div |
| 155 | + class={`flex items-center justify-center w-6 h-6 text-xs text-white ${MagnitudeColor[magnitude]}`} |
| 156 | + class:rounded-l={i === 0} |
| 157 | + class:rounded-r={i + 1 === totalMagnitudes} |
| 158 | + > |
| 159 | + {magnitude.replace("m-", "")} |
| 160 | + </div> |
| 161 | + {/each} |
| 162 | + </div> |
| 163 | + |
| 164 | + <!-- Save settings --> |
128 | 165 | <div class="text-right p-2 bg-white dark:bg-gray-800 border-t dark:border-gray-600 rounded-b-lg"> |
129 | 166 | <button |
130 | 167 | on:click={saveSettings} |
|
0 commit comments