Skip to content

Commit

Permalink
fix setting name system and theme selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
kylerchin committed Dec 9, 2024
1 parent 6ae7393 commit dfef985
Show file tree
Hide file tree
Showing 29 changed files with 610 additions and 416 deletions.
62 changes: 7 additions & 55 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
"dependencies": {
"@datadog/browser-rum": "^5.30.0",
"@mapbox/polyline": "^1.2.1",
"@maplibre/maplibre-gl-inspect": "^1.7.0",
"@sveltejs/adapter-cloudflare": "^4.7.4",
"@sveltejs/vite-plugin-svelte": "^3.1.2",
"@zerodevx/svelte-toast": "^0.9.6",
Expand All @@ -54,6 +53,7 @@
"maplibre-gl": "5.0.0-pre.5",
"moment": "^2.30.1",
"protobufjs": "^7.4.0",
"store2": "^2.14.3",
"stringify-object": "^5.0.0",
"svelte-i18n": "^4.0.1",
"svelte-toasts": "^1.1.2",
Expand Down
5 changes: 2 additions & 3 deletions src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,11 @@ body {
.maplibregl-canvas
{

background-color: #000000;
background-color: #324a78;
}

@media (prefers-color-scheme: dark) {.maplibregl-canvas
.dark .maplibregl-canvas
{

background-color: #000000;
}
}
8 changes: 4 additions & 4 deletions src/components/DelayDiff.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//Positive diff means late, negative diff means early
export let simple: boolean = false;
export let show_seconds = false;
let textclass: string = 'text-[0px]';
Expand Down Expand Up @@ -100,10 +100,10 @@
{#if h > 0}
<span class="text-sm">{h}</span>
<span class="text-xs">{locale_hour_marking(this_locale)}</span>
{/if}{#if h > 0 || m > 0 || (simple && m >= 0 && diff != 0)}
<span class="text-sm">{simple && Math.abs(diff) < 60 ? '<1' : m}</span>
{/if}{#if h > 0 || m > 0 || (!show_seconds && m >= 0 && diff != 0)}
<span class="text-sm">{!show_seconds && Math.abs(diff) < 60 ? '<1' : m}</span>
<span class="text-xs">{locale_min_marking(this_locale)}</span>{/if}
{#if !simple}
{#if show_seconds}
{#if Math.abs(diff) > 0}
<span class="text-sm">{s}</span>
<span class="text-xs">{locale_s_marking(this_locale)}</span>
Expand Down
159 changes: 159 additions & 0 deletions src/components/SettingsMenu.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
<script lang="ts">
import { getLocaleFromNavigator, locale, locales, _ } from 'svelte-i18n';
import { get } from 'svelte/store';
import { data_stack_store, usunits_store, show_gtfs_ids_store, ui_theme_store, show_seconds_store } from '../globalstores';
import HomeButton from './SidebarParts/home_button.svelte';
import {locales_options, locales_options_lookup} from '../i18n';
let this_locale: string | undefined | null;
import { getLocaleStorageOrNav } from '../i18n';
import { init_stores } from './init_stores';
init_stores();
let show_seconds = get(show_seconds_store);
let theme_selector = get(ui_theme_store);
ui_theme_store.subscribe((value) => {
theme_selector = value;
});
function locale_code_to_name(locale: string | null | undefined) {
if (locale == null || locale == undefined) {
return '--';
} else {
let temp = locales_options_lookup[locale];
if (temp == null || temp == undefined) {
return locale;
} else {
return temp;
}
}
}
locale.subscribe((newval) => {
this_locale = newval;
});
let show_gtfs_ids = get(show_gtfs_ids_store);
show_gtfs_ids_store.subscribe((value) => {
show_gtfs_ids = value;
});
</script>

<HomeButton />
<div class="px-3 pt-1 flex flex-col h-full select-text">
<h1 class="text-3xl font-medium mb-2">{$_('settings')}</h1>
<span class="text-xl block">{$_('language')}</span>
<p>{$locale}</p>
<select
bind:value={$locale}
class="text-black bg-white dark:bg-slate-900 dark:text-white p-1 border-2 my-1 border-seashore rounded-md"
>
{#each $locales as locale}
<option value={locale} class="text-black bg-white dark:bg-slate-900 dark:text-white"
>{locale_code_to_name(locale)}</option
>
{/each}
</select>
<span class="block my-2"></span>
<span class="text-xl block mb-1">{$_('mapstyle')}</span>

<!-- Radio selector -->
<div class="mb-2">
<div class="">
<input
type="radio"
id="system"
name="system"
value="system"
checked={theme_selector === 'system'}
on:click={() => {
ui_theme_store.set('system');
}}
/>
<label for="system">{$_('system_theme')}</label>
</div>
<div>
<input
type="radio"
id="light"
name="light"
value="light"
checked={theme_selector === 'light'}
on:click={() => {
ui_theme_store.set('light');
}}
/>
<label for="system">{$_('light_theme')}</label>
</div>
<div>
<input
type="radio"
id="dark"
name="dark"
value="dark"
checked={theme_selector === 'dark'}
on:click={() => {
ui_theme_store.set('dark');
}}
/>
<label for="dark">{$_('dark_theme')}</label>
</div>
</div>

<div class="flex flex-row gap-x-2">
<input
type="checkbox"
checked={get(usunits_store)}
class="accent-seashore"
on:click={() => {
usunits_store.update((x) => !x);
window.localStorage.usunits = get(usunits_store);
}}
on:keydown={(e) => {
if (e.key === 'Enter') {
usunits_store.update((x) => !x);
window.localStorage.usunits = get(usunits_store);
}
}}
/>
<p>{$_('useUSunits')}</p>
</div>
<div class="flex flex-row gap-x-2">
<input
type="checkbox"
checked={get(show_gtfs_ids_store)}
class="accent-seashore"
on:click={() => {
show_gtfs_ids_store.update((x) => !x);
window.localStorage.show_gtfs_ids = get(show_gtfs_ids_store);
}}
on:keydown={(e) => {
if (e.key === 'Enter') {
show_gtfs_ids_store.update((x) => !x);
window.localStorage.show_gtfs_ids = get(show_gtfs_ids_store);
}
}}
/>
<p>{$_('show_gtfs_ids')}</p>
</div>

<div class="flex flex-row gap-x-2">
<input
type="checkbox"
class="accent-seashore"
checked={show_seconds}
on:click={(e) => {
show_seconds_store.set(e.target.checked);
}}
on:keydown={(e) => {
show_seconds_store.set(e.target.checked);
}}
/>
<p>{$_('show_seconds_in_trips')}</p>
</div>
</div>
Loading

0 comments on commit dfef985

Please sign in to comment.