Skip to content

Commit a8139c5

Browse files
committed
Stack toasts in the canvas's bottom-right corner
They were pinned to the window at a guessed sidebar width, so they landed on the sidebar's edge. They now anchor to the canvas, stack upward from its bottom-right, and rise above the YAML pane when it is open.
1 parent a0a76ce commit a8139c5

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

components/EditorShell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,9 +773,9 @@ export default function EditorShell() {
773773
/>
774774
</div>
775775
)}
776+
<ToastContainer />
776777
</div>
777778
{!showStart && <YamlPanel text={yamlText} problems={yamlProblems} onChange={onYamlChange} />}
778-
<ToastContainer />
779779
</div>
780780
);
781781
}

components/ui/Toast.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import { useEffect, useState } from "react";
44

5+
import { useEditorStore } from "@/lib/store/editorStore";
6+
57
type ToastType = "success" | "error" | "info";
68

79
type Toast = {
@@ -28,8 +30,15 @@ export function showToast(message: string, type: ToastType = "info") {
2830
}, 4000);
2931
}
3032

33+
/**
34+
* Toasts stack up from the canvas's bottom-right corner, clear of the
35+
* toolbar, the zoom controls, and the YAML tab, and above the YAML pane
36+
* when it is open. Mount it inside the canvas container.
37+
*/
3138
export default function ToastContainer() {
3239
const [current, setCurrent] = useState<Toast[]>([]);
40+
const showYaml = useEditorStore((state) => state.showYaml);
41+
const yamlHeight = useEditorStore((state) => state.yamlPanelHeight);
3342

3443
useEffect(() => {
3544
listeners.add(setCurrent);
@@ -39,7 +48,10 @@ export default function ToastContainer() {
3948
}, []);
4049

4150
return (
42-
<div className="pointer-events-none fixed right-76 top-20 z-50 flex flex-col gap-2">
51+
<div
52+
className="pointer-events-none absolute right-4 z-40 flex flex-col-reverse items-end gap-2 transition-[bottom] duration-300"
53+
style={{ bottom: showYaml ? yamlHeight + 16 : 16 }}
54+
>
4355
{current.map((toast) => (
4456
<div
4557
key={toast.id}

0 commit comments

Comments
 (0)