diff --git a/.vscode/settings.json b/.vscode/settings.json index 52c3366..e2568a2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,4 @@ { - "jest.jestCommandLine": "node_modules/.bin/react-scripts test --run-in-band --no-cache --watchAll=false" + "jest.jestCommandLine": "node_modules/.bin/react-scripts test --run-in-band --no-cache --watchAll=false", + "typescript.tsdk": "node_modules/typescript/lib" } \ No newline at end of file diff --git a/package.json b/package.json index df8943c..ca44273 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "@bedrock-layout/split": "^2.3.5", "@bedrock-layout/stack": "^2.3.4", "@bedrock-layout/use-forwarded-ref": "^1.1.11", + "@react-spring/web": "^9.4.1", "@reduxjs/toolkit": "^1.7.1", "@testing-library/jest-dom": "^5.14.1", "@testing-library/react": "^12.0.0", diff --git a/src/components/OverlayTool/OverlayDisplay/OverlayDisplay.tsx b/src/components/OverlayTool/OverlayDisplay/OverlayDisplay.tsx index be3d70d..54bb124 100644 --- a/src/components/OverlayTool/OverlayDisplay/OverlayDisplay.tsx +++ b/src/components/OverlayTool/OverlayDisplay/OverlayDisplay.tsx @@ -1,4 +1,6 @@ import { useSelector } from "react-redux"; +import { useTransition, animated } from "@react-spring/web"; + import { overlayToolSelector } from "../../../features/overlayTool/overlayToolSelector"; import { OverlayItemContainer } from "./styles"; @@ -6,18 +8,37 @@ import { OverlayItemContainer } from "./styles"; export function OverlayDisplay() { const { currentOverlayItem, visible } = useSelector(overlayToolSelector); - if (currentOverlayItem == null) return null; + const xPos = currentOverlayItem?.position.x ?? 0; + const yPos = currentOverlayItem?.position.y ?? 0; + const transition = useTransition(visible, { + from: { left: xPos, top: yPos + 50, opacity: 0 }, + enter: { + left: xPos, + top: yPos, + opacity: currentOverlayItem?.opacity ?? 1, + }, + leave: { left: xPos, top: yPos + 50, opacity: 0 }, + }); + + if (currentOverlayItem == null) { + return null; // Exit - There is no overlay item yet! + } const { id, position } = currentOverlayItem; return ( - - {id} -
- ({position.x}px {position.y}px) -
+ transition((style, visible) => + visible ? ( + + + {id} +
+ (x:{position.x}px, y:{position.y}px) +
+
+ ) : null, + ) ); } diff --git a/src/components/OverlayTool/OverlayDisplay/styles.ts b/src/components/OverlayTool/OverlayDisplay/styles.ts index 6ff1885..6093c9b 100644 --- a/src/components/OverlayTool/OverlayDisplay/styles.ts +++ b/src/components/OverlayTool/OverlayDisplay/styles.ts @@ -1,4 +1,5 @@ import styled from "styled-components"; + import { OverlayPosition } from "../../../types/state"; export type OverlayItemContainerProps = { @@ -15,11 +16,11 @@ export const OverlayItemContainer = styled.div.attrs( display: visible ? undefined : "none", }, }))` - position: absolute; - /* Temporary. Overlay will be transparent and based on an image. */ width: 150px; height: 150px; background-color: white; box-shadow: 0px 7px 11px 1px black; `; +OverlayItemContainer.displayName = "OverlayItemContainer"; + diff --git a/src/components/Workspaces/Workspace/WorkspaceControls.tsx b/src/components/Workspaces/Workspace/WorkspaceControls.tsx index 900a21d..c0b53f3 100644 --- a/src/components/Workspaces/Workspace/WorkspaceControls.tsx +++ b/src/components/Workspaces/Workspace/WorkspaceControls.tsx @@ -12,7 +12,7 @@ export const WorkspaceControls = () => { const { animatedBG } = useSelector(workspaceSelector); return( - + ({ }))` background-color: ${p => p.theme.colors.faintGrey}; border-radius: 1em; + width: 800px; + margin-bottom: 1em; `; ControlsContainer.displayName = "ControlsContainer"; diff --git a/yarn.lock b/yarn.lock index a72fe20..3b7a858 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1466,6 +1466,52 @@ schema-utils "^3.0.0" source-map "^0.7.3" +"@react-spring/animated@~9.4.0": + version "9.4.1" + resolved "https://registry.yarnpkg.com/@react-spring/animated/-/animated-9.4.1.tgz#6b5e57725408ba8347f098a5111a9fb4de74a81b" + integrity sha512-uAJkcrSlpg8uSe8zy7eJcDdNpI5QvRXrZUKhn5dlGAPk3psgY5qj6pahzB0k5NZZQ27ls8Z5Nt4VKhGaXPJNDQ== + dependencies: + "@react-spring/shared" "~9.4.0" + "@react-spring/types" "~9.4.0" + +"@react-spring/core@~9.4.0": + version "9.4.1" + resolved "https://registry.yarnpkg.com/@react-spring/core/-/core-9.4.1.tgz#0658611dd961d745ac9cfc9dde5e86f2895e182a" + integrity sha512-sXQmGg4wNeyoVZ/LdEF01xtzQKZtLIyFDX03hoa0oa9VTgLNTVSbVXD9q2xsH8HtWpY4OFPTi/9Noi93gjnYyg== + dependencies: + "@react-spring/animated" "~9.4.0" + "@react-spring/rafz" "~9.4.0" + "@react-spring/shared" "~9.4.0" + "@react-spring/types" "~9.4.0" + +"@react-spring/rafz@~9.4.0": + version "9.4.1" + resolved "https://registry.yarnpkg.com/@react-spring/rafz/-/rafz-9.4.1.tgz#66ed8eadf5c1784d89b210f443fd2ec9fdb59fb6" + integrity sha512-R/mNOQ4axraWsL/jwzoaqfeX6RwUODg3WOGweL8zYbHHheRqQV+QwnhGmDATepBZ1H3UUulhXvOqkzWzjnpuQQ== + +"@react-spring/shared@~9.4.0": + version "9.4.1" + resolved "https://registry.yarnpkg.com/@react-spring/shared/-/shared-9.4.1.tgz#6c688cbe093ada7f6cd8ed2b9d28a807b6665ede" + integrity sha512-7atTQOhEQmw5UEYbb5yk7YEaf11AcRF7UISfAmr9FJ2FJD4VUVCn1R4V78omiFiRvnU6qI3GRhkRnIvYM8aAZw== + dependencies: + "@react-spring/rafz" "~9.4.0" + "@react-spring/types" "~9.4.0" + +"@react-spring/types@~9.4.0": + version "9.4.1" + resolved "https://registry.yarnpkg.com/@react-spring/types/-/types-9.4.1.tgz#93a203e5b922362e6643b95aff0989dd1a33b77b" + integrity sha512-eZmlFRc+XkY/HJi4RswLkIHH0nKQkqKRHPUqnseffcBuZ5FNXKDUmNnLUpqkrCpl746QCFVQtI5QptLklDATfQ== + +"@react-spring/web@^9.4.1": + version "9.4.1" + resolved "https://registry.yarnpkg.com/@react-spring/web/-/web-9.4.1.tgz#dd8560af6834a9c41cd7061bc98721e9f64a8557" + integrity sha512-ajlGJl0Zqa3idhZw0KL5chP8AIn4wPHpDY7WjtWaWjVZSZRSBAeHmfqNLtAGCjazeO/Q6zmt6wdGs8bX8q42rQ== + dependencies: + "@react-spring/animated" "~9.4.0" + "@react-spring/core" "~9.4.0" + "@react-spring/shared" "~9.4.0" + "@react-spring/types" "~9.4.0" + "@reduxjs/toolkit@^1.7.1": version "1.7.1" resolved "https://registry.yarnpkg.com/@reduxjs/toolkit/-/toolkit-1.7.1.tgz#994962aeb7df3c77be343dd2ad1aa48221dbaa0c"