Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"recommendations": [
"esbenp.prettier-vscode",
"styled-components.vscode-styled-components"
],
"unwantedRecommendations": []
}
3 changes: 1 addition & 2 deletions example/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

149 changes: 7 additions & 142 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
"vitest": "^1.4.0"
},
"peerDependencies": {
"react": "^17.0.0 || ^18.0.0",
"react-dom": "^17.0.0 || ^18.0.0"
"react": ">=16.0.0",
"react-dom": ">=16.0.0"
},
"lint-staged": {
"*.{ts,tsx}": [
Expand All @@ -84,8 +84,6 @@
],
"dependencies": {
"fabric": "^5.3.0",
"fabricjs-react": "^1.2.2",
"react-icons": "^5.0.1",
"styled-components": "^6.1.8"
"fabricjs-react": "^1.2.2"
}
}
44 changes: 7 additions & 37 deletions src/components/Board/Board.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React, { useEffect, useState } from "react";
import { fabric } from "fabric";
import { FabricJSCanvas, useFabricJSEditor } from "fabricjs-react";
import tokens from "../../tokens";
import { CanvasObject } from "./types";
import styled from "styled-components";

export type BoardProps = {
primary?: boolean;
Expand Down Expand Up @@ -40,11 +38,6 @@ type CanvasAnnotationState = {
isDragging?: boolean;
};

const StyledCanvas = styled.div`
width: 100%;
height: 100%;
`;

const Board = React.forwardRef<BoardActions, BoardProps>(
(
{
Expand Down Expand Up @@ -177,9 +170,7 @@ const Board = React.forwardRef<BoardActions, BoardProps>(
}

// Background color of canvas
editor.canvas.backgroundColor = primary
? tokens.primary.backgroundColor
: tokens.secondary.backgroundColor;
editor.canvas.backgroundColor = "#ffffff";

// Set FabricJS canvas width and height
editor.canvas.setWidth(parentCanvasElement.clientWidth);
Expand Down Expand Up @@ -397,35 +388,14 @@ const Board = React.forwardRef<BoardActions, BoardProps>(
// // setAction({ primitive: "rectangle", operation: "add" });
// };

// const getVisible = () => {
// console.log(editor?.canvas.getObjects()?.[0].visible);
// };

return (
<StyledCanvas id="react-annotator-canvas" role="board">
<div
id="react-annotator-canvas"
data-testid="react-annotator-canvas"
style={{ width: "100%", height: "100%" }}
>
<FabricJSCanvas className="fabricjs-canvas" onReady={onReady} />
</StyledCanvas>

// <div className="App">
// <button onClick={onAddRectangle}>Add Rectangle</button>
// <button onClick={resetZoom}>Reset Zoom</button>
// <button onClick={addRandom}>Add Random</button>
// <button onClick={draggingState}>
// DraggingState {draggingEnabled ? "ON" : "OFF"}
// </button>
// <button onClick={getActiveObjects}>Active Objects</button>
// <button onClick={getVisible}>Get Visible</button>
// <div
// style={{
// border: `3px solid Green`,
// width: `${WIDTH}px`,
// height: `${HEIGHT}px`,
// }}
// >
// <FabricJSCanvas className="react-annotator-canvas" onReady={onReady} />
// <div>Zoom: {Math.round(currentZoom)}%</div>
// </div>
// </div>
</div>
);
},
);
Expand Down
Loading