chore: formatting
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
@import "tailwindcss";
|
@import 'tailwindcss';
|
||||||
|
|
||||||
@import "tw-animate-css";
|
@import 'tw-animate-css';
|
||||||
|
|
||||||
@custom-variant dark (&:is(.dark *));
|
@custom-variant dark (&:is(.dark *));
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
export { default as Toaster } from "./sonner.svelte";
|
export { default as Toaster } from './sonner.svelte';
|
||||||
|
|||||||
@@ -11,4 +11,14 @@ export { default as LocationButton } from './components/LocationButton.svelte';
|
|||||||
|
|
||||||
// Location utilities and stores
|
// Location utilities and stores
|
||||||
export { geolocationService } from './utils/geolocation';
|
export { geolocationService } from './utils/geolocation';
|
||||||
export { locationActions, locationStore, coordinates, locationStatus, locationError, isLocationLoading, hasLocationAccess, getMapCenter, getMapZoom } from './stores/location';
|
export {
|
||||||
|
locationActions,
|
||||||
|
locationStore,
|
||||||
|
coordinates,
|
||||||
|
locationStatus,
|
||||||
|
locationError,
|
||||||
|
isLocationLoading,
|
||||||
|
hasLocationAccess,
|
||||||
|
getMapCenter,
|
||||||
|
getMapZoom
|
||||||
|
} from './stores/location';
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
import { writable, derived } from 'svelte/store';
|
import { writable, derived } from 'svelte/store';
|
||||||
import { geolocationService, type LocationCoordinates, type LocationError, type LocationStatus } from '$lib/utils/geolocation';
|
import {
|
||||||
|
geolocationService,
|
||||||
|
type LocationCoordinates,
|
||||||
|
type LocationError,
|
||||||
|
type LocationStatus
|
||||||
|
} from '$lib/utils/geolocation';
|
||||||
|
|
||||||
interface LocationState {
|
interface LocationState {
|
||||||
coordinates: LocationCoordinates | null;
|
coordinates: LocationCoordinates | null;
|
||||||
@@ -24,8 +29,14 @@ export const locationStore = writable<LocationState>(initialState);
|
|||||||
export const coordinates = derived(locationStore, ($location) => $location.coordinates);
|
export const coordinates = derived(locationStore, ($location) => $location.coordinates);
|
||||||
export const locationStatus = derived(locationStore, ($location) => $location.status);
|
export const locationStatus = derived(locationStore, ($location) => $location.status);
|
||||||
export const locationError = derived(locationStore, ($location) => $location.error);
|
export const locationError = derived(locationStore, ($location) => $location.error);
|
||||||
export const isLocationLoading = derived(locationStore, ($location) => $location.status === 'loading');
|
export const isLocationLoading = derived(
|
||||||
export const hasLocationAccess = derived(locationStore, ($location) => $location.coordinates !== null);
|
locationStore,
|
||||||
|
($location) => $location.status === 'loading'
|
||||||
|
);
|
||||||
|
export const hasLocationAccess = derived(
|
||||||
|
locationStore,
|
||||||
|
($location) => $location.coordinates !== null
|
||||||
|
);
|
||||||
|
|
||||||
// Location actions
|
// Location actions
|
||||||
export const locationActions = {
|
export const locationActions = {
|
||||||
@@ -33,7 +44,7 @@ export const locationActions = {
|
|||||||
* Get current position once
|
* Get current position once
|
||||||
*/
|
*/
|
||||||
async getCurrentLocation(options?: PositionOptions): Promise<LocationCoordinates | null> {
|
async getCurrentLocation(options?: PositionOptions): Promise<LocationCoordinates | null> {
|
||||||
locationStore.update(state => ({
|
locationStore.update((state) => ({
|
||||||
...state,
|
...state,
|
||||||
status: 'loading',
|
status: 'loading',
|
||||||
error: null
|
error: null
|
||||||
@@ -42,7 +53,7 @@ export const locationActions = {
|
|||||||
try {
|
try {
|
||||||
const coordinates = await geolocationService.getCurrentPosition(options);
|
const coordinates = await geolocationService.getCurrentPosition(options);
|
||||||
|
|
||||||
locationStore.update(state => ({
|
locationStore.update((state) => ({
|
||||||
...state,
|
...state,
|
||||||
coordinates,
|
coordinates,
|
||||||
status: 'success',
|
status: 'success',
|
||||||
@@ -54,7 +65,7 @@ export const locationActions = {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
const locationError = error as LocationError;
|
const locationError = error as LocationError;
|
||||||
|
|
||||||
locationStore.update(state => ({
|
locationStore.update((state) => ({
|
||||||
...state,
|
...state,
|
||||||
status: 'error',
|
status: 'error',
|
||||||
error: locationError,
|
error: locationError,
|
||||||
@@ -70,7 +81,7 @@ export const locationActions = {
|
|||||||
*/
|
*/
|
||||||
startWatching(options?: PositionOptions): void {
|
startWatching(options?: PositionOptions): void {
|
||||||
if (!geolocationService.isSupported()) {
|
if (!geolocationService.isSupported()) {
|
||||||
locationStore.update(state => ({
|
locationStore.update((state) => ({
|
||||||
...state,
|
...state,
|
||||||
status: 'error',
|
status: 'error',
|
||||||
error: {
|
error: {
|
||||||
@@ -81,7 +92,7 @@ export const locationActions = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
locationStore.update(state => ({
|
locationStore.update((state) => ({
|
||||||
...state,
|
...state,
|
||||||
status: 'loading',
|
status: 'loading',
|
||||||
isWatching: true,
|
isWatching: true,
|
||||||
@@ -90,7 +101,7 @@ export const locationActions = {
|
|||||||
|
|
||||||
geolocationService.watchPosition(
|
geolocationService.watchPosition(
|
||||||
(coordinates) => {
|
(coordinates) => {
|
||||||
locationStore.update(state => ({
|
locationStore.update((state) => ({
|
||||||
...state,
|
...state,
|
||||||
coordinates,
|
coordinates,
|
||||||
status: 'success',
|
status: 'success',
|
||||||
@@ -99,7 +110,7 @@ export const locationActions = {
|
|||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
locationStore.update(state => ({
|
locationStore.update((state) => ({
|
||||||
...state,
|
...state,
|
||||||
status: 'error',
|
status: 'error',
|
||||||
error,
|
error,
|
||||||
@@ -116,7 +127,7 @@ export const locationActions = {
|
|||||||
stopWatching(): void {
|
stopWatching(): void {
|
||||||
geolocationService.clearWatch();
|
geolocationService.clearWatch();
|
||||||
|
|
||||||
locationStore.update(state => ({
|
locationStore.update((state) => ({
|
||||||
...state,
|
...state,
|
||||||
isWatching: false
|
isWatching: false
|
||||||
}));
|
}));
|
||||||
@@ -134,7 +145,7 @@ export const locationActions = {
|
|||||||
* Set coordinates manually (useful for testing or setting default location)
|
* Set coordinates manually (useful for testing or setting default location)
|
||||||
*/
|
*/
|
||||||
setCoordinates(coordinates: LocationCoordinates): void {
|
setCoordinates(coordinates: LocationCoordinates): void {
|
||||||
locationStore.update(state => ({
|
locationStore.update((state) => ({
|
||||||
...state,
|
...state,
|
||||||
coordinates,
|
coordinates,
|
||||||
status: 'success',
|
status: 'success',
|
||||||
@@ -149,7 +160,7 @@ export const locationActions = {
|
|||||||
isLocationStale(maxAgeMinutes: number = 5): boolean {
|
isLocationStale(maxAgeMinutes: number = 5): boolean {
|
||||||
let currentState: LocationState = initialState;
|
let currentState: LocationState = initialState;
|
||||||
|
|
||||||
const unsubscribe = locationStore.subscribe(state => {
|
const unsubscribe = locationStore.subscribe((state) => {
|
||||||
currentState = state;
|
currentState = state;
|
||||||
});
|
});
|
||||||
unsubscribe();
|
unsubscribe();
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import { clsx, type ClassValue } from "clsx";
|
import { clsx, type ClassValue } from 'clsx';
|
||||||
import { twMerge } from "tailwind-merge";
|
import { twMerge } from 'tailwind-merge';
|
||||||
|
|
||||||
export function cn(...inputs: ClassValue[]) {
|
export function cn(...inputs: ClassValue[]) {
|
||||||
return twMerge(clsx(inputs));
|
return twMerge(clsx(inputs));
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
export type WithoutChild<T> = T extends { child?: any } ? Omit<T, "child"> : T;
|
export type WithoutChild<T> = T extends { child?: any } ? Omit<T, 'child'> : T;
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
export type WithoutChildren<T> = T extends { children?: any } ? Omit<T, "children"> : T;
|
export type WithoutChildren<T> = T extends { children?: any } ? Omit<T, 'children'> : T;
|
||||||
export type WithoutChildrenOrChild<T> = WithoutChildren<WithoutChild<T>>;
|
export type WithoutChildrenOrChild<T> = WithoutChildren<WithoutChild<T>>;
|
||||||
export type WithElementRef<T, U extends HTMLElement = HTMLElement> = T & { ref?: U | null };
|
export type WithElementRef<T, U extends HTMLElement = HTMLElement> = T & { ref?: U | null };
|
||||||
|
|||||||
@@ -180,10 +180,7 @@ export class GeolocationService {
|
|||||||
/**
|
/**
|
||||||
* Calculate distance between two coordinates in kilometers
|
* Calculate distance between two coordinates in kilometers
|
||||||
*/
|
*/
|
||||||
static calculateDistance(
|
static calculateDistance(coord1: LocationCoordinates, coord2: LocationCoordinates): number {
|
||||||
coord1: LocationCoordinates,
|
|
||||||
coord2: LocationCoordinates
|
|
||||||
): number {
|
|
||||||
const R = 6371; // Earth's radius in kilometers
|
const R = 6371; // Earth's radius in kilometers
|
||||||
const dLat = this.toRadians(coord2.latitude - coord1.latitude);
|
const dLat = this.toRadians(coord2.latitude - coord1.latitude);
|
||||||
const dLon = this.toRadians(coord2.longitude - coord1.longitude);
|
const dLon = this.toRadians(coord2.longitude - coord1.longitude);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ const config = {
|
|||||||
trustedOrigins: ['http://localhost:3000', 'https://serengo.ziasvannes.tech']
|
trustedOrigins: ['http://localhost:3000', 'https://serengo.ziasvannes.tech']
|
||||||
},
|
},
|
||||||
alias: {
|
alias: {
|
||||||
"@/*": "./src/lib/*"
|
'@/*': './src/lib/*'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user