From 2995c8ec842d54f74fe8615faa1b084fc7c3b712 Mon Sep 17 00:00:00 2001 From: swve Date: Sat, 3 Dec 2022 17:51:36 +0100 Subject: [PATCH] feat: add animations and avatar to editor --- front/components/Editor/Editor.tsx | 109 +++++++++++++----- .../Editor/Toolbar/ToolbarButtons.tsx | 14 +-- 2 files changed, 87 insertions(+), 36 deletions(-) diff --git a/front/components/Editor/Editor.tsx b/front/components/Editor/Editor.tsx index f849904d..12138f7d 100644 --- a/front/components/Editor/Editor.tsx +++ b/front/components/Editor/Editor.tsx @@ -6,10 +6,12 @@ import CollaborationCursor from "@tiptap/extension-collaboration-cursor"; import { AuthContext } from "../Security/AuthProvider"; import learnhouseIcon from "public/learnhouse_icon.png"; import { ToolbarButtons } from "./Toolbar/ToolbarButtons"; +import { motion, AnimatePresence } from "framer-motion"; import Image from "next/image"; import styled from "styled-components"; import { getBackendUrl } from "../../services/config"; -import { RocketIcon, SlashIcon, TriangleLeftIcon, TriangleRightIcon } from "@radix-ui/react-icons"; +import { GlobeIcon, SlashIcon } from "@radix-ui/react-icons"; +import Avvvatars from "avvvatars-react"; interface Editor { content: string; @@ -50,28 +52,58 @@ function Editor(props: Editor) { return (
- - - - - - - {" "} - {props.course.course.name} {props.element.name}{" "} - - props.setContent(editor.getJSON())}> - - - - - - - - - + + + + + + + + {" "} + {props.course.course.name} {props.element.name}{" "} + + props.setContent(editor.getJSON())}> + + + + + + + + + + + + + + + +
); } @@ -82,6 +114,12 @@ const EditorTop = styled.div` margin: 40px; margin-bottom: 20px; padding: 10px; + display: flex; + justify-content: space-between; + box-shadow: 0px 4px 16px rgba(0, 0, 0, 0.03); + //position: fixed; + z-index: 3; + width: -webkit-fill-available; `; // Inside EditorTop @@ -92,6 +130,8 @@ const EditorDocSection = styled.div` const EditorUsersSection = styled.div` display: flex; flex-direction: column; + justify-content: center; + align-items: center; `; // Inside EditorDocSection @@ -103,7 +143,12 @@ const EditorInfoWrapper = styled.div` const EditorButtonsWrapper = styled.div``; // Inside EditorUsersSection -const EditorUserProfileWrapper = styled.div``; +const EditorUserProfileWrapper = styled.div` + padding-right: 8px; + svg { + border-radius: 7px; + } +`; // Inside EditorInfoWrapper //..todo @@ -117,11 +162,13 @@ const EditorInfoDocName = styled.div` align-items: center; display: flex; margin-left: 10px; + color: #494949; svg { margin-left: 4px; margin-right: 4px; - color: #909090; + padding: 3px; + color: #353535; } `; @@ -161,20 +208,24 @@ const EditorInfoThumbnail = styled.img` const EditorContentWrapper = styled.div` margin: 40px; + margin-top: 20px; background-color: white; + border-radius: 10px; + box-shadow: 0px 4px 16px rgba(0, 0, 0, 0.03); // disable chrome outline - .ProseMirror { - padding: 10px; + padding-left: 20px; + padding-right: 20px; + padding-bottom: 6px; + padding-top: 1px; &:focus { - outline: none !important; - outline-style: none !important; - box-shadow: none !important; + outline: none !important; + outline-style: none !important; + box-shadow: none !important; + } } - } - `; export default Editor; diff --git a/front/components/Editor/Toolbar/ToolbarButtons.tsx b/front/components/Editor/Toolbar/ToolbarButtons.tsx index 4d057617..3e682fbc 100644 --- a/front/components/Editor/Toolbar/ToolbarButtons.tsx +++ b/front/components/Editor/Toolbar/ToolbarButtons.tsx @@ -8,6 +8,12 @@ export const ToolbarButtons = ({ editor }: any) => { return ( + editor.chain().focus().undo().run()}> + + + editor.chain().focus().redo().run()}> + + editor.chain().focus().toggleBold().run()} className={editor.isActive("bold") ? "is-active" : ""}> @@ -17,13 +23,6 @@ export const ToolbarButtons = ({ editor }: any) => { editor.chain().focus().toggleStrike().run()} className={editor.isActive("strike") ? "is-active" : ""}> - - editor.chain().focus().undo().run()}> - - - editor.chain().focus().redo().run()}> - - editor.chain().focus().toggleHeading({ level: parseInt(e.target.value) }).run() }> @@ -52,6 +51,7 @@ const ToolBtn = styled.div` padding: 5px; font-size: 5px; margin-right: 5px; + transition: all 0.2s ease-in-out; &.is-active { background: rgba(176, 176, 176, 0.5);