Skip to content

Commit

Permalink
✨ New empty state
Browse files Browse the repository at this point in the history
  • Loading branch information
aexol committed Sep 26, 2023
1 parent 976f490 commit 56a5894
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 26 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

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

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.9.4",
"version": "6.9.5",
"private": false,
"license": "MIT",
"description": "Visual node editor for GraphQL",
Expand Down
4 changes: 2 additions & 2 deletions packages/editor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphql-editor",
"version": "6.9.4",
"version": "6.9.5",
"private": false,
"license": "MIT",
"description": "Visual node editor for GraphQL",
Expand Down Expand Up @@ -45,7 +45,7 @@
"file-saver": "^2.0.5",
"framer-motion": "^10.12.16",
"fuzzyjs": "^5.0.1",
"graphql-editor-worker": "^6.9.4",
"graphql-editor-worker": "^6.9.5",
"graphql-js-tree": "^1.0.5",
"graphql-language-service": "3.1.4",
"html-to-image": "^1.10.8",
Expand Down
53 changes: 46 additions & 7 deletions packages/editor/src/Relation/FTUX/BackgroundFTUX.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,54 @@
import { NewNode } from "@/shared/components/NewNode";
import { Stack, Typography } from "@aexol-studio/styling-system";
import {
ArrowNarrowBottomAlignment,
Button,
Stack,
Typography,
} from "@aexol-studio/styling-system";
import styled from "@emotion/styled";
import React from "react";

export const BackgroundFTUX = () => {
export const BackgroundFTUX = ({
onImport,
onStartCoding,
showCode,
}: {
showCode?: boolean;
onStartCoding: () => void;
onImport: () => void;
}) => {
return (
<Container direction="column" align="center" justify="center" gap="1rem;">
<Typography>
Your schema is empty! Please create your first node
</Typography>
<NewNode />
<Container direction="column" align="center" justify="center" gap="2rem">
<Stack direction="column" gap="4rem">
<Stack direction="column" gap="1rem">
<Typography>
Your schema is empty! Please create your first node.
</Typography>
<Stack gap="1rem">
{showCode && (
<Button onClick={onStartCoding} variant="neutral" size="small">
Start coding
</Button>
)}
<NewNode />
</Stack>
</Stack>
<Stack direction="column" gap="1rem">
<Typography>
You can also import the schema from URL and .graphql or .json file.
</Typography>
<Stack gap="1rem">
<Button
endAdornment={<ArrowNarrowBottomAlignment />}
onClick={onImport}
variant="neutral"
size="small"
>
Import schema
</Button>
</Stack>
</Stack>
</Stack>
</Container>
);
};
Expand Down
36 changes: 33 additions & 3 deletions packages/editor/src/Relation/Relation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,28 @@ import {
useRelationsState,
useTreesState,
} from "@/state/containers";
import React, { useMemo } from "react";
import React, { useMemo, useState } from "react";
import { TransformWrapper } from "react-zoom-pan-pinch";
import { Graf } from "@/Graf/Graf";
import styled from "@emotion/styled";
import { Chip } from "@aexol-studio/styling-system";
import { AnimatePresence } from "framer-motion";
import { BackgroundFTUX } from "@/Relation/FTUX/BackgroundFTUX";
import { useRouter } from "@/state/containers/router";
import { ImportSchema } from "@/shared/dialogs/ImportSchema";

export const Relation: React.FC = () => {
export const Relation: React.FC<{ setInitialSchema: (s: string) => void }> = ({
setInitialSchema,
}) => {
const { activeNode, focusMode, allNodes } = useTreesState();
const { filteredFocusedNodes, filteredRelationNodes } =
useRelationNodesState();
const { editMode, ctrlToZoom } = useRelationsState();
const { set, routes } = useRouter();
const { grafErrors } = useErrorsState();
const [popupsState, setPopupsState] = useState({
import: false,
});
const isFocus = !!(focusMode && filteredFocusedNodes);
const viewport = useMemo(() => {
return (
Expand Down Expand Up @@ -73,9 +81,31 @@ export const Relation: React.FC = () => {
</AnimatePresence>
{!allNodes.nodes.length && (
<AnimatePresence>
<BackgroundFTUX />
<BackgroundFTUX
showCode={routes.code === "off"}
onStartCoding={() => {
set(
{
...routes,
code: routes.code === "off" ? "on" : "off",
source: "internal",
},
"internal"
);
}}
onImport={() => {
setPopupsState({ import: true });
}}
/>
</AnimatePresence>
)}
<ImportSchema
onClose={() => setPopupsState({ import: false })}
onImport={(s) => {
setInitialSchema(s);
}}
open={popupsState.import}
/>
</RelationContainer>
);
};
Expand Down
12 changes: 11 additions & 1 deletion packages/editor/src/editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,17 @@ export const Editor = React.forwardRef<ExternalEditorAPI, EditorProps>(
)}
{(routes.pane === "relation" || routes.pane === "docs") && (
<ErrorOuterContainer>
{routes.pane === "relation" && <Relation />}
{routes.pane === "relation" && (
<Relation
setInitialSchema={(s) =>
setSchema({
code: s,
libraries: schema.libraries,
source: "outside",
})
}
/>
)}
{routes.pane === "docs" && <Docs />}
<NodeNavigation />
</ErrorOuterContainer>
Expand Down
6 changes: 5 additions & 1 deletion packages/editor/src/editor/EmbeddedEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ export const EmbeddedEditor = ({ schema, theme }: EmbeddedEditorProps) => {
}}
>
<ErrorOuterContainer>
<Relation />
<Relation
setInitialSchema={(s) => {
//noop
}}
/>
<NodeNavigation />
</ErrorOuterContainer>
{!!codeErrors.length && <ErrorsList>{errorsItems}</ErrorsList>}
Expand Down
4 changes: 2 additions & 2 deletions packages/sandbox/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sandbox",
"version": "6.9.4",
"version": "6.9.5",
"private": false,
"license": "MIT",
"description": "Visual node editor for GraphQL",
Expand Down Expand Up @@ -48,7 +48,7 @@
"@aexol-studio/styling-system": "^0.0.8",
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"graphql-editor": "^6.9.4",
"graphql-editor": "^6.9.5",
"graphql-js-tree": "^0.1.6",
"socket.io-client": "^4.7.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/socket-live-test/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "socket-live-test",
"version": "1.0.2",
"version": "1.0.3",
"description": "testing editor live",
"main": "index.js",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion packages/svg-ts-sync/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "svg-ts-sync",
"version": "0.8.4",
"version": "0.8.5",
"private": false,
"license": "MIT",
"description": "Sync folders with svg's to react typescript components",
Expand Down

0 comments on commit 56a5894

Please sign in to comment.