diff --git a/frontend/src/lib/components/ImageInfoModal.svelte b/frontend/src/lib/components/ImageInfoModal.svelte new file mode 100644 index 0000000..fed5234 --- /dev/null +++ b/frontend/src/lib/components/ImageInfoModal.svelte @@ -0,0 +1,56 @@ + + + + + + + + About This Background + + + + + + {#if background.author != ''} + Photo by {background.author} + {/if} + {#if background.location != ''} + Location: {background.location} + {/if} + (window.location.href = 'https://forms.gle/2uZNnz8QS3VjuYtQ8')} + class="btn btn-neutral inline-block mt-4 mb-2">Submit an Image + + + Close + + diff --git a/frontend/src/lib/index.ts b/frontend/src/lib/index.ts index 6e228d7..52073ad 100644 --- a/frontend/src/lib/index.ts +++ b/frontend/src/lib/index.ts @@ -1,6 +1,14 @@ import inspirationalQuotes from './json/quotes.json'; import randomBackgrounds from './json/backgrounds.json'; -import type { Adventure, Checklist, Collection, Note, Transportation, User } from './types'; +import type { + Adventure, + Background, + Checklist, + Collection, + Note, + Transportation, + User +} from './types'; export function getRandomQuote() { const quotes = inspirationalQuotes.quotes; @@ -278,5 +286,5 @@ export function isAdventureVisited(adventure: Adventure) { export function getRandomBackground() { const randomIndex = Math.floor(Math.random() * randomBackgrounds.backgrounds.length); - return randomBackgrounds.backgrounds[randomIndex]; + return randomBackgrounds.backgrounds[randomIndex] as Background; } diff --git a/frontend/src/lib/types.ts b/frontend/src/lib/types.ts index f70cd41..8e4dff1 100644 --- a/frontend/src/lib/types.ts +++ b/frontend/src/lib/types.ts @@ -162,3 +162,9 @@ export type ChecklistItem = { created_at: string; // ISO 8601 date string updated_at: string; // ISO 8601 date string }; + +export type Background = { + url: string; + author?: string; + location?: string; +}; diff --git a/frontend/src/routes/login/+page.server.ts b/frontend/src/routes/login/+page.server.ts index 8b634b4..fcafe72 100644 --- a/frontend/src/routes/login/+page.server.ts +++ b/frontend/src/routes/login/+page.server.ts @@ -1,11 +1,22 @@ import { fail, redirect } from '@sveltejs/kit'; import type { Actions, PageServerLoad } from './$types'; +import { getRandomBackground, getRandomQuote } from '$lib'; const PUBLIC_SERVER_URL = process.env['PUBLIC_SERVER_URL']; export const load: PageServerLoad = async (event) => { if (event.locals.user) { return redirect(302, '/'); + } else { + const quote = getRandomQuote(); + const background = getRandomBackground(); + + return { + props: { + quote, + background + } + }; } }; diff --git a/frontend/src/routes/login/+page.svelte b/frontend/src/routes/login/+page.svelte index 276aa54..2e8b1c8 100644 --- a/frontend/src/routes/login/+page.svelte +++ b/frontend/src/routes/login/+page.svelte @@ -7,21 +7,23 @@ console.log(data); import FileImageBox from '~icons/mdi/file-image-box'; - import Account from '~icons/mdi/account'; - import MapMarkerOutline from '~icons/mdi/map-marker-outline'; + + let isImageInfoModalOpen: boolean = false; import { page } from '$app/stores'; - import ImageDisplayModal from '$lib/components/ImageDisplayModal.svelte'; - let quote: { quote: string; author: string } = { quote: '', author: '' }; + import ImageInfoModal from '$lib/components/ImageInfoModal.svelte'; + import type { Background } from '$lib/types.js'; - let background = getRandomBackground(); + let quote: { quote: string; author: string } = data.props.quote; - onMount(async () => { - quote = getRandomQuote(); - }); + let background: Background = data.props.background; +{#if isImageInfoModalOpen} + (isImageInfoModalOpen = false)} /> +{/if} + - + (isImageInfoModalOpen = true)}> - - - - - {background.author} - - {background.location} - (window.location.href = 'https://forms.gle/2uZNnz8QS3VjuYtQ8')} - class="btn btn-sm btn-neutral inline-block ml-4">Submit an Image - - + + Login | AdventureLog
Photo by {background.author}
Location: {background.location}
- - {background.author} - - {background.location} - (window.location.href = 'https://forms.gle/2uZNnz8QS3VjuYtQ8')} - class="btn btn-sm btn-neutral inline-block ml-4">Submit an Image -