From 6a951cad78acdf930e4dd8d108beec3e0c4d548e Mon Sep 17 00:00:00 2001 From: Max Leiter Date: Fri, 22 Apr 2022 15:42:54 -0700 Subject: [PATCH] client: add more formatting icons and improve formatting bar responsiveness --- .../edit-document/document.module.css | 7 +++ .../edit-document/formatting-icons/index.tsx | 47 ++++++++++++------- .../new-post/drag-and-drop/index.tsx | 8 +++- 3 files changed, 44 insertions(+), 18 deletions(-) diff --git a/client/components/edit-document/document.module.css b/client/components/edit-document/document.module.css index 82c46cad..c966020e 100644 --- a/client/components/edit-document/document.module.css +++ b/client/components/edit-document/document.module.css @@ -38,3 +38,10 @@ position: absolute; right: 0; } + +@media (max-width: 768px) { + .actionWrapper .actions { + position: relative; + margin-left: 0 !important; + } +} diff --git a/client/components/edit-document/formatting-icons/index.tsx b/client/components/edit-document/formatting-icons/index.tsx index ca39c04e..b3b0a06d 100644 --- a/client/components/edit-document/formatting-icons/index.tsx +++ b/client/components/edit-document/formatting-icons/index.tsx @@ -1,10 +1,13 @@ import Bold from "@geist-ui/icons/bold" import Italic from "@geist-ui/icons/italic" import Link from "@geist-ui/icons/link" +import Code from "@geist-ui/icons/code" +import List from "@geist-ui/icons/list" + import ImageIcon from "@geist-ui/icons/image" -import { RefObject, useCallback, useMemo } from "react" +import { RefObject, useMemo } from "react" import styles from "../document.module.css" -import { Button, ButtonGroup } from "@geist-ui/core" +import { Button, ButtonGroup, Tooltip } from "@geist-ui/core" import { TextareaMarkdownRef } from "textarea-markdown-editor" // TODO: clean up @@ -19,6 +22,9 @@ const FormattingIcons = ({ const handleItalicClick = () => textareaRef?.current?.trigger("italic") const handleLinkClick = () => textareaRef?.current?.trigger("link") const handleImageClick = () => textareaRef?.current?.trigger("image") + const handleCodeClick = () => textareaRef?.current?.trigger("code") + const handleListClick = () => + textareaRef?.current?.trigger("unordered-list") return [ { icon: , @@ -30,11 +36,6 @@ const FormattingIcons = ({ name: "italic", action: handleItalicClick }, - // { - // icon: , - // name: 'underline', - // action: handleUnderlineClick - // }, { icon: , name: "hyperlink", @@ -44,6 +45,16 @@ const FormattingIcons = ({ icon: , name: "image", action: handleImageClick + }, + { + icon: , + name: "code", + action: handleCodeClick + }, + { + icon: , + name: "unordered-list", + action: handleListClick } ] }, [textareaRef]) @@ -52,16 +63,20 @@ const FormattingIcons = ({
{formattingActions.map(({ icon, name, action }) => ( -
diff --git a/client/components/new-post/drag-and-drop/index.tsx b/client/components/new-post/drag-and-drop/index.tsx index 89cfeb22..26df0c0d 100644 --- a/client/components/new-post/drag-and-drop/index.tsx +++ b/client/components/new-post/drag-and-drop/index.tsx @@ -1,4 +1,4 @@ -import { Text, useTheme, useToasts } from "@geist-ui/core" +import { Text, useMediaQuery, useTheme, useToasts } from "@geist-ui/core" import { memo } from "react" import { useDropzone } from "react-dropzone" import styles from "./drag-and-drop.module.css" @@ -14,6 +14,9 @@ import byteToMB from "@lib/byte-to-mb" function FileDropzone({ setDocs }: { setDocs: (docs: Document[]) => void }) { const { palette } = useTheme() const { setToast } = useToasts() + const isMobile = useMediaQuery("xs", { + match: "down" + }) const onDrop = async (acceptedFiles: File[]) => { const newDocs = await Promise.all( acceptedFiles.map((file) => { @@ -84,6 +87,7 @@ function FileDropzone({ setDocs }: { setDocs: (docs: Document[]) => void }) { )) + const verb = isMobile ? "tap" : "click" return (
void }) { > {!isDragActive && ( - Drag some files here, or click to select files + Drag some files here, or {verb} to select files )} {isDragActive && Release to drop the files here}