From 4594823cd498f15471083beb87f81184c513ad8d Mon Sep 17 00:00:00 2001 From: Pouria Delfanazari Date: Thu, 3 Oct 2024 18:28:21 -0700 Subject: [PATCH] Expand composer editor space - Pin bottom editor bar to bottom of the page - Move upload preview to under text editor - Hide drop zone after adding image --- .../inputs/editor/BottomEditorBar.tsx | 5 +- src/components/inputs/editor/Editor.tsx | 107 ++++++++++-------- src/components/inputs/editor/TextEdit.tsx | 2 +- src/components/inputs/editor/TopEditorBar.tsx | 2 +- .../inputs/editor/UploadPreview.tsx | 4 +- src/lib/hooks/bsky/actor/useSearchUsers.tsx | 2 +- 6 files changed, 67 insertions(+), 55 deletions(-) diff --git a/src/components/inputs/editor/BottomEditorBar.tsx b/src/components/inputs/editor/BottomEditorBar.tsx index aaecc17c..5ed82a66 100644 --- a/src/components/inputs/editor/BottomEditorBar.tsx +++ b/src/components/inputs/editor/BottomEditorBar.tsx @@ -7,7 +7,6 @@ import LanguagePicker from "./LanguagePicker"; import { useState } from "react"; import { useDropzone } from "react-dropzone"; import { BiUpload } from "react-icons/bi"; -import UploadPreview from "./UploadPreview"; import { RichText } from "@atproto/api"; import { jsonToText } from "@/lib/utils/text"; import ThreadGatePicker from "./ThreadGatePicker"; @@ -64,6 +63,7 @@ export default function BottomEditorBar(props: Props) { ), ]; onUpdateImages(updatedImages); + setShowDropzone(false); }, }); @@ -93,9 +93,6 @@ export default function BottomEditorBar(props: Props) { - {images && images.length > 0 && ( - - )} {showDropzone && (
void; @@ -88,7 +89,7 @@ export default function Editor(props: Props) { autofocus: true, editorProps: { attributes: { - class: "focus:outline-none h-48 overflow-y-auto text-lg text-skin-base", + class: "focus:outline-none overflow-y-auto text-lg text-skin-base", }, }, onUpdate: ({ editor }) => { @@ -131,7 +132,7 @@ export default function Editor(props: Props) { return (
-
+
setLabel("")} numberOfImages={images?.length ?? 0} /> - {replyTo && } - -
- {quote && } - {embedSuggestions.size > 0 && ( -
- {Array.from(embedSuggestions).map((link) => ( - { - setLinkEmbed(link); - setEmbedSuggestions(new Set("")); - }} +
+ {replyTo && } + +
0) || embedSuggestions.size > 0 ? "mb-3" : ""}`} + > + {quote && } + {embedSuggestions.size > 0 && ( +
+ {Array.from(embedSuggestions).map((link) => ( + { + setLinkEmbed(link); + setEmbedSuggestions(new Set("")); + }} + /> + ))} +
+ )} + {linkEmbed !== "" && ( + { + setLinkEmbed(""); + setLinkCard(null); + }} + onAddLinkCard={setLinkCard} + /> + )} + {images && images.length > 0 && ( +
+ - ))} -
- )} - {linkEmbed !== "" && ( - { - setLinkEmbed(""); - setLinkCard(null); - }} - onAddLinkCard={setLinkCard} - /> - )} -
- +
+ )} +
+
+
+ +
); diff --git a/src/components/inputs/editor/TextEdit.tsx b/src/components/inputs/editor/TextEdit.tsx index 6a7cb346..734171d8 100644 --- a/src/components/inputs/editor/TextEdit.tsx +++ b/src/components/inputs/editor/TextEdit.tsx @@ -14,7 +14,7 @@ export default function TextEdit(props: Props) { const { editor, author, isReply } = props; return ( -
+
)} {showCancelModal && ( -
+

Do you want to discard this draft?

diff --git a/src/components/inputs/editor/UploadPreview.tsx b/src/components/inputs/editor/UploadPreview.tsx index 7e4a26f8..125d529a 100644 --- a/src/components/inputs/editor/UploadPreview.tsx +++ b/src/components/inputs/editor/UploadPreview.tsx @@ -54,14 +54,14 @@ export default function UploadPreview(props: Props) { {selectedImage && ( -
+
Uploaded image
diff --git a/src/lib/hooks/bsky/actor/useSearchUsers.tsx b/src/lib/hooks/bsky/actor/useSearchUsers.tsx index 3d621580..ac1bf40f 100644 --- a/src/lib/hooks/bsky/actor/useSearchUsers.tsx +++ b/src/lib/hooks/bsky/actor/useSearchUsers.tsx @@ -20,7 +20,7 @@ export default function useSearchUsers(props: Props) { const data = await queryClient.fetchQuery({ staleTime: 300 * 1000, // 5 minutes queryKey: ["followers"], - queryFn: () => getFollows({ handle: authorHandle, agent, limit: 8 }), + queryFn: () => getFollows({ handle: authorHandle, agent, limit: 5 }), }); return data.data.follows; } catch (error) {