This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "bracketSameLine": true, | |
| "printWidth": 80, | |
| "singleQuote": true, | |
| "tabWidth": 2, | |
| "trailingComma": "all", | |
| "useTabs": true | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // A generic Firestore converter that provides type inference | |
| export const genericConverter = <T>() => ({ | |
| toFirestore: (data: PartialWithFieldValue<T>) => data ?? {}, | |
| fromFirestore: (snap: QueryDocumentSnapshot) => snap.data() as T, | |
| }); | |
| // A wrapper of collection() that uses a generic converter to provide type inference | |
| export const typedCollection = <T>(db: Firestore, name: string) => | |
| collection(db, name).withConverter<T>(genericConverter<T>()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default function clickOutside(node: HTMLElement) { | |
| const handleClick = (event: MouseEvent) => { | |
| if (!node.contains(event.target as Node)) { | |
| node.dispatchEvent(new CustomEvent('outsideclick')); | |
| } | |
| }; | |
| // The node has been mounted to the DOM | |
| window.addEventListener('click', handleClick); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default function stopPropagation(fn: (e: Event) => void) { | |
| return function (this: (e: Event) => void, event: Event) { | |
| event.stopPropagation(); | |
| fn.call(this, event); | |
| }; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { linear } from 'svelte/easing'; | |
| type TickFunc = (t: number) => number | void; | |
| export interface TailwindTransitionOptions { | |
| delay?: number; | |
| easing?: (t: number) => number; | |
| base?: string; | |
| from?: string; | |
| to?: string; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export default function preventDefault<T extends Event>(fn: (e: T) => void | Promise<void>) { | |
| return function (this: (e: T) => void, event: T) { | |
| event.preventDefault(); | |
| fn.call(this, event); | |
| }; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = { | |
| theme: { | |
| extend: { | |
| boxShadow: { | |
| 'paper-xs': '0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24)', | |
| 'paper-sm': '0 2px 4px rgba(0,0,0,0.14), 0 2px 4px rgba(0,0,0,0.24)', | |
| paper: '0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23)', | |
| 'paper-md': '0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23)', | |
| 'paper-lg': '0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22)', | |
| 'paper-xl': '0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22)', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script lang="ts"> | |
| import { dev } from '$app/environment'; | |
| let hide = $state(false); | |
| </script> | |
| {#if dev} | |
| <aside | |
| ondblclick={() => (hide = true)} | |
| class:!hidden={hide} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // !! This is yet untested | |
| import type { Writable } from 'svelte/store'; | |
| export const toState = <T>(store: Writable<T>, initial: T | null = null) => { | |
| let value = $state<T | null>(initial); | |
| const stateful = { | |
| get: () => value, | |
| set: (newValue: T) => { | |
| store.set(newValue); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type ErrorName = 'Unknown Error' | 'Initialization Error'; | |
| export class ProjectError extends Error { | |
| name: ErrorName; | |
| data?: Record<string, unknown>; | |
| constructor({ name, message, data }: { name: ErrorName; message: string; data?: Record<string, unknown> }) { | |
| super(); | |
| this.name = name; | |
| this.message = message; |