From 597c7e4e0ba0cbd8301ed179beb91f0c98307dc9 Mon Sep 17 00:00:00 2001 From: Chris Kruining Date: Tue, 12 Nov 2024 16:09:24 +0100 Subject: [PATCH] more fancy pancy error component --- src/routes/(editor).tsx | 14 +++++++++++--- src/routes/(editor)/edit.tsx | 17 +++++++++++++---- src/routes/editor.module.css | 12 +++++++++++- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/src/routes/(editor).tsx b/src/routes/(editor).tsx index 69d7f98..511f4f5 100644 --- a/src/routes/(editor).tsx +++ b/src/routes/(editor).tsx @@ -64,7 +64,7 @@ export default function Editor(props: ParentProps) {
- }> + }> {props.children} @@ -76,6 +76,14 @@ export default function Editor(props: ParentProps) { } -const ErrorComp: Component<{ error: string }> = (props) => { - return
{props.error}
+const ErrorComp: Component<{ error: Error }> = (props) => { + return
+ {props.error.message} + + { + cause => <>{cause().description} + } + + Return to start +
; }; diff --git a/src/routes/(editor)/edit.tsx b/src/routes/(editor)/edit.tsx index f21e107..3192d40 100644 --- a/src/routes/(editor)/edit.tsx +++ b/src/routes/(editor)/edit.tsx @@ -42,6 +42,19 @@ interface Entries extends Map { + if (!('showDirectoryPicker' in window)) { + throw new Error('Unable to manage files', { + cause: { + description:

+ The browser you are using does not support the File Access API.
+ This API is crutial for this app. +

+ } + }); + } + }); + const open = createCommand('open folder', async () => { const directory = await window.showDirectoryPicker({ mode: 'readwrite' }); @@ -319,10 +332,6 @@ const Content: Component<{ directory: FileSystemDirectoryHandle, api?: Setter>>(new Map); const [api, setApi] = createSignal(); - if (!isServer && !('showDirectoryPicker' in window)) { - throw new Error('Unable to manage files'); - } - createEffect(() => { props.entries?.(entries()); }); diff --git a/src/routes/editor.module.css b/src/routes/editor.module.css index c4d0c22..b6f301a 100644 --- a/src/routes/editor.module.css +++ b/src/routes/editor.module.css @@ -51,6 +51,11 @@ } & > section { + display: grid; + grid: 100% / 100%; + inline-size: 100%; + block-size: 100%; + overflow: clip; view-transition-name: content; } } @@ -59,7 +64,12 @@ display: grid; place-content: center; - background-color: color(from var(--fail) xyz x y z / .3); + background: repeating-linear-gradient(-45deg, + color(from var(--fail) xyz x y z / .05), + color(from var(--fail) xyz x y z / .05) 10px, + color(from var(--fail) xyz x y z / .25) 10px, + color(from var(--fail) xyz x y z / .25) 12px, + color(from var(--fail) xyz x y z / .05) 12px); color: var(--text-2); border: 1px solid var(--fail); border-radius: var(--radii-m);