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 function logError(err: unknown, context?: string) { | |
| // Convert to Error if it's not one | |
| let error: Error; | |
| if (err instanceof Error) { | |
| error = err; | |
| } else { | |
| // Wrap string in Error, but pop first line of stack (which will be this line) | |
| error = new Error(String(err)); | |
| error.stack = error.stack?.split('\n').slice(1).join('\n'); | |
| } |
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
| root = true | |
| [*] | |
| end_of_line = lf | |
| insert_final_newline = true | |
| indent_style = tab | |
| indent_size = 2 | |
| charset = utf-8 | |
| trim_trailing_whitespace = 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
| <!-- This component disables CSS transitions until onMount fires, in order to avoid FOUC --> | |
| <script lang="ts"> | |
| import { tick } from 'svelte'; | |
| // Adds 'mounted' class to body to signal that transitions should be enabled | |
| $effect(() => { | |
| tick().then(() => document.firstElementChild?.setAttribute('data-mounted', 'true')); | |
| }); | |
| </script> |
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 interface Options { | |
| bubble: boolean; | |
| } | |
| // When applied to an input, it will blur the input when the escape key is pressed | |
| // By default it will prevent the default action of the escape key, which is useful | |
| // for inputs in dialogs | |
| export default function blurOnEscape(node: HTMLElement, options: Options = { bubble: false }) { | |
| const onKeydown = (event: KeyboardEvent) => { | |
| if (event.key !== 'Escape') return; |
OlderNewer