From dfef9852a243b4c70b4ba90796528e55f98d12f3 Mon Sep 17 00:00:00 2001
From: Kyler Chin <7539174+kylerchin@users.noreply.github.com>
Date: Sun, 8 Dec 2024 23:30:20 -0800
Subject: [PATCH] fix setting name system and theme selectors
---
package-lock.json | 62 +------
package.json | 2 +-
src/app.css | 5 +-
src/components/DelayDiff.svelte | 8 +-
src/components/SettingsMenu.svelte | 159 ++++++++++++++++++
src/components/SingleTripInfo.svelte | 77 +++++----
src/components/TimeDiff.svelte | 2 +-
src/components/addLayers/addStops.ts | 5 +-
src/components/init_stores.ts | 61 +++++++
src/components/layernames.ts | 43 +++++
src/components/sidebarInternals.svelte | 195 +----------------------
src/components/transitionDarkAndLight.ts | 120 ++++++++++++++
src/globalstores.ts | 7 +-
src/locales/de.json | 7 +-
src/locales/en.json | 7 +-
src/locales/es.json | 7 +-
src/locales/fr.json | 7 +-
src/locales/it.json | 7 +-
src/locales/jp.json | 7 +-
src/locales/ko.json | 7 +-
src/locales/nl.json | 7 +-
src/locales/pl.json | 7 +-
src/locales/zh-CN.json | 41 ++---
src/locales/zh-TW.json | 30 +++-
src/routes/+page.svelte | 115 +++++--------
static/dark-style.json | 2 +-
static/light-style.json | 2 +-
tailwind.config.js | 2 +-
yarn.lock | 25 +--
29 files changed, 610 insertions(+), 416 deletions(-)
create mode 100644 src/components/SettingsMenu.svelte
create mode 100644 src/components/init_stores.ts
create mode 100644 src/components/layernames.ts
create mode 100644 src/components/transitionDarkAndLight.ts
diff --git a/package-lock.json b/package-lock.json
index 7ae70bf..b6d2b6d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10,7 +10,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",
@@ -20,6 +19,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",
@@ -716,19 +716,6 @@
"node": ">=6.0.0"
}
},
- "node_modules/@maplibre/maplibre-gl-inspect": {
- "version": "1.7.0",
- "resolved": "https://registry.npmjs.org/@maplibre/maplibre-gl-inspect/-/maplibre-gl-inspect-1.7.0.tgz",
- "integrity": "sha512-O2C78Dh9zRvVLrm0axgzB9do5spoOGqMnN34xmJVedQWco6tCq49oSyeMuGyBEX9fE9/zLwynnZrAfT5FRN1pQ==",
- "license": "BSD-3-Clause",
- "dependencies": {
- "lodash.isequal": "^4.5.0",
- "randomcolor": "^0.6.2"
- },
- "peerDependencies": {
- "maplibre-gl": ">3.0.0"
- }
- },
"node_modules/@maplibre/maplibre-gl-style-spec": {
"version": "21.1.0",
"license": "ISC",
@@ -3285,20 +3272,6 @@
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",
"license": "ISC"
},
- "node_modules/fsevents": {
- "version": "2.3.3",
- "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
- "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
- "hasInstallScript": true,
- "license": "MIT",
- "optional": true,
- "os": [
- "darwin"
- ],
- "engines": {
- "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
- }
- },
"node_modules/function-bind": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
@@ -4173,12 +4146,6 @@
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"license": "MIT"
},
- "node_modules/lodash.isequal": {
- "version": "4.5.0",
- "resolved": "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz",
- "integrity": "sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==",
- "license": "MIT"
- },
"node_modules/lodash.merge": {
"version": "4.6.2",
"resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz",
@@ -5138,21 +5105,6 @@
"node": ">=18"
}
},
- "node_modules/playwright/node_modules/fsevents": {
- "version": "2.3.2",
- "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
- "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
- "dev": true,
- "hasInstallScript": true,
- "license": "MIT",
- "optional": true,
- "os": [
- "darwin"
- ],
- "engines": {
- "node": "^8.16.0 || ^10.6.0 || >=11.0.0"
- }
- },
"node_modules/postcss": {
"version": "8.4.49",
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.49.tgz",
@@ -5578,12 +5530,6 @@
"integrity": "sha512-XdjUArbK4Bm5fLLvlm5KpTFOiOThgfWWI4axAZDWg4E/0mKdZyI9tNEfds27qCi1ze/vwTR16kvmmGhRra3c2g==",
"license": "ISC"
},
- "node_modules/randomcolor": {
- "version": "0.6.2",
- "resolved": "https://registry.npmjs.org/randomcolor/-/randomcolor-0.6.2.tgz",
- "integrity": "sha512-Mn6TbyYpFgwFuQ8KJKqf3bqqY9O1y37/0jgSK/61PUxV4QfIMv0+K2ioq8DfOjkBslcjwSzRfIDEXfzA9aCx7A==",
- "license": "CC0"
- },
"node_modules/react-is": {
"version": "18.3.1",
"resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz",
@@ -6333,6 +6279,12 @@
"npm": ">=6"
}
},
+ "node_modules/store2": {
+ "version": "2.14.3",
+ "resolved": "https://registry.npmjs.org/store2/-/store2-2.14.3.tgz",
+ "integrity": "sha512-4QcZ+yx7nzEFiV4BMLnr/pRa5HYzNITX2ri0Zh6sT9EyQHbBHacC6YigllUPU9X3D0f/22QCgfokpKs52YRrUg==",
+ "license": "MIT"
+ },
"node_modules/string-width": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz",
diff --git a/package.json b/package.json
index 51fd149..bff0d6b 100644
--- a/package.json
+++ b/package.json
@@ -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",
@@ -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",
diff --git a/src/app.css b/src/app.css
index 8a47e1f..ffe6e0b 100644
--- a/src/app.css
+++ b/src/app.css
@@ -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;
-}
}
\ No newline at end of file
diff --git a/src/components/DelayDiff.svelte b/src/components/DelayDiff.svelte
index ca11229..c161b14 100644
--- a/src/components/DelayDiff.svelte
+++ b/src/components/DelayDiff.svelte
@@ -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]';
@@ -100,10 +100,10 @@
{#if h > 0}
{h}
{locale_hour_marking(this_locale)}
- {/if}{#if h > 0 || m > 0 || (simple && m >= 0 && diff != 0)}
- {simple && Math.abs(diff) < 60 ? '<1' : m}
+ {/if}{#if h > 0 || m > 0 || (!show_seconds && m >= 0 && diff != 0)}
+ {!show_seconds && Math.abs(diff) < 60 ? '<1' : m}
{locale_min_marking(this_locale)}{/if}
- {#if !simple}
+ {#if show_seconds}
{#if Math.abs(diff) > 0}
{s}
{locale_s_marking(this_locale)}
diff --git a/src/components/SettingsMenu.svelte b/src/components/SettingsMenu.svelte
new file mode 100644
index 0000000..c6cd291
--- /dev/null
+++ b/src/components/SettingsMenu.svelte
@@ -0,0 +1,159 @@
+
+
+
+
+
{$_('settings')}
+
{$_('language')}
+
{$locale}
+
+
+
{$_('mapstyle')}
+
+
+
+
+
+
{
+ 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);
+ }
+ }}
+ />
+
{$_('useUSunits')}
+
+
+
{
+ 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);
+ }
+ }}
+ />
+
{$_('show_gtfs_ids')}
+
+
+
+
{
+ show_seconds_store.set(e.target.checked);
+ }}
+ on:keydown={(e) => {
+ show_seconds_store.set(e.target.checked);
+ }}
+ />
+
{$_('show_seconds_in_trips')}
+
+
\ No newline at end of file
diff --git a/src/components/SingleTripInfo.svelte b/src/components/SingleTripInfo.svelte
index 67ca624..ba28511 100644
--- a/src/components/SingleTripInfo.svelte
+++ b/src/components/SingleTripInfo.svelte
@@ -44,8 +44,8 @@
});
})
-
export let usunits: boolean;
+
import {
dark_mode_store,
@@ -56,6 +56,7 @@
realtime_vehicle_route_cache_hash_store,
realtime_vehicle_route_cache_store,
lock_on_gps_store,
+ show_seconds_store,
usunits_store,
show_zombie_buses_store,
show_my_location_store,
@@ -66,6 +67,12 @@
import RouteHeading from './RouteHeading.svelte';
import { hexToRgb } from '../utils/colour';
+ let show_seconds = get(show_seconds_store);
+
+ show_seconds_store.subscribe((value) => {
+ show_seconds = value;
+ });
+
let stop_id_to_alert_ids: Record = {};
let alerts: Record = {};
@@ -502,8 +509,6 @@
}
}, 100);
});
-
- export let simpleRouteMode = true;
@@ -558,7 +563,6 @@
- {#if !simpleRouteMode}
Trip ID {trip_selected.trip_id}{#if trip_data.block_id != null}
{' | Block '}{trip_data.block_id}
@@ -572,15 +576,6 @@
{$_('timezone')}: {timezones.filter((x) => x != null).join(', ')}
{/if}
- {#if init_loaded != 0}
-
-
- {$_('lastupdated')}:
-
-
-
- {/if}
- {/if}
{/if}
- {#if stoptime.code && !simpleRouteMode}
-
+ {#if stoptime.code}
+
{/if}
@@ -697,7 +692,7 @@
stoptime.interpolated_stoptime_unix_seconds) -
current_time / 1000}
show_brackets={false}
- show_seconds={false}
+ show_seconds={show_seconds}
/>
{/if}
@@ -716,7 +711,7 @@
{:else}
-
+
{:else}