MVP #5.3 #75

Merged
matthieu42morin merged 25 commits from master into deploy/prod 2023-03-16 15:12:10 +00:00
4 changed files with 36 additions and 35 deletions
Showing only changes of commit 74d2cf607e - Show all commits

View File

@ -55,6 +55,5 @@
width: 100%;
position: relative;
max-width: var(--max-viewport-width);
padding: 10px;
}
</style>

View File

@ -44,7 +44,7 @@
<div class={'section w-full h-[calc(100%-100px)] overflow-auto ' + className}><slot /></div>
<div class="footer">
{#each items as { name, url, image_url }}
{#if location.pathname === url || location.pathname.includes("/" + url.split("/")[0] + '/')}
{#if location.pathname === url || location.pathname.includes('/' + url.split('/')[0] + '/')}
<FooterItem on:click={() => navigate(url)} active={true} {name} {url}>
<img alt="" style="filter: invert(44%) sepia(66%) saturate(6619%) hue-rotate(222deg) brightness(98%) contrast(88%);" src={image_url} />
</FooterItem>

View File

@ -10,6 +10,8 @@
export let radius = false
export let center: { lng: number; lat: number } = { lng: 0, lat: 0 }
$: console.log(center)
/*export const geo = (e) => {
geolocateControl.dispatchEvent('geolocate')
if (navigator.geolocation) {

View File

@ -1,43 +1,43 @@
<script lang="ts">
import NavigationBarLayout from '$lib/components/Layouts/NavigationBarLayout.svelte';
import Erantmap from '$lib/components/Map/Erantmap.svelte';
import LocationRequest from '$lib/components/Map/LocationRequest.svelte';
import { onMount } from 'svelte';
import NavigationBarLayout from '$lib/components/Layouts/NavigationBarLayout.svelte'
import Erantmap from '$lib/components/Map/Erantmap.svelte'
import LocationRequest from '$lib/components/Map/LocationRequest.svelte'
import { onMount } from 'svelte'
let user: { lat: number, lng: number } = null;
let granted = false;
let user: { lat: number; lng: number } = { lat: 0, lng: 0 }
let granted = false
const lastGame = localStorage.getItem('lastGame')
const handleLocationGranted = (position: GeolocationPosition) => {
user = { lat: position.coords.latitude, lng: position.coords.longitude };
granted = true;
user = { lat: position.coords.latitude, lng: position.coords.longitude }
granted = true
}
onMount(() => {
if ('permissions' in navigator) {
navigator.permissions.query({ name: 'geolocation' }).then((permissionStatus) => {
if (permissionStatus.state === 'granted') {
navigator.geolocation.getCurrentPosition(
(position) => {
handleLocationGranted(position);
},
(error) => {
console.log(error);
}
);
}
});
}
});
</script>
if ('permissions' in navigator) {
navigator.permissions.query({ name: 'geolocation' }).then((permissionStatus) => {
if (permissionStatus.state === 'granted') {
navigator.geolocation.getCurrentPosition(
(position) => {
handleLocationGranted(position)
},
(error) => {
console.log(error)
},
)
}
})
}
})
</script>
<NavigationBarLayout>
<NavigationBarLayout>
{#if granted}
<!-- Conditionally center on current location if granted is true. -->
<Erantmap class="w-full h-full" center={{ lng: user.lng, lat: user.lat }} bind:user />
<!-- Conditionally center on current location if granted is true. -->
<Erantmap class="w-full h-full" center={{ lng: user.lng, lat: user.lat }} bind:user />
{:else}
<!--If not granted, the LocationRequest component is displayed and when it is granted center map. -->
<LocationRequest on:locationGranted={() => granted = true} />
<!--If not granted, the LocationRequest component is displayed and when it is granted center map. -->
<LocationRequest on:locationGranted={() => (granted = true)} />
{/if}
</NavigationBarLayout>
</NavigationBarLayout>