initial commit
This commit is contained in:
1
src/app.css
Normal file
1
src/app.css
Normal file
@@ -0,0 +1 @@
|
||||
@import 'tailwindcss';
|
||||
13
src/app.d.ts
vendored
Normal file
13
src/app.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
// See https://svelte.dev/docs/kit/types#app.d.ts
|
||||
// for information about these interfaces
|
||||
declare global {
|
||||
namespace App {
|
||||
// interface Error {}
|
||||
// interface Locals {}
|
||||
// interface PageData {}
|
||||
// interface PageState {}
|
||||
// interface Platform {}
|
||||
}
|
||||
}
|
||||
|
||||
export {};
|
||||
12
src/app.html
Normal file
12
src/app.html
Normal file
@@ -0,0 +1,12 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
%sveltekit.head%
|
||||
</head>
|
||||
<body data-sveltekit-preload-data="hover">
|
||||
<div style="display: contents">%sveltekit.body%</div>
|
||||
</body>
|
||||
</html>
|
||||
7
src/demo.spec.ts
Normal file
7
src/demo.spec.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
describe('sum test', () => {
|
||||
it('adds 1 + 2 to equal 3', () => {
|
||||
expect(1 + 2).toBe(3);
|
||||
});
|
||||
});
|
||||
1
src/lib/index.ts
Normal file
1
src/lib/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
// place files you want to import through the `$lib` alias in this folder.
|
||||
7
src/routes/+layout.svelte
Normal file
7
src/routes/+layout.svelte
Normal file
@@ -0,0 +1,7 @@
|
||||
<script lang="ts">
|
||||
import '../app.css';
|
||||
|
||||
let { children } = $props();
|
||||
</script>
|
||||
|
||||
{@render children()}
|
||||
31
src/routes/+page.svelte
Normal file
31
src/routes/+page.svelte
Normal file
@@ -0,0 +1,31 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import Geolocation from 'svelte-geolocation';
|
||||
import type { GeolocationError } from 'svelte-geolocation/Geolocation.svelte';
|
||||
|
||||
let getPosition: boolean = $state(false);
|
||||
let loading: boolean = $state(false);
|
||||
let position: GeolocationPosition | undefined = $state(undefined);
|
||||
let error: GeolocationError | undefined = $state(undefined);
|
||||
|
||||
function flipGetPosition(): void {
|
||||
getPosition = true;
|
||||
}
|
||||
|
||||
function goToPlayer(): void {
|
||||
goto(`/on-out?lat=${position?.coords.latitude}&long=${position?.coords.longitude}`);
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if !getPosition}
|
||||
<button onclick={flipGetPosition}> Find yourself </button>
|
||||
{:else if loading}
|
||||
<p>Loading...</p>
|
||||
{:else if error}
|
||||
<p>We can't seem to find you.</p>
|
||||
{:else}
|
||||
<p>Your Position is set as: {position?.coords?.latitude}, {position?.coords?.longitude}</p>
|
||||
<button onclick={goToPlayer}>Ok, on-out with it</button>
|
||||
{/if}
|
||||
|
||||
<Geolocation {getPosition} bind:position bind:loading bind:error />
|
||||
9
src/routes/on-out/+page.svelte
Normal file
9
src/routes/on-out/+page.svelte
Normal file
@@ -0,0 +1,9 @@
|
||||
<script lang="ts">
|
||||
import { page } from '$app/state';
|
||||
|
||||
const lat = $derived(page.url.searchParams.get('lat'));
|
||||
const long = $derived(page.url.searchParams.get('long'));
|
||||
|
||||
$inspect(lat);
|
||||
$inspect(long);
|
||||
</script>
|
||||
13
src/routes/page.svelte.test.ts
Normal file
13
src/routes/page.svelte.test.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { page } from '@vitest/browser/context';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { render } from 'vitest-browser-svelte';
|
||||
import Page from './+page.svelte';
|
||||
|
||||
describe('/+page.svelte', () => {
|
||||
it('should render h1', async () => {
|
||||
render(Page);
|
||||
|
||||
const heading = page.getByRole('heading', { level: 1 });
|
||||
await expect.element(heading).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user