Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

Placeholders and more css tidying

Matt Robertscc7cabba354b
diff --git a/package-lock.json b/package-lock.json
index 7f60c96f3..495c1b639 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -11,6 +11,7 @@
"@lingui/format-json": "^5.1.2",
"@lingui/react": "^5.1.2",
"@tiptap/extension-mention": "^2.11.5",
+ "@tiptap/extension-placeholder": "^2.11.5",
"@tiptap/pm": "^2.11.5",
"@tiptap/react": "^2.11.5",
"@tiptap/starter-kit": "^2.11.5",
@@ -4728,6 +4729,20 @@
"@tiptap/core": "^2.7.0"
}
},
+ "node_modules/@tiptap/extension-placeholder": {
+ "version": "2.11.5",
+ "resolved": "https://registry.npmjs.org/@tiptap/extension-placeholder/-/extension-placeholder-2.11.5.tgz",
+ "integrity": "sha512-Pr+0Ju/l2ZvXMd9VQxtaoSZbs0BBp1jbBDqwms88ctpyvQFRfLSfSkqudQcSHyw2ROOz2E31p/7I7fpI8Y0CLA==",
+ "license": "MIT",
+ "funding": {
+ "type": "github",
+ "url": "https://github.com/sponsors/ueberdosis"
+ },
+ "peerDependencies": {
+ "@tiptap/core": "^2.7.0",
+ "@tiptap/pm": "^2.7.0"
+ }
+ },
"node_modules/@tiptap/extension-strike": {
"version": "2.11.5",
"resolved": "https://registry.npmjs.org/@tiptap/extension-strike/-/extension-strike-2.11.5.tgz",
diff --git a/package.json b/package.json
index 8b139a33b..e8bf2cd89 100644
--- a/package.json
+++ b/package.json
@@ -7,6 +7,7 @@
"@lingui/format-json": "^5.1.2",
"@lingui/react": "^5.1.2",
"@tiptap/extension-mention": "^2.11.5",
+ "@tiptap/extension-placeholder": "^2.11.5",
"@tiptap/pm": "^2.11.5",
"@tiptap/react": "^2.11.5",
"@tiptap/starter-kit": "^2.11.5",
diff --git a/public/components/common/form/CommentEditor.scss b/public/components/common/form/CommentEditor.scss
index 8ae4dc9d4..3175c1ecc 100644
--- a/public/components/common/form/CommentEditor.scss
+++ b/public/components/common/form/CommentEditor.scss
@@ -44,13 +44,6 @@
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
}
-/* Basic editor styling */
-.fider-tiptap-editor {
- border: 1px solid #e5e7eb;
- border-radius: 4px;
- overflow: hidden;
-}
-
.fider-tiptap-editor .ProseMirror {
padding: 12px;
min-height: 120px;
@@ -72,30 +65,10 @@
color: #3b82f6;
text-decoration: underline;
}
-
-/* Menu styling */
-.fider-floating-menu {
- background-color: white;
- border: 1px solid #e5e7eb;
- border-radius: 4px;
- padding: 6px 10px;
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
-}
-
-.fider-bubble-menu {
- background-color: white;
- border: 1px solid #e5e7eb;
- border-radius: 4px;
- padding: 6px 10px;
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
-}
-
// THese are the AI generated toolbar styles, I'll need to check these
-
.c-editor-toolbar {
- margin-bottom: 0.5rem;
- border-bottom: 1px solid #e5e7eb;
- padding-bottom: 0.5rem;
+ border-bottom: 1px solid get("colors.gray.300");
+ padding: spacing(1);
}
.c-editor-button-group {
@@ -107,27 +80,27 @@
display: flex;
align-items: center;
justify-content: center;
- padding: 6px;
- border-radius: 4px;
+ padding: spacing(1.5);
+ border-radius: get("border.radius.small");
background: transparent;
border: none;
+ color: get("colors.gray.700");
cursor: pointer;
- color: #6b7280;
transition: all 0.2s ease;
&:hover {
- background-color: #f3f4f6;
- color: #111827;
+ background-color: get("colors.gray.100");
+ color: get("colors.gray.900");
}
&.is-active {
- background-color: #e5e7eb;
- color: #111827;
+ background-color: get("colors.gray.300");
+ color: get("colors.gray.900");
}
svg {
- width: 18px;
- height: 18px;
+ width: spacing(4.5);
+ height: spacing(4.5);
}
}
@@ -165,3 +138,12 @@
}
}
}
+
+// Placeholder
+.tiptap p.is-editor-empty:first-child::before {
+ color: get("colors.gray.400");
+ content: attr(data-placeholder);
+ float: left;
+ height: 0;
+ pointer-events: none;
+}
diff --git a/public/components/common/form/CommentEditor2.tsx b/public/components/common/form/CommentEditor2.tsx
index 9c8c6ac63..96225c761 100644
--- a/public/components/common/form/CommentEditor2.tsx
+++ b/public/components/common/form/CommentEditor2.tsx
@@ -4,6 +4,7 @@ import StarterKit from "@tiptap/starter-kit"
import React from "react"
import { EditorContent, useEditor } from "@tiptap/react"
import { Markdown } from "tiptap-markdown"
+import Placeholder from "@tiptap/extension-placeholder"
// import Mention from "@tiptap/extension-mention"
import "./CommentEditor.scss"
@@ -21,24 +22,6 @@ import { CustomMention } from "./CustomMention"
// import CustomMarkdown from "./MentionMarkdown"
// define your extension array
-const extensions = [
- StarterKit,
- Markdown.configure({
- html: true,
- }),
- CustomMention.configure({
- HTMLAttributes: {
- class: "mention",
- },
- suggestion,
- }),
- // CustomMarkdown,
- // Mention.configure({
- // HTMLAttributes: {
- // class: "mention",
- // },
- // suggestion,
-]
const MenuBar = ({ editor }: { editor: Editor | null }) => {
if (!editor) {
@@ -105,12 +88,40 @@ const Tiptap: React.FunctionComponent<CommentEditorProps2> = (props) => {
console.log(markdown)
props.onChange && props.onChange(markdown)
}
- const initialValue = props.initialValue ?? "Hello"
+ const initialValue = props.initialValue ?? ""
+ console.log(initialValue)
+
+ const extensions = [
+ StarterKit,
+ Markdown.configure({
+ html: true,
+ }),
+ CustomMention.configure({
+ HTMLAttributes: {
+ class: "mention",
+ },
+ suggestion,
+ }),
+ Placeholder.configure({
+ placeholder: props.placeholder ?? "Write your comment here...",
+ }),
+ // CustomMarkdown,
+ // Mention.configure({
+ // HTMLAttributes: {
+ // class: "mention",
+ // },
+ // suggestion,
+ ]
const editor = useEditor({
extensions,
- content: initialValue,
+ // content: initialValue,
onUpdate: updated,
+ editorProps: {
+ attributes: {
+ class: "no-focus",
+ },
+ },
})
return (
diff --git a/public/components/common/form/MultiImageUploader.scss b/public/components/common/form/MultiImageUploader.scss
index f75c14b75..ca3ac98da 100644
--- a/public/components/common/form/MultiImageUploader.scss
+++ b/public/components/common/form/MultiImageUploader.scss
@@ -1,4 +1,7 @@
+@import "~@fider/assets/styles/variables.scss";
+
.c-multi-image-uploader {
+ padding-top: spacing(2);
.c-multi-image-uploader-instances {
display: flex;
flex-wrap: wrap;
diff --git a/public/pages/ShowPost/components/CommentInput.tsx b/public/pages/ShowPost/components/CommentInput.tsx
index 897cfcc6f..6c302adc9 100644
--- a/public/pages/ShowPost/components/CommentInput.tsx
+++ b/public/pages/ShowPost/components/CommentInput.tsx
@@ -6,7 +6,7 @@ import { SignInModal } from "@fider/components"
import { cache, actions, Failure, Fider } from "@fider/services"
import { HStack } from "@fider/components/layout"
-// import { i18n } from "@lingui/core"
+import { i18n } from "@lingui/core"
import { Trans } from "@lingui/react/macro"
// import { CommentEditor } from "@fider/components"
@@ -74,7 +74,7 @@ export const CommentInput = (props: CommentInputProps) => {
return (
<>
<SignInModal isOpen={isSignInModalOpen} onClose={hideModal} />
- <HStack spacing={2} className="c-comment-input">
+ <HStack spacing={2} className="c-comment-input" align="start">
{Fider.session.isAuthenticated && <Avatar user={Fider.session.user} />}
<div className="flex-grow bg-gray-50 rounded-md p-2">
<Form error={error}>
@@ -89,7 +89,11 @@ export const CommentInput = (props: CommentInputProps) => {
onFocus={editorFocused}
placeholder={i18n._("showpost.commentinput.placeholder", { message: "Leave a comment" })}
/> */}
- <MemoizedTiptap onChange={commentChanged2} initialValue={getContentFromCache()} />
+ <MemoizedTiptap
+ onChange={commentChanged2}
+ initialValue={getContentFromCache()}
+ placeholder={i18n._("showpost.commentinput.placeholder", { message: "Leave a comment" })}
+ />
{hasContent && (
<>