"npx prettier" pass on the files changed in this PR
Does not include changes to `website/src/lib/db.ts`, because there would otherwise be lots of unrelated formatting changes
This commit is contained in:
parent
7db43d3e35
commit
62da9b7f37
3 changed files with 249 additions and 230 deletions
|
|
@ -23,18 +23,18 @@
|
|||
|
||||
<span class={$$props.class}>
|
||||
{#if type === 'distance'}
|
||||
{ getConvertedDistance(value, $distanceUnits).toFixed(decimals ?? 2) }
|
||||
{ showUnits ? getDistanceUnits($distanceUnits) : '' }
|
||||
{getConvertedDistance(value, $distanceUnits).toFixed(decimals ?? 2)}
|
||||
{showUnits ? getDistanceUnits($distanceUnits) : ''}
|
||||
{:else if type === 'elevation'}
|
||||
{ getConvertedElevation(value, $distanceUnits).toFixed(decimals ?? 2) }
|
||||
{ showUnits ? getElevationUnits($distanceUnits) : '' }
|
||||
{getConvertedElevation(value, $distanceUnits).toFixed(decimals ?? 2)}
|
||||
{showUnits ? getElevationUnits($distanceUnits) : ''}
|
||||
{:else if type === 'speed'}
|
||||
{#if $velocityUnits === 'speed'}
|
||||
{ getConvertedVelocity(value, $velocityUnits, $distanceUnits).toFixed(decimals ?? 2) }
|
||||
{ showUnits ? getVelocityUnits($velocityUnits, $distanceUnits) : '' }
|
||||
{getConvertedVelocity(value, $velocityUnits, $distanceUnits).toFixed(decimals ?? 2)}
|
||||
{showUnits ? getVelocityUnits($velocityUnits, $distanceUnits) : ''}
|
||||
{:else}
|
||||
{ secondsToHHMMSS(getConvertedVelocity(value, $velocityUnits, $distanceUnits)) }
|
||||
{ showUnits ? getVelocityUnits($velocityUnits, $distanceUnits) : '' }
|
||||
{secondsToHHMMSS(getConvertedVelocity(value, $velocityUnits, $distanceUnits))}
|
||||
{showUnits ? getVelocityUnits($velocityUnits, $distanceUnits) : ''}
|
||||
{/if}
|
||||
{:else if type === 'temperature'}
|
||||
{#if $temperatureUnits === 'celsius'}
|
||||
|
|
@ -43,6 +43,6 @@
|
|||
{celsiusToFahrenheit(value)} {showUnits ? $_('units.fahrenheit') : ''}
|
||||
{/if}
|
||||
{:else if type === 'time'}
|
||||
{ secondsToHHMMSS(value) }
|
||||
{secondsToHHMMSS(value)}
|
||||
{/if}
|
||||
</span>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { PUBLIC_MAPBOX_TOKEN } from "$env/static/public";
|
||||
import { basemaps } from "$lib/assets/layers";
|
||||
import { PUBLIC_MAPBOX_TOKEN } from '$env/static/public';
|
||||
import { basemaps } from '$lib/assets/layers';
|
||||
|
||||
export type EmbeddingOptions = {
|
||||
token: string;
|
||||
|
|
@ -7,21 +7,21 @@ export type EmbeddingOptions = {
|
|||
basemap: string;
|
||||
elevation: {
|
||||
show: boolean;
|
||||
height: number,
|
||||
controls: boolean,
|
||||
fill: 'slope' | 'surface' | undefined,
|
||||
speed: boolean,
|
||||
hr: boolean,
|
||||
cad: boolean,
|
||||
temp: boolean,
|
||||
power: boolean,
|
||||
},
|
||||
distanceMarkers: boolean,
|
||||
directionMarkers: boolean,
|
||||
distanceUnits: 'metric' | 'imperial' | 'nautical',
|
||||
velocityUnits: 'speed' | 'pace',
|
||||
temperatureUnits: 'celsius' | 'fahrenheit',
|
||||
theme: 'system' | 'light' | 'dark',
|
||||
height: number;
|
||||
controls: boolean;
|
||||
fill: 'slope' | 'surface' | undefined;
|
||||
speed: boolean;
|
||||
hr: boolean;
|
||||
cad: boolean;
|
||||
temp: boolean;
|
||||
power: boolean;
|
||||
};
|
||||
distanceMarkers: boolean;
|
||||
directionMarkers: boolean;
|
||||
distanceUnits: 'metric' | 'imperial' | 'nautical';
|
||||
velocityUnits: 'speed' | 'pace';
|
||||
temperatureUnits: 'celsius' | 'fahrenheit';
|
||||
theme: 'system' | 'light' | 'dark';
|
||||
};
|
||||
|
||||
export const defaultEmbeddingOptions = {
|
||||
|
|
@ -37,21 +37,24 @@ export const defaultEmbeddingOptions = {
|
|||
hr: false,
|
||||
cad: false,
|
||||
temp: false,
|
||||
power: false,
|
||||
power: false
|
||||
},
|
||||
distanceMarkers: false,
|
||||
directionMarkers: false,
|
||||
distanceUnits: 'metric',
|
||||
velocityUnits: 'speed',
|
||||
temperatureUnits: 'celsius',
|
||||
theme: 'system',
|
||||
theme: 'system'
|
||||
};
|
||||
|
||||
export function getDefaultEmbeddingOptions(): EmbeddingOptions {
|
||||
return JSON.parse(JSON.stringify(defaultEmbeddingOptions));
|
||||
}
|
||||
|
||||
export function getMergedEmbeddingOptions(options: any, defaultOptions: any = defaultEmbeddingOptions): EmbeddingOptions {
|
||||
export function getMergedEmbeddingOptions(
|
||||
options: any,
|
||||
defaultOptions: any = defaultEmbeddingOptions
|
||||
): EmbeddingOptions {
|
||||
const mergedOptions = JSON.parse(JSON.stringify(defaultOptions));
|
||||
for (const key in options) {
|
||||
if (typeof options[key] === 'object' && options[key] !== null && !Array.isArray(options[key])) {
|
||||
|
|
@ -63,10 +66,17 @@ export function getMergedEmbeddingOptions(options: any, defaultOptions: any = de
|
|||
return mergedOptions;
|
||||
}
|
||||
|
||||
export function getCleanedEmbeddingOptions(options: any, defaultOptions: any = defaultEmbeddingOptions): any {
|
||||
export function getCleanedEmbeddingOptions(
|
||||
options: any,
|
||||
defaultOptions: any = defaultEmbeddingOptions
|
||||
): any {
|
||||
const cleanedOptions = JSON.parse(JSON.stringify(options));
|
||||
for (const key in cleanedOptions) {
|
||||
if (typeof cleanedOptions[key] === 'object' && cleanedOptions[key] !== null && !Array.isArray(cleanedOptions[key])) {
|
||||
if (
|
||||
typeof cleanedOptions[key] === 'object' &&
|
||||
cleanedOptions[key] !== null &&
|
||||
!Array.isArray(cleanedOptions[key])
|
||||
) {
|
||||
cleanedOptions[key] = getCleanedEmbeddingOptions(cleanedOptions[key], defaultOptions[key]);
|
||||
if (Object.keys(cleanedOptions[key]).length === 0) {
|
||||
delete cleanedOptions[key];
|
||||
|
|
@ -78,7 +88,9 @@ export function getCleanedEmbeddingOptions(options: any, defaultOptions: any = d
|
|||
return cleanedOptions;
|
||||
}
|
||||
|
||||
export const allowedEmbeddingBasemaps = Object.keys(basemaps).filter(basemap => !['ordnanceSurvey'].includes(basemap));
|
||||
export const allowedEmbeddingBasemaps = Object.keys(basemaps).filter(
|
||||
(basemap) => !['ordnanceSurvey'].includes(basemap)
|
||||
);
|
||||
|
||||
export function getURLForGoogleDriveFile(fileId: string): string {
|
||||
return `https://www.googleapis.com/drive/v3/files/${fileId}?alt=media&key=AIzaSyA2ZadQob_hXiT2VaYIkAyafPvz_4ZMssk`;
|
||||
|
|
@ -87,7 +99,7 @@ export function getURLForGoogleDriveFile(fileId: string): string {
|
|||
export function convertOldEmbeddingOptions(options: URLSearchParams): any {
|
||||
let newOptions: any = {
|
||||
token: PUBLIC_MAPBOX_TOKEN,
|
||||
files: [],
|
||||
files: []
|
||||
};
|
||||
if (options.has('state')) {
|
||||
let state = JSON.parse(options.get('state')!);
|
||||
|
|
@ -122,7 +134,7 @@ export function convertOldEmbeddingOptions(options: URLSearchParams): any {
|
|||
}
|
||||
if (options.has('slope')) {
|
||||
newOptions.elevation = {
|
||||
fill: 'slope',
|
||||
fill: 'slope'
|
||||
};
|
||||
}
|
||||
return newOptions;
|
||||
|
|
|
|||
|
|
@ -111,7 +111,10 @@ export function getDistanceUnits(targetDistanceUnits = get(distanceUnits)) {
|
|||
}
|
||||
}
|
||||
|
||||
export function getVelocityUnits(targetVelocityUnits = get(velocityUnits), targetDistanceUnits = get(distanceUnits)) {
|
||||
export function getVelocityUnits(
|
||||
targetVelocityUnits = get(velocityUnits),
|
||||
targetDistanceUnits = get(distanceUnits)
|
||||
) {
|
||||
if (targetVelocityUnits === 'speed') {
|
||||
switch (targetDistanceUnits) {
|
||||
case 'metric':
|
||||
|
|
@ -169,7 +172,11 @@ export function getConvertedElevation(value: number, targetDistanceUnits = get(d
|
|||
return targetDistanceUnits === 'metric' ? value : metersToFeet(value);
|
||||
}
|
||||
|
||||
export function getConvertedVelocity(value: number, targetVelocityUnits = get(velocityUnits), targetDistanceUnits = get(distanceUnits)) {
|
||||
export function getConvertedVelocity(
|
||||
value: number,
|
||||
targetVelocityUnits = get(velocityUnits),
|
||||
targetDistanceUnits = get(distanceUnits)
|
||||
) {
|
||||
if (targetVelocityUnits === 'speed') {
|
||||
switch (targetDistanceUnits) {
|
||||
case 'metric':
|
||||
|
|
|
|||
Loading…
Reference in a new issue