mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-16 06:42:14 +00:00
toast alert styling (#433)
- moved toast to inside editor container bounds so it's easier to read - styling and icons fix 
This commit is contained in:
1 parent
0cc5aa6b3c
commit
d47849c324
4 files changed
+62
-27
No files matched your search
@@ -1,14 +1,13 @@
|
||||
import { useSignals } from "@preact/signals-react/runtime";
|
||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||
import {
|
||||
faCircleExclamation,
|
||||
faSquareCheck,
|
||||
faHexagonXmark,
|
||||
faTriangleExclamation,
|
||||
faXmark,
|
||||
} from "@fortawesome/pro-solid-svg-icons";
|
||||
|
||||
import { ToastTypes } from "~/enums";
|
||||
import { toasts, deleteToast } from "~/signals";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
|
||||
export const Toaster = () => {
|
||||
useSignals();
|
||||
@@ -17,46 +16,78 @@ export const Toaster = () => {
|
||||
[ToastTypes.WARNING]: "Warning!",
|
||||
[ToastTypes.SUCCESS]: "Success",
|
||||
};
|
||||
|
||||
const ICONS: Record<string, React.ReactNode> = {
|
||||
error: (
|
||||
<FontAwesomeIcon
|
||||
icon={faCircleExclamation}
|
||||
className="text-brand-primary-700"
|
||||
/>
|
||||
),
|
||||
error: <FontAwesomeIcon icon={faHexagonXmark} className="text-[#FF5F5F]" />,
|
||||
warning: (
|
||||
<FontAwesomeIcon
|
||||
icon={faTriangleExclamation}
|
||||
className="text-keyframe-selected"
|
||||
className="text-[#FFDC5F]"
|
||||
/>
|
||||
),
|
||||
success: (
|
||||
<FontAwesomeIcon icon={faSquareCheck} className="text-success-700" />
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 512 512"
|
||||
className="h-4 w-4"
|
||||
>
|
||||
<path
|
||||
opacity="1"
|
||||
d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c-9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z"
|
||||
fill="#3ACA86"
|
||||
/>
|
||||
<path
|
||||
d="M369 175c-9.4 9.4-9.4 24.6 0 33.9L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c-9.4-9.4 24.6-9.4 33.9 0z"
|
||||
fill="#FFFFFF"
|
||||
/>
|
||||
</svg>
|
||||
),
|
||||
};
|
||||
|
||||
const toastTypeToKey: Record<ToastTypes, string> = {
|
||||
[ToastTypes.ERROR]: "error",
|
||||
[ToastTypes.WARNING]: "warning",
|
||||
[ToastTypes.SUCCESS]: "success",
|
||||
};
|
||||
|
||||
const toastRefs = useRef<(HTMLDivElement | null)[]>([]);
|
||||
const [heights, setHeights] = useState<number[]>([]);
|
||||
|
||||
useEffect(() => {
|
||||
const newHeights = toastRefs.current.map((ref) => ref?.offsetHeight || 0);
|
||||
setHeights(newHeights);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [toasts.value]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{toasts.value.map((toast, index) => (
|
||||
<div
|
||||
key={toast.id}
|
||||
className="rounded=lg fixed z-50 bg-black p-4"
|
||||
style={{ top: 74 + index * 80, right: 6 }}
|
||||
ref={(el) => (toastRefs.current[index] = el)}
|
||||
className="absolute z-50 w-[360px] animate-fadeIn rounded-lg border-2 border-[#5E5E7C] bg-ui-controls p-4 shadow-xl"
|
||||
style={{
|
||||
top: heights
|
||||
.slice(0, index)
|
||||
.reduce((acc, height) => acc + height + 8, 12),
|
||||
right: 12,
|
||||
}}
|
||||
>
|
||||
<div className="mr-3 flex justify-between rounded-lg">
|
||||
<div>
|
||||
<div className="ml-3 flex items-center gap-4">
|
||||
{ICONS[toast.type]}
|
||||
<div className="flex justify-between rounded-lg">
|
||||
<div className="flex flex-col gap-1">
|
||||
<div className="flex items-center gap-2">
|
||||
{ICONS[toastTypeToKey[toast.type]]}
|
||||
<div className="text-base font-bold text-white">
|
||||
{TITLES[toast.type]}
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-left text-sm text-white opacity-50">
|
||||
<div className="text-left text-sm text-white opacity-75">
|
||||
{toast.message}
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
onClick={() => deleteToast(toast.id)}
|
||||
className="text-sm font-bold text-white opacity-50"
|
||||
className="ml-4 text-xl font-bold text-white opacity-50"
|
||||
>
|
||||
<FontAwesomeIcon icon={faXmark} />
|
||||
</button>
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import React, { useEffect } from "react";
|
||||
import { useSignals } from "@preact/signals-react/runtime";
|
||||
|
||||
import { LoadingDots, TopBar } from "~/components";
|
||||
import { LoadingDots, Toaster, TopBar } from "~/components";
|
||||
import { SidePanel } from "~/pages/PageEnigma/comps/SidePanel";
|
||||
|
||||
import { Timeline } from "./comps/Timeline";
|
||||
import { Controls3D } from "./comps/Controls3D";
|
||||
import { ControlsTopButtons } from "./comps/ControlsTopButtons";
|
||||
@@ -11,9 +9,7 @@ import { ControlsVideo } from "./comps/ControlsVideo";
|
||||
import { ControlPanelSceneObject } from "./comps/ControlPanelSceneObject";
|
||||
import { PreviewEngineCamera } from "./comps/PreviewEngineCamera";
|
||||
import { PreviewFrameImage } from "./comps/PreviewFrameImage";
|
||||
|
||||
import { pageHeight, pageWidth } from "~/signals";
|
||||
|
||||
import {
|
||||
timelineHeight,
|
||||
sidePanelWidth,
|
||||
@@ -22,7 +18,6 @@ import {
|
||||
dndTimelineHeight,
|
||||
editorLoader,
|
||||
} from "~/pages/PageEnigma/signals";
|
||||
|
||||
import { EditorCanvas } from "./comps/EngineCanvases";
|
||||
import { SceneContainer } from "./comps/SceneContainer";
|
||||
|
||||
@@ -71,6 +66,7 @@ export const PageEditor = () => {
|
||||
}}
|
||||
>
|
||||
<div className="relative w-full overflow-hidden bg-transparent">
|
||||
<Toaster />
|
||||
<SceneContainer>
|
||||
<EditorCanvas />
|
||||
<PreviewFrameImage />
|
||||
|
||||
+1
-2
@@ -29,7 +29,7 @@ import {
|
||||
persistLogin,
|
||||
} from "~/signals";
|
||||
|
||||
import { LoadingDotsBricks, Toaster } from "~/components";
|
||||
import { LoadingDotsBricks } from "~/components";
|
||||
|
||||
config.autoAddCss = false; /* eslint-disable import/first */
|
||||
|
||||
@@ -120,7 +120,6 @@ export default function App() {
|
||||
</head>
|
||||
<body className="overflow-hidden bg-ui-background">
|
||||
<CompleteTakeoverLoadingScreen isShowing={showLoader} />
|
||||
<Toaster />
|
||||
<div className="topbar-spacer" />
|
||||
<Outlet />
|
||||
<ScrollRestoration />
|
||||
|
||||
@@ -12,6 +12,15 @@ export default {
|
||||
fontFamily: {
|
||||
"custom-font": ["Fira Sans", "sans-serif"],
|
||||
},
|
||||
keyframes: {
|
||||
fadeIn: {
|
||||
"0%": { opacity: "0" },
|
||||
"100%": { opacity: "1" },
|
||||
},
|
||||
},
|
||||
animation: {
|
||||
fadeIn: "fadeIn 0.2s ease-in-out",
|
||||
},
|
||||
},
|
||||
colors: {
|
||||
transparent: "transparent",
|
||||
|
||||
Reference in new issue
Block a user