Skip to content

Commit

Permalink
WIP animations and fixes and direction of relations
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Czemiel authored and Artur Czemiel committed Jun 3, 2023
1 parent be7584b commit 3a3369a
Show file tree
Hide file tree
Showing 14 changed files with 215 additions and 55 deletions.
3 changes: 3 additions & 0 deletions declarations.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// NOTE: The declaration below was injected by `"framer"`
// see https://www.framer.com/docs/guides/handshake for more information.
declare module "https://framer.com/m/*";
147 changes: 143 additions & 4 deletions package-lock.json

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

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"@emotion/react": "^11.9.3",
"@emotion/styled": "^11.9.3",
"color2k": "^1.2.4",
"framer-motion": "^10.12.16",
"fuzzyjs": "^5.0.1",
"graphql-language-service": "3.1.4",
"js-graph-algorithms": "^1.0.18",
Expand All @@ -87,4 +88,4 @@
"./packages/sandbox"
]
}
}
}
2 changes: 1 addition & 1 deletion packages/editor-worker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphql-editor-worker",
"version": "6.5.0",
"version": "6.6.0",
"private": false,
"license": "MIT",
"description": "Visual node editor for GraphQL",
Expand Down
3 changes: 2 additions & 1 deletion packages/editor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphql-editor",
"version": "6.5.0",
"version": "6.6.0",
"private": false,
"license": "MIT",
"description": "Visual node editor for GraphQL",
Expand Down Expand Up @@ -44,6 +44,7 @@
"d3": "^7.8.4",
"diff": "^5.1.0",
"file-saver": "^2.0.5",
"framer": "^2.3.0",
"fuzzyjs": "^5.0.1",
"graphql-editor-worker": "^6.5.0",
"graphql-js-tree": "^0.3.1",
Expand Down
7 changes: 6 additions & 1 deletion packages/editor/src/Graf/Graf.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { KeyboardActions, useIO } from "@/shared/hooks/io";
import { DraggableProvider } from "@/Graf/state/draggable";
import { useRelationsState } from "@/state/containers";
import { Button, Stack, useToasts } from "@aexol-studio/styling-system";
import { motion } from "framer-motion";

const SubNodeContainer = styled.div`
font-family: ${fontFamilySans};
Expand All @@ -29,7 +30,7 @@ const SubNodeContainer = styled.div`
height: 100%;
`;

const SubNodeWrapper = styled.div`
const SubNodeWrapper = styled(motion.div)`
width: 100%;
bottom: 0;
left: 0;
Expand Down Expand Up @@ -99,6 +100,10 @@ export const Graf: React.FC<{ node: ParserField }> = ({ node }) => {
if (selectedNodeId?.justCreated) return;
exit();
}}
transition={{ duration: 0.2 }}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
>
<SubNodeContainer>
<DraggableProvider>
Expand Down
23 changes: 16 additions & 7 deletions packages/editor/src/Graf/Node/components/Menu/Menu.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import React from 'react';
import React from "react";

import styled from '@emotion/styled';
import { fontFamilySans } from '@/vars';
import styled from "@emotion/styled";
import { fontFamilySans } from "@/vars";
import { motion } from "framer-motion";

const Wrapper = styled.div`
const Wrapper = styled(motion.div)`
width: 220px;
border-radius: ${(p) => p.theme.radius}px;
font-family: ${fontFamilySans};
z-index: 22;
z-index: 2;
`;

const Content = styled.div`
Expand Down Expand Up @@ -39,12 +40,20 @@ interface MenuProps
export const Menu = React.forwardRef<HTMLDivElement, MenuProps>(
({ children, hideMenu, menuName, ...props }, ref) => {
return (
<Wrapper {...props} ref={ref}>
<Wrapper
{...(props as any)}
ref={ref}
transition={{ duration: 0.2 }}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
>
<Content>
{menuName && <Title>{menuName}</Title>}
{children}
</Content>
</Wrapper>
);
},
}
);
Menu.displayName = "Menu";
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ export const Draw = ({
stroke={stroke}
strokeWidth={fac}
strokeDasharray={
relationType.type === Options.required ? undefined : "5 10"
relationType.type === Options.required ? undefined : "10 5"
}
d={`M ${t.x} ${t.y}
Q ${bezier1.x} ${bezier1.y} ${center.x} ${center.y}
Q ${bezier2.x} ${bezier2.y} ${f.x} ${f.y}`}
/>
<circle fill={stroke} stroke={stroke} r={7} cx={t.x + 2} cy={t.y + 2} />
<circle fill={stroke} stroke={stroke} r={7} cx={f.x + 2} cy={f.y + 2} />
<circle fill={stroke} stroke={stroke} r={4} cx={t.x} cy={t.y} />
<circle fill={stroke} stroke={stroke} r={8} cx={f.x} cy={f.y} />
</PathG>
);
}
Expand Down

0 comments on commit 3a3369a

Please sign in to comment.