From 4c90689e41d40f2ac99e58256ba8459e0144f057 Mon Sep 17 00:00:00 2001 From: Charles Lirsac Date: Tue, 28 Nov 2023 23:17:17 +0000 Subject: [PATCH] Add basic help modal --- src/components/app.tsx | 21 +++++++++++++++-- src/components/header.tsx | 18 +++++++++++++-- src/components/help.tsx | 48 +++++++++++++++++++++++++++++++++++++++ src/components/modal.tsx | 20 ++++++++++++---- 4 files changed, 98 insertions(+), 9 deletions(-) create mode 100644 src/components/help.tsx diff --git a/src/components/app.tsx b/src/components/app.tsx index 2025e6d..69ced24 100644 --- a/src/components/app.tsx +++ b/src/components/app.tsx @@ -2,15 +2,23 @@ import { Fragment, h } from "preact"; import { useEffect, useMemo, useState } from "preact/hooks"; import { Session } from "../session"; -import { useStoredString, getRandomColour, randomName } from "../utils"; +import { + useStoredString, + getRandomColour, + randomName, + useFlag, +} from "../utils"; import Editor from "./editor"; import Header from "./header"; +import Help from "./help"; import MermaidRenderer from "./mermaid-renderer"; +import Modal from "./modal"; import Resizable from "./resizable"; export default function App({ session }: { session: Session }) { const [contents, setContents] = useState(""); + const helpFlag = useFlag(false); // TODO: Allow changing. const [username] = useStoredString("username", randomName()); @@ -37,7 +45,7 @@ export default function App({ session }: { session: Session }) { return (
-
+
@@ -53,6 +61,15 @@ export default function App({ session }: { session: Session }) {
+ {/* Modals */} + + +
); } diff --git a/src/components/header.tsx b/src/components/header.tsx index 7f8b465..ba5fdae 100644 --- a/src/components/header.tsx +++ b/src/components/header.tsx @@ -4,7 +4,13 @@ import { Session } from "../session"; import ClipboardButton from "./clipboard-button"; -const Header = ({ session }: { session: Session }) => { +const Header = ({ + session, + showHelp, +}: { + session: Session; + showHelp?: () => void; +}) => { return (
diff --git a/src/components/help.tsx b/src/components/help.tsx new file mode 100644 index 0000000..f3299f1 --- /dev/null +++ b/src/components/help.tsx @@ -0,0 +1,48 @@ +import { h, Fragment } from "preact"; + +// TODO: Check about using MDX for this. +const Help = () => ( + +

+ 🚧 This is very much a work in progress. Expect rough edges and paper + cuts. 🚧 +

+

What is this?

+

+ This is a collaborative live editor for{" "} + Mermaid diagrams. If you don't care + about multiplayer, the existing{" "} + live editor is probably a better option + for a single user. +

+

How do I collaborate?

+ +

Security / privacy

+

+ This tool currently relies on a WebSocket sharing server which sees the + document updates. It's not recording anything but you generally shouldn't + use it for anything sensitive. +
+ Work is in progress to support peer to peer through WEB RTC and encrypted + collaboration. +

+
+

+ Find more details on{" "} + GitHub +

+
+); + +export default Help; diff --git a/src/components/modal.tsx b/src/components/modal.tsx index 227457b..6da1778 100644 --- a/src/components/modal.tsx +++ b/src/components/modal.tsx @@ -2,15 +2,23 @@ import { ComponentChildren, h } from "preact"; import { useRef, useState, useEffect } from "preact/hooks"; import * as b from "bootstrap"; +import classNames from "classnames"; interface ModalProps { children: ComponentChildren; visible: boolean; title: ComponentChildren; + scrollable: boolean; onHide?: () => void; } -const Modal = ({ children, visible, title, onHide }: ModalProps) => { +const Modal = ({ + children, + visible, + title, + onHide, + scrollable, +}: ModalProps) => { const ref = useRef(null); const [modal, setModal] = useState(null); @@ -35,12 +43,14 @@ const Modal = ({ children, visible, title, onHide }: ModalProps) => { return (
-
+
-
- {title} -
+
{title}
{onHide && (