-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
utilize more types in LFNext (#1664)
- Loading branch information
billy clark
authored
Jan 10, 2023
1 parent
6c1766b
commit f8f611f
Showing
29 changed files
with
644 additions
and
602 deletions.
There are no files selected for viewing
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 file contains 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 file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<h1 class='text-2xl md:text-3xl { $$props.class }'> | ||
<h1 class='text-2xl md:text-3xl'> | ||
<slot /> | ||
</h1> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<script lang=ts> | ||
import { goto } from '$app/navigation' | ||
type Stat = { | ||
title: string, | ||
value?: number, | ||
icon?: ConstructorOfATypedSvelteComponent, | ||
url?: string | URL, | ||
} | ||
export let stats: Stat[] | ||
$: _stats = stats.map(({ title, value, icon, url }) => ({ | ||
title, | ||
value, | ||
icon, | ||
href: value ? url : '' | ||
})) | ||
const clicked = (href: string | URL = '') => href ? goto(href) : {} | ||
</script> | ||
|
||
<!-- https://daisyui.com/components/stat/ --> | ||
<dl class='stats shadow max-w-full'> <!-- added max-w-full so a horiz scroll will appear on small screens rather than stretching the whole doc --> | ||
{#each _stats as { title, value, icon, href }} | ||
<div class='stat place-items-center' class:href on:click={ () => clicked(href) } on:keydown={ () => clicked(href) }> | ||
<dt class=stat-title>{ title }</dt> | ||
<dd class='stat-value text-primary'>{ Number(value).toLocaleString() }</dd> | ||
|
||
{#if icon} | ||
<div class='stat-figure text-primary pl-4'> | ||
<svelte:component this={icon} /> | ||
</div> | ||
{/if} | ||
</div> | ||
{/each} | ||
</dl> | ||
|
||
<style> | ||
.href { | ||
cursor: pointer; | ||
} | ||
</style> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,14 @@ | ||
import { browser } from '$app/environment' | ||
import { writable, type Writable } from 'svelte/store' | ||
|
||
interface LfError { | ||
message: string, | ||
code?: number, | ||
} | ||
export const error: Writable<LfError> = writable({ message: '' }) | ||
|
||
export function throw_error(message: string, code: number = 0) { | ||
throw set({ message, code }) | ||
} | ||
export const error: Writable<Error> = writable(Error()) | ||
|
||
export const dismiss = set | ||
export const dismiss = () => error.set(Error()) | ||
|
||
if (browser) { | ||
// https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onerror#window.addEventListenererror | ||
window.addEventListener('error', (event: ErrorEvent) => set(event.error)) | ||
window.addEventListener('error', (event: ErrorEvent) => error.set(event.error)) | ||
|
||
// https://developer.mozilla.org/en-US/docs/Web/API/PromiseRejectionEvent | ||
window.onunhandledrejection = (event: PromiseRejectionEvent) => set(event.reason) | ||
} | ||
|
||
function set({ message, code = 0 }: LfError) { | ||
error.set({ code, message }) | ||
|
||
return { code, message } | ||
window.onunhandledrejection = (event: PromiseRejectionEvent) => error.set(event.reason) | ||
} |
This file contains 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 file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
<script> | ||
export let danger = false | ||
export {clazz as class} | ||
let clazz = '' | ||
</script> | ||
|
||
<!-- https://daisyui.com/components/button --> | ||
<button on:click class:danger class='btn btn-primary { $$props.class }'> | ||
<button on:click class:btn-error={danger} class='btn btn-primary { clazz }'> | ||
<slot /> | ||
</button> | ||
|
||
<style> | ||
.danger { @apply | ||
btn-error; | ||
} | ||
</style> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
<slot /> | ||
</form> | ||
|
||
<style> | ||
<style lang=postcss> | ||
:global(form > input) { @apply | ||
mb-6; | ||
} | ||
|
This file contains 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 file contains 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 file contains 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 file contains 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
Oops, something went wrong.