chore: add prettier formatting
All checks were successful
CI / Lint, typecheck and build (push) Successful in 9m56s
All checks were successful
CI / Lint, typecheck and build (push) Successful in 9m56s
This commit is contained in:
@@ -67,11 +67,13 @@ export function CurrentLocationControl({ stations }: { stations: LocatedSynopSta
|
||||
},
|
||||
(error) => {
|
||||
setIsLocating(false);
|
||||
setMessage(error.code === error.PERMISSION_DENIED
|
||||
? t("location.gpsDenied")
|
||||
: error.code === error.TIMEOUT
|
||||
? t("location.gpsTimeout")
|
||||
: t("location.gpsPositionUnavailable"));
|
||||
setMessage(
|
||||
error.code === error.PERMISSION_DENIED
|
||||
? t("location.gpsDenied")
|
||||
: error.code === error.TIMEOUT
|
||||
? t("location.gpsTimeout")
|
||||
: t("location.gpsPositionUnavailable"),
|
||||
);
|
||||
},
|
||||
{ enableHighAccuracy: true, maximumAge: 5 * 60 * 1000, timeout: 12_000 },
|
||||
);
|
||||
@@ -87,11 +89,14 @@ export function CurrentLocationControl({ stations }: { stations: LocatedSynopSta
|
||||
|
||||
useEffect(() => {
|
||||
if (!window.isSecureContext || autoLocated.current || !navigator.permissions?.query) return;
|
||||
navigator.permissions.query({ name: "geolocation" }).then((permission) => {
|
||||
if (permission.state !== "granted" || autoLocated.current) return;
|
||||
autoLocated.current = true;
|
||||
locate();
|
||||
}).catch(() => undefined);
|
||||
navigator.permissions
|
||||
.query({ name: "geolocation" })
|
||||
.then((permission) => {
|
||||
if (permission.state !== "granted" || autoLocated.current) return;
|
||||
autoLocated.current = true;
|
||||
locate();
|
||||
})
|
||||
.catch(() => undefined);
|
||||
}, [locate]);
|
||||
|
||||
return (
|
||||
@@ -99,17 +104,27 @@ export function CurrentLocationControl({ stations }: { stations: LocatedSynopSta
|
||||
{showPrompt && (
|
||||
<div className="glass-subtle rounded-card p-3.5">
|
||||
<div className="flex items-start gap-3">
|
||||
<div className="rounded-control bg-accent/10 p-2 text-accent"><MapPinned className="size-4" /></div>
|
||||
<div className="rounded-control bg-accent/10 p-2 text-accent">
|
||||
<MapPinned className="size-4" />
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="text-sm font-semibold">{t("location.gpsPromptTitle")}</p>
|
||||
<p className="mt-1 text-xs leading-5 text-muted">{t("location.gpsPromptDescription")}</p>
|
||||
{!isSecureContext && <p className="mt-2 flex items-start gap-1.5 text-xs leading-5 text-warning"><ShieldAlert className="mt-0.5 size-3.5 shrink-0" />{t("location.gpsSecureContext")}</p>}
|
||||
{!isSecureContext && (
|
||||
<p className="mt-2 flex items-start gap-1.5 text-xs leading-5 text-warning">
|
||||
<ShieldAlert className="mt-0.5 size-3.5 shrink-0" />
|
||||
{t("location.gpsSecureContext")}
|
||||
</p>
|
||||
)}
|
||||
<div className="mt-3 flex flex-wrap gap-2">
|
||||
<Button type="button" onClick={locate} disabled={isLocating}>
|
||||
{isLocating ? <LoaderCircle className="size-4 animate-spin" /> : <LocateFixed className="size-4" />}
|
||||
{isLocating ? t("location.gpsLocating") : t("location.gpsAllow")}
|
||||
</Button>
|
||||
<Button type="button" variant="ghost" onClick={dismissPrompt}><X className="size-4" />{t("location.gpsNotNow")}</Button>
|
||||
<Button type="button" variant="ghost" onClick={dismissPrompt}>
|
||||
<X className="size-4" />
|
||||
{t("location.gpsNotNow")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -121,11 +136,23 @@ export function CurrentLocationControl({ stations }: { stations: LocatedSynopSta
|
||||
{isLocating ? <LoaderCircle className="size-4 animate-spin" /> : <LocateFixed className="size-4" />}
|
||||
{isLocating ? t("location.gpsLocating") : t("location.gpsUse")}
|
||||
</Button>
|
||||
{message && <p aria-live="polite" className="max-w-xl text-xs leading-5 text-muted">{message}</p>}
|
||||
{message && (
|
||||
<p aria-live="polite" className="max-w-xl text-xs leading-5 text-muted">
|
||||
{message}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
<p className="text-[0.68rem] text-muted">
|
||||
{t("location.gpsAttribution")} <a href="https://www.openstreetmap.org/copyright" target="_blank" rel="noreferrer" className="inline-flex items-center gap-1 underline decoration-muted/60 underline-offset-2 transition hover:text-accent">OpenStreetMap <ExternalLink className="size-3" /></a>
|
||||
{t("location.gpsAttribution")}{" "}
|
||||
<a
|
||||
href="https://www.openstreetmap.org/copyright"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="inline-flex items-center gap-1 underline decoration-muted/60 underline-offset-2 transition hover:text-accent"
|
||||
>
|
||||
OpenStreetMap <ExternalLink className="size-3" />
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user