-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
281 additions
and
142 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
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { Dialog, DialogBackdrop, DialogPanel } from "@headlessui/react"; | ||
import type { PropsWithChildren, ReactNode } from "react"; | ||
import { Link, useNavigate } from "react-router-dom"; | ||
import Icon from "../Icon"; | ||
import { PromptIcon } from "./prompt-icon"; | ||
|
||
interface Props extends PropsWithChildren { | ||
type?: "success" | "error" | "loading"; | ||
ack?: ReactNode; | ||
} | ||
|
||
export default function PromptV2({ type, children }: Props) { | ||
const navigate = useNavigate(); | ||
return ( | ||
<Dialog | ||
open={true} | ||
onClose={() => | ||
navigate("..", { preventScrollReset: true, replace: true }) | ||
} | ||
className="relative z-50" | ||
> | ||
<DialogBackdrop className="fixed inset-0 bg-black/30 data-[closed]:opacity-0" /> | ||
<DialogPanel className="fixed-center z-10 grid text-navy-d4 bg-white sm:w-full w-[90vw] sm:max-w-lg rounded overflow-hidden"> | ||
<div className="flex justify-end p-4 border-b border-gray-l4"> | ||
<Link | ||
to=".." | ||
preventScrollReset | ||
replace | ||
className="border border-gray-l4 p-2 rounded-md" | ||
> | ||
<Icon type="Close" size={24} /> | ||
</Link> | ||
</div> | ||
|
||
<PromptIcon type={type} classes="mb-6 sm:mb-8 mt-4 sm:mt-12" /> | ||
<div className="px-6 pb-4 text-center text-navy-l1 dark:text-navy-l2"> | ||
{children} | ||
</div> | ||
<div className="p-3 sm:px-8 sm:py-4 empty:h-12 w-full text-center sm:text-right bg-blue-l5 border-t border-gray-l4"> | ||
<Link | ||
to=".." | ||
preventScrollReset | ||
replace | ||
type="button" | ||
className="inline-block btn-blue px-8 py-2 max-sm:w-full" | ||
> | ||
{type === "success" ? "Done" : "Ok"} | ||
</Link> | ||
</div> | ||
</DialogPanel> | ||
</Dialog> | ||
); | ||
} |
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,24 @@ | ||
import LoaderRing from "components/LoaderRing"; | ||
import Icon from "../Icon"; | ||
import type { Props } from "./types"; | ||
|
||
export function PromptIcon({ | ||
type, | ||
classes = "", | ||
}: Pick<Props, "type"> & { classes?: string }) { | ||
const common = `justify-self-center ${classes}`; | ||
switch (type) { | ||
case "success": | ||
return ( | ||
<Icon type="CheckCircle" size={92} className={common + " text-green"} /> | ||
); | ||
case "error": | ||
return ( | ||
<Icon type="Exclamation" size={80} className={common + " text-red"} /> | ||
); | ||
case "loading": | ||
return <LoaderRing thickness={12} classes={common + " h-24"} />; | ||
default: | ||
return null; | ||
} | ||
} |
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,11 +1,16 @@ | ||
import Icon from "components/Icon"; | ||
import { GENERIC_ERROR_MESSAGE } from "constants/common"; | ||
import type { ReactNode } from "react"; | ||
|
||
export default function DefaultFallback() { | ||
interface Props { | ||
acknowledger?: ReactNode; | ||
} | ||
export default function DefaultFallback({ acknowledger }: Props) { | ||
return ( | ||
<div className="grid place-items-center content-center gap-6 p-4"> | ||
<Icon type="Exclamation" className="text-red text-[2em]" /> | ||
<p className="text-center">{GENERIC_ERROR_MESSAGE}</p> | ||
{acknowledger} | ||
</div> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { logger } from "helpers"; | ||
import { useEffect, useRef } from "react"; | ||
import { Link, useRouteError } from "react-router-dom"; | ||
import DefaultFallback from "./DefaultFallback"; | ||
|
||
export function ErrorElement() { | ||
const error = useRouteError(); | ||
|
||
const elementRef = useRef<HTMLAnchorElement>(null); | ||
|
||
//biome-ignore lint: log onmount only | ||
useEffect(() => { | ||
logger.error(error); | ||
}, []); | ||
|
||
useEffect(() => { | ||
if (!elementRef.current) return; | ||
elementRef.current.scrollIntoView({ block: "center" }); | ||
}, []); | ||
|
||
return ( | ||
<DefaultFallback | ||
acknowledger={ | ||
<Link | ||
ref={elementRef} | ||
to="." | ||
className="border border-gray-l4 rounded-lg px-6 py-2" | ||
> | ||
OK | ||
</Link> | ||
} | ||
/> | ||
); | ||
} |
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.