move error component to standalone
This commit is contained in:
parent
2b4aac7189
commit
5731ba62d0
6 changed files with 40 additions and 34 deletions
16
src/components/error/error.module.css
Normal file
16
src/components/error/error.module.css
Normal file
|
@ -0,0 +1,16 @@
|
|||
.error {
|
||||
display: grid;
|
||||
place-content: center;
|
||||
|
||||
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);
|
||||
|
||||
margin: var(--padding-l);
|
||||
}
|
16
src/components/error/error.tsx
Normal file
16
src/components/error/error.tsx
Normal file
|
@ -0,0 +1,16 @@
|
|||
import { Component, Show } from "solid-js";
|
||||
import css from './error.module.css';
|
||||
|
||||
export const ErrorComp: Component<{ error: Error }> = (props) => {
|
||||
return <div class={css.error}>
|
||||
<b>{props.error.message}</b>
|
||||
|
||||
<Show when={props.error.cause}>{
|
||||
cause => <>{cause().description}</>
|
||||
}</Show>
|
||||
|
||||
{props.error.stack}
|
||||
|
||||
<a href="/">Return to start</a>
|
||||
</div>;
|
||||
};
|
1
src/components/error/index.tsx
Normal file
1
src/components/error/index.tsx
Normal file
|
@ -0,0 +1 @@
|
|||
export { ErrorComp } from './error';
|
|
@ -9,8 +9,9 @@ import { HttpHeader } from "@solidjs/start";
|
|||
import { FaSolidPalette } from "solid-icons/fa";
|
||||
import { LocalePicker } from "~/features/i18n";
|
||||
import { ColorScheme, ColorSchemePicker, getState, useTheme } from "~/features/theme";
|
||||
import css from "./editor.module.css";
|
||||
import { Dropdown } from "~/components/dropdown";
|
||||
import { ErrorComp } from "~/components/error";
|
||||
import css from "./editor.module.css";
|
||||
|
||||
const event = getRequestEvent();
|
||||
|
||||
|
@ -99,19 +100,5 @@ export default function Editor(props: ParentProps) {
|
|||
</MenuProvider>
|
||||
}
|
||||
|
||||
const ErrorComp: Component<{ error: Error }> = (props) => {
|
||||
return <div class={css.error}>
|
||||
<b>{props.error.message}</b>
|
||||
|
||||
<Show when={props.error.cause}>{
|
||||
cause => <>{cause().description}</>
|
||||
}</Show>
|
||||
|
||||
{props.error.stack}
|
||||
|
||||
<a href="/">Return to start</a>
|
||||
</div>;
|
||||
};
|
||||
|
||||
let keyCounter = 0;
|
||||
const createUniqueId = () => `key-${keyCounter++}`;
|
|
@ -1,8 +1,9 @@
|
|||
|
||||
import { ParentProps } from "solid-js";
|
||||
import { ErrorBoundary, ParentProps } from "solid-js";
|
||||
import { Menu } from "~/features/menu";
|
||||
import { createCommand } from "~/features/command";
|
||||
import { useNavigate } from "@solidjs/router";
|
||||
import { ErrorComp } from "~/components/error";
|
||||
|
||||
export default function Experimental(props: ParentProps) {
|
||||
const navigate = useNavigate();
|
||||
|
@ -19,6 +20,8 @@ export default function Experimental(props: ParentProps) {
|
|||
<Menu.Item command={goTo.withLabel('formatter').with('formatter')} />
|
||||
</Menu.Root>
|
||||
|
||||
{props.children}
|
||||
<ErrorBoundary fallback={e => <ErrorComp error={e} />}>
|
||||
{props.children}
|
||||
</ErrorBoundary>
|
||||
</>;
|
||||
}
|
|
@ -108,23 +108,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
.error {
|
||||
display: grid;
|
||||
place-content: center;
|
||||
|
||||
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);
|
||||
|
||||
margin: var(--padding-l);
|
||||
}
|
||||
|
||||
@keyframes slide-left {
|
||||
from {
|
||||
translate: 0% 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue