Skip to content

Commit

Permalink
⚡️ :: (#28) use gates
Browse files Browse the repository at this point in the history
  • Loading branch information
KJG04 committed Jan 25, 2022
1 parent a708768 commit 3ef59eb
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions functions/src/components/LogicGate/LogicGate.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
import { useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from "react";
import { GateContext } from "../../context/GateContext";
import { color } from "../Minesweeper";
import { ANDGate } from "./Gates";
import * as S from "./styles";
Expand Down Expand Up @@ -26,17 +27,14 @@ const isCollision = (point: Point, dot: Point): boolean => {
};

const LogicGate = () => {
const { nodes, gates } = useContext(GateContext);

useLayoutEffect(() => {
document.querySelector("html")!.style.backgroundColor = color.red;
}, []);

const isMousePress = useRef(false);
const dots = useRef<Point[]>([
[300, 300],
[500, 500],
[600, 450],
[800, 740],
]);
const dots = useRef<Point[]>([]);

const [currentLine, setCurrentLine] = useState<Line | null>(null);
const [lines, setLines] = useState<Line[]>([]);
Expand Down Expand Up @@ -109,6 +107,10 @@ const LogicGate = () => {
<path d={drawLine(value)} fill="none" stroke="#FFFFFF" stroke-width="3" />
))}
</S.PathContainer>

{gates.map((value, index) => {
return <ANDGate {...{ ...value, index }} />;
})}
</S.Container>
</>
);
Expand Down

0 comments on commit 3ef59eb

Please sign in to comment.