adds new default state images

This commit is contained in:
Christian Beutel
2024-03-11 00:08:02 +01:00
parent a2819f3b45
commit 02c82d3e46
25 changed files with 191 additions and 98 deletions

View File

@@ -7,7 +7,7 @@
<img
style="width: {width}px"
class="rounded-full aspect-square"
src="/imgs/empty_state.webp"
src="/imgs/empty_state.png"
alt="Empty State showing a wanderer going into the distance"
/>

View File

@@ -78,7 +78,7 @@
function handleDropdownClick(item: { text: string; value: any }) {
if (item.value == "logout") {
logout();
goto("/");
window.location.href = "/";
} else if (item.value == "profile") {
goto("/profile");
}
@@ -117,7 +117,7 @@
<hr class="my-6 border-input-border" />
<div class="flex flex-col basis-full">
<a class="btn-primary btn-large text-center mx-4" href="/trail/edit/new"
><i class="fa fa-plus mr-2"></i>{$_('new-trail')}</a
><i class="fa fa-plus mr-2"></i>{$_("new-trail")}</a
>
{#if $currentUser}
<div class="basis-full"></div>
@@ -180,7 +180,7 @@
on:click={() => toggleTheme()}
></button>
<a class="btn-primary btn-large" href="/trail/edit/new"
><i class="fa fa-plus mr-2"></i>{$_('new-trail')}</a
><i class="fa fa-plus mr-2"></i>{$_("new-trail")}</a
>
<Dropdown
items={dropdownItems}
@@ -208,7 +208,7 @@
: 'moon'}"
on:click={() => toggleTheme()}
></button>
<a class="btn-primary btn-large" href="/login">{$_('login')}</a>
<a class="btn-primary btn-large" href="/login">{$_("login")}</a>
</div>
{/if}
<button

View File

@@ -8,6 +8,10 @@
} from "$lib/util/format_util";
export let trail: Trail;
$: thumbnail = trail.photos.length
? getFileURL(trail, trail.photos[trail.thumbnail])
: "/imgs/default_thumbnail.webp";
</script>
<div
@@ -17,7 +21,7 @@
role="listitem"
>
<div class="w-full min-h-40 max-h-48 overflow-hidden rounded-t-2xl">
<img src={getFileURL(trail, trail.photos[trail.thumbnail])} alt="" />
<img src={thumbnail} alt="" />
</div>
<div class="p-4">
<div>

View File

@@ -97,7 +97,7 @@
<div id="trails" class="flex items-start flex-wrap gap-8 py-8 max-w-full">
{#if trails.length == 0}
<div class="flex flex-col basis-full items-center">
<EmptyStateSearch></EmptyStateSearch>
<EmptyStateSearch width={356}></EmptyStateSearch>
</div>
{/if}
{#each trails as trail}

View File

@@ -1,20 +1,24 @@
<script lang="ts">
import type { Trail } from "$lib/models/trail";
import { getFileURL } from "$lib/util/file_util";
import { formatDistance, formatElevation, formatTimeHHMM } from "$lib/util/format_util";
import {
formatDistance,
formatElevation,
formatTimeHHMM,
} from "$lib/util/format_util";
export let trail: Trail;
$: thumbnail = trail.photos.length
? getFileURL(trail, trail.photos[trail.thumbnail])
: "/imgs/default_thumbnail.webp";
</script>
<li
class="flex gap-8 p-4 rounded-xl border border-input-border cursor-pointer hover:bg-secondary-hover transition-colors"
>
<div class="shrink-0">
<img
class="h-28 w-28 object-cover rounded-xl"
src={getFileURL(trail, trail.photos[trail.thumbnail])}
alt=""
/>
<img class="h-28 w-28 object-cover rounded-xl" src={thumbnail} alt="" />
</div>
<div class="min-w-0 basis-full">
<h4 class="font-semibold text-lg">{trail.name}</h4>

View File

@@ -28,7 +28,7 @@
"delete-trail-confirm": "Möchtest du diese Route wirklich löschen? Diese Aktion kann nicht rückgängig gemacht werden.",
"describe-your-trail": "Beschreibe deine Route",
"description": "Beschreibung",
"difficult": "Schwierig",
"difficult": "Schwer",
"difficulty": "Schwierigkeit",
"directions": "Wegbeschreibung",
"display-as": "Anzeigen als",
@@ -42,16 +42,21 @@
"elevation-gain": "Höhenunterschied",
"email": "Email",
"english": "Englisch",
"error-creating-user": "Fehler beim Erstellen des Nutzers",
"error-during-login": "Fehler beim Login",
"est-duration": "Gesch. Dauer",
"explore": "Erkunden",
"explore-some-trails": "Erkunden Sie einige Routen",
"features": "Feature",
"german": "Deutsch",
"hero_section_0_text": "Entdecke spannende Routen, speichere deine Favoriten und erlebe die Schönheit der Natur. Finde dein nächstes Abenteuer!",
"hero_section_1_heading": "Hier gibt es noch keine Routen",
"hero_section_1_text": "Hier sind einige Routen, die dir gefallen könnten. Oder du wirfst einen Blick auf die vollständige Liste.",
"hero_section_1_text_alternative": "Speichere dein letztes Abenteuer, um loszulegen.",
"hero_section_2_text": "Wusstest du schon? Du kannst nicht nur deine Routen speichern. Es gibt viele Kategorien für alle deine Abenteuer.",
"icon": "Icon",
"imperial": "Amerikanisch",
"invalid-username": "Ungültiger Nutzername",
"language": "Sprache",
"latitude": "Breitengrad",
"license": "Lizenz",
@@ -65,6 +70,7 @@
"map": "Karte",
"metric": "Metrisch",
"moderate": "Mittel",
"must-be-at-least-8-characters-long": "Muss mindestens 8 Zeichen lang sein",
"name": "Name",
"near": "Nahe",
"new-list": "Neue Liste",
@@ -72,6 +78,7 @@
"no-account": "Du hast noch kein Konto?",
"no-preference": "Keine Präferenz",
"no-results": "Keine Ergebnisse gefunden",
"not-a-valid-email-address": "Keine gültige Email-Adresse",
"not-completed": "Nicht abgeschlossen",
"password": "Passwort",
"photos": "Fotos",
@@ -81,6 +88,7 @@
"radius": "Radius",
"register": "Registrieren",
"removed-trail-from": "Route entfernt aus",
"required": "Pflichtfeld",
"save": "Speichern",
"save-trail": "Route speichern",
"search-cities": "Städte suchen",
@@ -100,5 +108,6 @@
"upload-gpx": "GPX hochladen",
"username": "Nutzername",
"waypoints": "Wegpunkte",
"welcome_to": "Willkommen bei"
"welcome_to": "Willkommen bei",
"wrong-username-or-password": "Falscher Nutzername oder falsches Passwort"
}

View File

@@ -42,16 +42,21 @@
"elevation-gain": "Elevation Gain",
"email": "Email",
"english": "English",
"error-creating-user": "Error creating user",
"error-during-login": "Error during login",
"est-duration": "Est. duration",
"explore": "Explore",
"explore-some-trails": "Explore some trails",
"features": "Features",
"german": "German",
"hero_section_0_text": "Explore exciting trails, save your favorites, and experience the beauty of nature. Find your next adventure!",
"hero_section_1_heading": "It seems there are no trails here yet.",
"hero_section_1_text": "Here are some trails you might like. Or you can just go to the full list right now.",
"hero_section_1_text_alternative": "Get started by saving your latest adventure.",
"hero_section_2_text": "Did you know? You cannot only save you hiking trails. There are many categories for all your adventures.",
"icon": "Icon",
"imperial": "Imperial",
"invalid-username": "Invalid username",
"language": "Language",
"latitude": "Latitude",
"license": "License",
@@ -65,6 +70,7 @@
"map": "Map",
"metric": "Metric",
"moderate": "Moderate",
"must-be-at-least-8-characters-long": "Must be at least 8 characters long",
"name": "Name",
"near": "Near",
"new-list": "New List",
@@ -72,6 +78,7 @@
"no-account": "Don't have an account?",
"no-preference": "No preference",
"no-results": "No results found",
"not-a-valid-email-address": "Not a valid email address",
"not-completed": "Not completed",
"password": "Password",
"photos": "Photos",
@@ -81,6 +88,7 @@
"radius": "Radius",
"register": "Register",
"removed-trail-from": "Removed trail from",
"required": "Required",
"save": "Save",
"save-trail": "Save Trail",
"search-cities": "Search cities",
@@ -100,5 +108,6 @@
"upload-gpx": "Upload GPX",
"username": "Username",
"waypoints": "Waypoints",
"welcome_to": "Welcome to"
"welcome_to": "Welcome to",
"wrong-username-or-password": "Wrong username or password"
}

View File

@@ -1,4 +1,3 @@
import { array, number, object, string } from "yup";
import type { Category } from "./category";
import type { SummitLog } from "./summit_log";
import type { Waypoint } from "./waypoint";
@@ -11,7 +10,7 @@ class Trail {
distance?: number;
elevation_gain?: number;
duration?: number;
difficulty?: "easy"|"moderate"|"difficult"
difficulty?: "easy" | "moderate" | "difficult"
lat?: number;
lon?: number;
thumbnail: number;
@@ -39,8 +38,8 @@ class Trail {
distance?: number,
elevation_gain?: number,
duration?: number,
difficulty?: "easy"|"moderate"|"difficult",
lat?:number,
difficulty?: "easy" | "moderate" | "difficult",
lat?: number,
lon?: number,
thumbnail?: number,
photos?: string[],
@@ -66,7 +65,7 @@ class Trail {
this.lon = params?.lon;
this.thumbnail = params?.thumbnail ?? 0;
this.photos = params?.photos ?? [];
this.waypoints = [];
this.waypoints = [];
this.summit_logs = [];
this.gpx = params?.gpx;
this.expand = {
@@ -80,19 +79,6 @@ class Trail {
}
}
const trailSchema = object<Trail>({
id: string().optional(),
name: string().required("Required"),
location: string().optional(),
distance: number().optional(),
elevation_gain: number().optional(),
duration: number().optional(),
thumbnail: string().optional(),
photos: array(string()).optional(),
gpx: string().optional(),
description: string().optional()
});
interface TrailFilter {
q: string,
category: string[],
@@ -108,10 +94,9 @@ interface TrailFilter {
elevationGainMax: number;
completed?: boolean;
sort: "name" | "distance" | "elevation_gain" | "created";
sortOrder: "+" | "-"
sortOrder: "+" | "-"
}
export { Trail, trailSchema };
export type { TrailFilter };
export { Trail };
export type { TrailFilter };

View File

@@ -60,7 +60,7 @@ export async function trails_search_filter(filter: TrailFilter, page: number = 1
if (!r.ok) {
throw new ClientResponseError(result)
}
const trailIds = result.hits.map((h: Record<string, any>) => h.id);
if (trailIds.length == 0) {
@@ -92,6 +92,8 @@ export async function trails_search_bounding_box(northEast: LatLng, southWest: L
if (filter) {
filterText += `distance >= ${filter.distanceMin} AND distance <= ${filter.distanceMax} AND elevation_gain >= ${filter.elevationGainMin} AND elevation_gain <= ${filter.elevationGainMax}`;
filterText += ` AND difficulty IN [${filter.difficulty.join(",")}]`
if (filter.category.length > 0) {
filterText += ` AND category IN [${filter.category.join(",")}]`;
}

View File

@@ -1,6 +1,7 @@
const privateRoutes = [
"/profile",
"/lists"
"/lists",
"/trail",
]
export function isRouteProtected(path: string) {