diff --git a/src/components/Annotator/Annotator.tsx b/src/components/Annotator/Annotator.tsx index 678d48e..b5567d3 100644 --- a/src/components/Annotator/Annotator.tsx +++ b/src/components/Annotator/Annotator.tsx @@ -1,23 +1,183 @@ -import React from "react"; +import React, { useEffect, useRef } from "react"; import styled from "styled-components"; +import { Header } from "../Header"; +import { Toolbar } from "../Toolbar"; +import { Menu } from "../Menu"; +import { FabricJSCanvas, useFabricJSEditor } from "fabricjs-react"; export type AnnotatorProps = { id?: string; primary?: boolean; }; -const StyledDiv = styled.div``; +const Container = styled.div` + display: flex; + flex-direction: column; + height: 100%; + width: 100%; + border: 2px solid black; + border-radius: 2px; + padding: 5px; +`; + +const TopBar = styled.div` + height: "auto"; + display: flex; + align-items: center; + justify-content: center; + border-color: black; +`; + +const InnerWrapper = styled.div` + flex: 1; + display: flex; + justify-content: space-between; +`; + +const LeftBar = styled.div` + background-color: #444; + width: auto; + overflow: hidden; +`; + +const RightBar = styled.div` + width: auto; + min-width: 250px; +`; + +const InnerContent = styled.div` + flex: 1; + border: 1px solid #cbcbcb; + margin: 15px; +`; + +const Annotator: React.FC = ({ id, primary }) => { + const ref = useRef(null); + const { editor, onReady } = useFabricJSEditor(); + + useEffect(() => { + if (!editor || !ref.current) { + return; + } + console.log("width", ref.current ? ref.current.offsetWidth : 0); + console.log("height", ref.current ? ref.current.offsetHeight : 0); + + editor.canvas.setWidth(ref.current.offsetWidth); + editor.canvas.setHeight(ref.current.offsetHeight); + }, [ref, editor]); -const Annotator: React.FC = ({ id, ...props }) => { return ( - -
Header
-
-
Toolbar
-
CanvasContainer
-
Stack Menu
-
-
+ + +
console.log(e) }} + annotation={{ value: true, action: (e) => console.log(e) }} + /> + + + + console.log("Move"), + }, + { + icon: "pointer", + text: "Pointer", + selected: true, + onClick: () => console.log("Pointer"), + }, + { + icon: "rectangle", + text: "Annotate", + onClick: () => console.log("Annotate"), + }, + ]} + /> + + + + + + +

It is a circle

+
    +
  • Circle 1
  • +
  • Circle 2
  • +
  • Circle 3
  • +
+ + + ), + disabled: false, + }, + { + icon: "tags", + title: "Tags", + content: ( +
+

It is a tag

+
    +
  • Tag 1
  • +
  • Tag 2
  • +
  • Tag 3
  • +
+ +
+ ), + disabled: false, + }, + { + icon: "annotation", + title: "Annotation", + content: ( +
+

It is a annotation

+
    +
  • Annotation 1
  • +
  • Annotation 2
  • +
  • Annotation 3
  • +
+ +
+ ), + disabled: true, + }, + { + icon: "coffee", + title: "Coffee", + content: ( +
+

It is a coffee

+
    +
  • Coffee 1
  • +
  • Coffee 2
  • +
  • Coffee 3
  • +
+ +
+ ), + disabled: false, + }, + ]} + /> + + + ); }; diff --git a/src/components/Annotator/__docs__/Example.tsx b/src/components/Annotator/__docs__/Example.tsx index c968d85..1eb4abc 100644 --- a/src/components/Annotator/__docs__/Example.tsx +++ b/src/components/Annotator/__docs__/Example.tsx @@ -8,8 +8,8 @@ const Example: FC = ({ id, primary = true }) => { display: "flex", justifyContent: "center", alignItems: "center", - height: "100%", - width: "100%", + width: "1000px", + height: "550px", }} > diff --git a/src/components/Header/Header.tsx b/src/components/Header/Header.tsx index d9dff2d..8a6e8e1 100644 --- a/src/components/Header/Header.tsx +++ b/src/components/Header/Header.tsx @@ -46,7 +46,7 @@ const ZoomValue = styled.span` display: flex; align-items: center; justify-content: center; - font-family: "Roboto"; + font-family: Roboto; font-style: normal; font-weight: 500; min-width: 50px; @@ -65,7 +65,7 @@ const ImageInfo = styled.span` display: flex; justify-content: center; align-items: center; - font-family: "Roboto"; + font-family: Roboto; font-style: normal; font-weight: 500; color: ${(props) => @@ -73,7 +73,7 @@ const ImageInfo = styled.span` `; const Header: React.FC = ({ - primary, + primary = true, size = "medium", imageInfo, zoom, diff --git a/src/components/Menu/Menu.tsx b/src/components/Menu/Menu.tsx index c9bdba8..bcc69f4 100644 --- a/src/components/Menu/Menu.tsx +++ b/src/components/Menu/Menu.tsx @@ -19,13 +19,15 @@ export type MenuProps = { // Styled components const MenuContainer = styled.div>` width: 100%; - font-family: "Roboto"; + height: 100%; + font-family: Roboto; font-style: normal; visibility: ${(props) => (props.visible ? "visible" : "hidden")}; + font-size: 14px; background-color: ${(props) => props.primary ? tokens.primary.backgroundColor - : tokens.secondary.semiBackgroundColor}; + : tokens.secondary.backgroundColor}; color: ${(props) => props.primary ? tokens.primary.color : tokens.secondary.color}; `; @@ -35,7 +37,7 @@ const MenuItem = styled.div>` ${(props) => props.primary ? tokens.primary.lightColor : tokens.secondary.lightColor}; border-radius: 5px; - margin: 5px; + margin: 0 5px 5px 5px; background-color: ${(props) => props.primary ? undefined : tokens.secondary.activeColor}; `; diff --git a/src/components/Toolbar/Toolbar.tsx b/src/components/Toolbar/Toolbar.tsx index cff88b8..34846e1 100644 --- a/src/components/Toolbar/Toolbar.tsx +++ b/src/components/Toolbar/Toolbar.tsx @@ -21,9 +21,11 @@ const StyledDiv = styled.div>` props.primary ? tokens.primary.backgroundColor : tokens.secondary.backgroundColor}; - padding: 5px; - height: max-content; - gap: 10px; + height: 100%; +`; + +const ItemDiv = styled.div` + margin: 5px; `; const Toolbar: React.FC = ({ @@ -39,18 +41,19 @@ const Toolbar: React.FC = ({ return ( {items.map(({ icon, text, onClick }, index) => ( - { - setSelectedItem(index); - onClick?.(event); - }} - /> + + { + setSelectedItem(index); + onClick?.(event); + }} + /> + ))} ); diff --git a/src/components/Toolbar/__docs__/Example.tsx b/src/components/Toolbar/__docs__/Example.tsx index aa13e34..ae05640 100644 --- a/src/components/Toolbar/__docs__/Example.tsx +++ b/src/components/Toolbar/__docs__/Example.tsx @@ -14,7 +14,7 @@ const Example: FC = ({ display: "flex", justifyContent: "center", alignItems: "center", - height: "100%", + height: "500px", }} > diff --git a/src/components/ToolbarItem/ToolbarItem.tsx b/src/components/ToolbarItem/ToolbarItem.tsx index 5c2f339..baf5fcb 100644 --- a/src/components/ToolbarItem/ToolbarItem.tsx +++ b/src/components/ToolbarItem/ToolbarItem.tsx @@ -20,7 +20,7 @@ const StyledDiv = styled.div>` align-items: center; justify-content: center; border: 0; - font-family: "Roboto"; + font-family: Roboto; font-style: normal; font-size: ${(props) => props.size === "small"