ISSUE-017 - Basic animated mounting added.
This commit is contained in:
1 parent
61b60b9819
commit
1ba5e99532
7 files changed
+85
-13
No files matched your search
Vendored
+2
-1
@@ -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"
|
||||||
}
|
}
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
"@bedrock-layout/split": "^2.3.5",
|
"@bedrock-layout/split": "^2.3.5",
|
||||||
"@bedrock-layout/stack": "^2.3.4",
|
"@bedrock-layout/stack": "^2.3.4",
|
||||||
"@bedrock-layout/use-forwarded-ref": "^1.1.11",
|
"@bedrock-layout/use-forwarded-ref": "^1.1.11",
|
||||||
|
"@react-spring/web": "^9.4.1",
|
||||||
"@reduxjs/toolkit": "^1.7.1",
|
"@reduxjs/toolkit": "^1.7.1",
|
||||||
"@testing-library/jest-dom": "^5.14.1",
|
"@testing-library/jest-dom": "^5.14.1",
|
||||||
"@testing-library/react": "^12.0.0",
|
"@testing-library/react": "^12.0.0",
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
|
import { useTransition, animated } from "@react-spring/web";
|
||||||
|
|
||||||
import { overlayToolSelector } from "../../../features/overlayTool/overlayToolSelector";
|
import { overlayToolSelector } from "../../../features/overlayTool/overlayToolSelector";
|
||||||
|
|
||||||
import { OverlayItemContainer } from "./styles";
|
import { OverlayItemContainer } from "./styles";
|
||||||
@@ -6,18 +8,37 @@ import { OverlayItemContainer } from "./styles";
|
|||||||
export function OverlayDisplay() {
|
export function OverlayDisplay() {
|
||||||
const { currentOverlayItem, visible } = useSelector(overlayToolSelector);
|
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;
|
const { id, position } = currentOverlayItem;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<OverlayItemContainer
|
transition((style, visible) =>
|
||||||
position={position}
|
visible ? (
|
||||||
visible={visible}
|
<animated.div
|
||||||
>
|
style={{ ...style, position: "absolute" }}
|
||||||
{id}
|
>
|
||||||
<br />
|
<OverlayItemContainer position={position} visible={visible}>
|
||||||
({position.x}px {position.y}px)
|
{id}
|
||||||
</OverlayItemContainer>
|
<br />
|
||||||
|
(x:{position.x}px, y:{position.y}px)
|
||||||
|
</OverlayItemContainer>
|
||||||
|
</animated.div>
|
||||||
|
) : null,
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
|
|
||||||
import { OverlayPosition } from "../../../types/state";
|
import { OverlayPosition } from "../../../types/state";
|
||||||
|
|
||||||
export type OverlayItemContainerProps = {
|
export type OverlayItemContainerProps = {
|
||||||
@@ -15,11 +16,11 @@ export const OverlayItemContainer = styled.div.attrs<OverlayItemContainerProps>(
|
|||||||
display: visible ? undefined : "none",
|
display: visible ? undefined : "none",
|
||||||
},
|
},
|
||||||
}))<OverlayItemContainerProps>`
|
}))<OverlayItemContainerProps>`
|
||||||
position: absolute;
|
|
||||||
|
|
||||||
/* Temporary. Overlay will be transparent and based on an image. */
|
/* Temporary. Overlay will be transparent and based on an image. */
|
||||||
width: 150px;
|
width: 150px;
|
||||||
height: 150px;
|
height: 150px;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
box-shadow: 0px 7px 11px 1px black;
|
box-shadow: 0px 7px 11px 1px black;
|
||||||
`;
|
`;
|
||||||
|
OverlayItemContainer.displayName = "OverlayItemContainer";
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ export const WorkspaceControls = () => {
|
|||||||
const { animatedBG } = useSelector(workspaceSelector);
|
const { animatedBG } = useSelector(workspaceSelector);
|
||||||
|
|
||||||
return(
|
return(
|
||||||
<Grid gutter="sm">
|
<Grid gutter="sm" minItemWidth="25rem">
|
||||||
<Toggle
|
<Toggle
|
||||||
label="Animate BG"
|
label="Animate BG"
|
||||||
toggled={animatedBG}
|
toggled={animatedBG}
|
||||||
|
|||||||
@@ -49,5 +49,7 @@ export const ControlsContainer = styled(PadBox).attrs(() => ({
|
|||||||
}))`
|
}))`
|
||||||
background-color: ${p => p.theme.colors.faintGrey};
|
background-color: ${p => p.theme.colors.faintGrey};
|
||||||
border-radius: 1em;
|
border-radius: 1em;
|
||||||
|
width: 800px;
|
||||||
|
margin-bottom: 1em;
|
||||||
`;
|
`;
|
||||||
ControlsContainer.displayName = "ControlsContainer";
|
ControlsContainer.displayName = "ControlsContainer";
|
||||||
@@ -1466,6 +1466,52 @@
|
|||||||
schema-utils "^3.0.0"
|
schema-utils "^3.0.0"
|
||||||
source-map "^0.7.3"
|
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":
|
"@reduxjs/toolkit@^1.7.1":
|
||||||
version "1.7.1"
|
version "1.7.1"
|
||||||
resolved "https://registry.yarnpkg.com/@reduxjs/toolkit/-/toolkit-1.7.1.tgz#994962aeb7df3c77be343dd2ad1aa48221dbaa0c"
|
resolved "https://registry.yarnpkg.com/@reduxjs/toolkit/-/toolkit-1.7.1.tgz#994962aeb7df3c77be343dd2ad1aa48221dbaa0c"
|
||||||
|
|||||||
Reference in new issue
Block a user