mirror of
https://github.com/gpxstudio/gpx.studio.git
synced 2025-09-02 08:42:31 +00:00
embedding theme option, closes #57
This commit is contained in:
@@ -6,7 +6,6 @@
|
|||||||
import Map from '$lib/components/Map.svelte';
|
import Map from '$lib/components/Map.svelte';
|
||||||
import LayerControl from '$lib/components/layer-control/LayerControl.svelte';
|
import LayerControl from '$lib/components/layer-control/LayerControl.svelte';
|
||||||
import OpenIn from '$lib/components/embedding/OpenIn.svelte';
|
import OpenIn from '$lib/components/embedding/OpenIn.svelte';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
gpxStatistics,
|
gpxStatistics,
|
||||||
slicedGPXStatistics,
|
slicedGPXStatistics,
|
||||||
@@ -22,6 +21,7 @@
|
|||||||
import { selection } from '$lib/components/file-list/Selection';
|
import { selection } from '$lib/components/file-list/Selection';
|
||||||
import { ListFileItem } from '$lib/components/file-list/FileList';
|
import { ListFileItem } from '$lib/components/file-list/FileList';
|
||||||
import { allowedEmbeddingBasemaps, type EmbeddingOptions } from './Embedding';
|
import { allowedEmbeddingBasemaps, type EmbeddingOptions } from './Embedding';
|
||||||
|
import { mode, setMode } from 'mode-watcher';
|
||||||
|
|
||||||
$embedding = true;
|
$embedding = true;
|
||||||
|
|
||||||
@@ -44,7 +44,8 @@
|
|||||||
directionMarkers: false,
|
directionMarkers: false,
|
||||||
distanceUnits: 'metric',
|
distanceUnits: 'metric',
|
||||||
velocityUnits: 'speed',
|
velocityUnits: 'speed',
|
||||||
temperatureUnits: 'celsius'
|
temperatureUnits: 'celsius',
|
||||||
|
theme: 'system'
|
||||||
};
|
};
|
||||||
|
|
||||||
function applyOptions() {
|
function applyOptions() {
|
||||||
@@ -160,6 +161,10 @@
|
|||||||
if (options.temperatureUnits !== $temperatureUnits) {
|
if (options.temperatureUnits !== $temperatureUnits) {
|
||||||
$temperatureUnits = options.temperatureUnits;
|
$temperatureUnits = options.temperatureUnits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.theme !== $mode) {
|
||||||
|
setMode(options.theme);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
@@ -168,6 +173,7 @@
|
|||||||
prevSettings.distanceUnits = $distanceUnits;
|
prevSettings.distanceUnits = $distanceUnits;
|
||||||
prevSettings.velocityUnits = $velocityUnits;
|
prevSettings.velocityUnits = $velocityUnits;
|
||||||
prevSettings.temperatureUnits = $temperatureUnits;
|
prevSettings.temperatureUnits = $temperatureUnits;
|
||||||
|
prevSettings.theme = $mode ?? 'system';
|
||||||
});
|
});
|
||||||
|
|
||||||
$: if (options) {
|
$: if (options) {
|
||||||
@@ -199,6 +205,10 @@
|
|||||||
$temperatureUnits = prevSettings.temperatureUnits;
|
$temperatureUnits = prevSettings.temperatureUnits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($mode !== prevSettings.theme) {
|
||||||
|
setMode(prevSettings.theme);
|
||||||
|
}
|
||||||
|
|
||||||
$selection.clear();
|
$selection.clear();
|
||||||
$fileObservers.clear();
|
$fileObservers.clear();
|
||||||
$fileOrder = $fileOrder.filter((id) => !id.includes('embed'));
|
$fileOrder = $fileOrder.filter((id) => !id.includes('embed'));
|
||||||
|
@@ -20,6 +20,7 @@ export type EmbeddingOptions = {
|
|||||||
distanceUnits: 'metric' | 'imperial',
|
distanceUnits: 'metric' | 'imperial',
|
||||||
velocityUnits: 'speed' | 'pace',
|
velocityUnits: 'speed' | 'pace',
|
||||||
temperatureUnits: 'celsius' | 'fahrenheit',
|
temperatureUnits: 'celsius' | 'fahrenheit',
|
||||||
|
theme: 'system' | 'light' | 'dark',
|
||||||
};
|
};
|
||||||
|
|
||||||
export const defaultEmbeddingOptions = {
|
export const defaultEmbeddingOptions = {
|
||||||
@@ -42,6 +43,7 @@ export const defaultEmbeddingOptions = {
|
|||||||
distanceUnits: 'metric',
|
distanceUnits: 'metric',
|
||||||
velocityUnits: 'speed',
|
velocityUnits: 'speed',
|
||||||
temperatureUnits: 'celsius',
|
temperatureUnits: 'celsius',
|
||||||
|
theme: 'system',
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getDefaultEmbeddingOptions(): EmbeddingOptions {
|
export function getDefaultEmbeddingOptions(): EmbeddingOptions {
|
||||||
|
@@ -243,6 +243,23 @@
|
|||||||
</RadioGroup.Root>
|
</RadioGroup.Root>
|
||||||
</Label>
|
</Label>
|
||||||
</div>
|
</div>
|
||||||
|
<Label class="flex flex-col items-start gap-2">
|
||||||
|
{$_('menu.mode')}
|
||||||
|
<RadioGroup.Root bind:value={options.theme} class="flex flex-row">
|
||||||
|
<div class="flex items-center space-x-2">
|
||||||
|
<RadioGroup.Item value="system" id="system" />
|
||||||
|
<Label for="system">{$_('menu.system')}</Label>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center space-x-2">
|
||||||
|
<RadioGroup.Item value="light" id="light" />
|
||||||
|
<Label for="light">{$_('menu.light')}</Label>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center space-x-2">
|
||||||
|
<RadioGroup.Item value="dark" id="dark" />
|
||||||
|
<Label for="dark">{$_('menu.dark')}</Label>
|
||||||
|
</div>
|
||||||
|
</RadioGroup.Root>
|
||||||
|
</Label>
|
||||||
<div class="flex flex-col gap-3 p-3 border rounded-md">
|
<div class="flex flex-col gap-3 p-3 border rounded-md">
|
||||||
<div class="flex flex-row items-center gap-2">
|
<div class="flex flex-row items-center gap-2">
|
||||||
<Checkbox id="manual-camera" bind:checked={manualCamera} />
|
<Checkbox id="manual-camera" bind:checked={manualCamera} />
|
||||||
|
@@ -46,6 +46,7 @@
|
|||||||
"fahrenheit": "Fahrenheit",
|
"fahrenheit": "Fahrenheit",
|
||||||
"language": "Language",
|
"language": "Language",
|
||||||
"mode": "Theme",
|
"mode": "Theme",
|
||||||
|
"system": "System",
|
||||||
"light": "Light",
|
"light": "Light",
|
||||||
"dark": "Dark",
|
"dark": "Dark",
|
||||||
"street_view_source": "Street view source",
|
"street_view_source": "Street view source",
|
||||||
|
Reference in New Issue
Block a user