Skip to content

Commit 6a951ca

Browse files
committed
client: add more formatting icons and improve formatting bar responsiveness
1 parent a52e9a1 commit 6a951ca

File tree

3 files changed

+44
-18
lines changed

3 files changed

+44
-18
lines changed

client/components/edit-document/document.module.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,10 @@
3838
position: absolute;
3939
right: 0;
4040
}
41+
42+
@media (max-width: 768px) {
43+
.actionWrapper .actions {
44+
position: relative;
45+
margin-left: 0 !important;
46+
}
47+
}

client/components/edit-document/formatting-icons/index.tsx

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import Bold from "@geist-ui/icons/bold"
22
import Italic from "@geist-ui/icons/italic"
33
import Link from "@geist-ui/icons/link"
4+
import Code from "@geist-ui/icons/code"
5+
import List from "@geist-ui/icons/list"
6+
47
import ImageIcon from "@geist-ui/icons/image"
5-
import { RefObject, useCallback, useMemo } from "react"
8+
import { RefObject, useMemo } from "react"
69
import styles from "../document.module.css"
7-
import { Button, ButtonGroup } from "@geist-ui/core"
10+
import { Button, ButtonGroup, Tooltip } from "@geist-ui/core"
811
import { TextareaMarkdownRef } from "textarea-markdown-editor"
912

1013
// TODO: clean up
@@ -19,6 +22,9 @@ const FormattingIcons = ({
1922
const handleItalicClick = () => textareaRef?.current?.trigger("italic")
2023
const handleLinkClick = () => textareaRef?.current?.trigger("link")
2124
const handleImageClick = () => textareaRef?.current?.trigger("image")
25+
const handleCodeClick = () => textareaRef?.current?.trigger("code")
26+
const handleListClick = () =>
27+
textareaRef?.current?.trigger("unordered-list")
2228
return [
2329
{
2430
icon: <Bold />,
@@ -30,11 +36,6 @@ const FormattingIcons = ({
3036
name: "italic",
3137
action: handleItalicClick
3238
},
33-
// {
34-
// icon: <Underline />,
35-
// name: 'underline',
36-
// action: handleUnderlineClick
37-
// },
3839
{
3940
icon: <Link />,
4041
name: "hyperlink",
@@ -44,6 +45,16 @@ const FormattingIcons = ({
4445
icon: <ImageIcon />,
4546
name: "image",
4647
action: handleImageClick
48+
},
49+
{
50+
icon: <Code />,
51+
name: "code",
52+
action: handleCodeClick
53+
},
54+
{
55+
icon: <List />,
56+
name: "unordered-list",
57+
action: handleListClick
4758
}
4859
]
4960
}, [textareaRef])
@@ -52,16 +63,20 @@ const FormattingIcons = ({
5263
<div className={styles.actionWrapper}>
5364
<ButtonGroup className={styles.actions}>
5465
{formattingActions.map(({ icon, name, action }) => (
55-
<Button
56-
auto
57-
scale={2 / 3}
58-
px={0.6}
59-
aria-label={name}
66+
<Tooltip
67+
text={name[0].toUpperCase() + name.slice(1).replace("-", " ")}
6068
key={name}
61-
icon={icon}
62-
onMouseDown={(e) => e.preventDefault()}
63-
onClick={action}
64-
/>
69+
>
70+
<Button
71+
auto
72+
scale={2 / 3}
73+
px={0.6}
74+
aria-label={name}
75+
icon={icon}
76+
onMouseDown={(e) => e.preventDefault()}
77+
onClick={action}
78+
/>
79+
</Tooltip>
6580
))}
6681
</ButtonGroup>
6782
</div>

client/components/new-post/drag-and-drop/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Text, useTheme, useToasts } from "@geist-ui/core"
1+
import { Text, useMediaQuery, useTheme, useToasts } from "@geist-ui/core"
22
import { memo } from "react"
33
import { useDropzone } from "react-dropzone"
44
import styles from "./drag-and-drop.module.css"
@@ -14,6 +14,9 @@ import byteToMB from "@lib/byte-to-mb"
1414
function FileDropzone({ setDocs }: { setDocs: (docs: Document[]) => void }) {
1515
const { palette } = useTheme()
1616
const { setToast } = useToasts()
17+
const isMobile = useMediaQuery("xs", {
18+
match: "down"
19+
})
1720
const onDrop = async (acceptedFiles: File[]) => {
1821
const newDocs = await Promise.all(
1922
acceptedFiles.map((file) => {
@@ -84,6 +87,7 @@ function FileDropzone({ setDocs }: { setDocs: (docs: Document[]) => void }) {
8487
</li>
8588
))
8689

90+
const verb = isMobile ? "tap" : "click"
8791
return (
8892
<div className={styles.container}>
8993
<div
@@ -95,7 +99,7 @@ function FileDropzone({ setDocs }: { setDocs: (docs: Document[]) => void }) {
9599
>
96100
<input {...getInputProps()} />
97101
{!isDragActive && (
98-
<Text p>Drag some files here, or click to select files</Text>
102+
<Text p>Drag some files here, or {verb} to select files</Text>
99103
)}
100104
{isDragActive && <Text p>Release to drop the files here</Text>}
101105
</div>

0 commit comments

Comments
 (0)