Skip to content

✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.

feat: add editor top banner

AykutSaracc63d1432198d
diff --git a/.env.development b/.env.development
index 7d391f7b..15d1a8b1 100644
--- a/.env.development
+++ b/.env.development
@@ -1 +1,2 @@
+NEXT_PUBLIC_NODE_LIMIT=2000
NEXT_PUBLIC_DISABLE_EXTERNAL_MODE=false
\ No newline at end of file
diff --git a/src/features/Banner.tsx b/src/features/Banner.tsx
new file mode 100644
index 00000000..d7eb2110
--- /dev/null
+++ b/src/features/Banner.tsx
@@ -0,0 +1,73 @@
+import React, { useEffect, useState } from "react";
+import { Anchor, Flex, Button } from "@mantine/core";
+
+export const BANNER_HEIGHT =
+ process.env.NEXT_PUBLIC_DISABLE_EXTERNAL_MODE === "true" ? "0px" : "40px";
+
+const BANNER_LIST = [
+ "Save and store your diagrams with ToDiagram",
+ "Explore the ToDiagram from the creators of JSON Crack",
+ "Generate AI diagrams with single prompt",
+ "Try ToDiagram for free, no sign-up required",
+ "Edit data directly inside diagrams",
+ "Explore larger datasets (up to 50 MB) easily",
+];
+
+export const Banner = () => {
+ const ROTATION_INTERVAL = 6000; // ms between label changes
+ const FADE_DURATION = 500; // ms for fade transition
+
+ const [index, setIndex] = useState(0);
+ const [visible, setVisible] = useState(true);
+
+ useEffect(() => {
+ let fadeTimeout: ReturnType<typeof setTimeout> | undefined;
+ const intervalId = setInterval(() => {
+ setVisible(false);
+ fadeTimeout = setTimeout(() => {
+ setIndex(i => (i + 1) % BANNER_LIST.length);
+ setVisible(true);
+ }, FADE_DURATION);
+ }, ROTATION_INTERVAL);
+
+ return () => {
+ clearInterval(intervalId);
+ if (fadeTimeout) clearTimeout(fadeTimeout);
+ };
+ }, []);
+
+ return (
+ <Anchor
+ href="https://todiagram.com/editor?utm_source=jsoncrack&utm_medium=top_banner"
+ target="_blank"
+ rel="noopener"
+ underline="never"
+ >
+ <Flex
+ h={BANNER_HEIGHT}
+ justify="center"
+ align="center"
+ fw="500"
+ gap="xs"
+ style={{
+ background: "linear-gradient(90deg, #FF75B7 0%, #FED761 100%)",
+ color: "black",
+ }}
+ >
+ <span
+ style={{
+ transition: `opacity ${FADE_DURATION}ms ease`,
+ opacity: visible ? 1 : 0,
+ willChange: "opacity",
+ display: "inline-block",
+ }}
+ >
+ {BANNER_LIST[index]}{" "}
+ </span>
+ <Button size="xs" color="gray">
+ Try now
+ </Button>
+ </Flex>
+ </Anchor>
+ );
+};
diff --git a/src/features/editor/BottomBar.tsx b/src/features/editor/BottomBar.tsx
index 8a51bc68..25de396e 100644
--- a/src/features/editor/BottomBar.tsx
+++ b/src/features/editor/BottomBar.tsx
@@ -3,7 +3,6 @@ import { Flex, Menu, Popover, Text } from "@mantine/core";
import styled from "styled-components";
import { event as gaEvent } from "nextjs-google-analytics";
import { BiSolidDockLeft } from "react-icons/bi";
-import { FaCrown } from "react-icons/fa6";
import { IoMdCheckmark } from "react-icons/io";
import { MdArrowUpward } from "react-icons/md";
import { VscCheck, VscError, VscRunAll, VscSync, VscSyncIgnored } from "react-icons/vsc";
@@ -161,30 +160,6 @@ export const BottomBar = () => {
{format.label}
</Menu.Item>
))}
- <Menu.Item
- fz={12}
- onClick={() =>
- window.open(
- "https://todiagram.com/editor?utm_source=jsoncrack&utm_medium=bottom-bar&utm_campaign=custom-diagram",
- "_blank"
- )
- }
- rightSection={<FaCrown color="gray" />}
- >
- Custom
- </Menu.Item>
- <Menu.Item
- fz={12}
- onClick={() =>
- window.open(
- "https://todiagram.com/editor?utm_source=jsoncrack&utm_medium=bottom-bar&utm_campaign=mermaid-diagram",
- "_blank"
- )
- }
- rightSection={<FaCrown color="gray" />}
- >
- Mermaid
- </Menu.Item>
</Menu.Dropdown>
</Menu>
</StyledRight>
diff --git a/src/features/editor/TextEditor.tsx b/src/features/editor/TextEditor.tsx
index 53b7c830..4a2a0571 100644
--- a/src/features/editor/TextEditor.tsx
+++ b/src/features/editor/TextEditor.tsx
@@ -4,6 +4,7 @@ import styled from "styled-components";
import Editor, { type EditorProps, loader, type OnMount, useMonaco } from "@monaco-editor/react";
import useConfig from "../../store/useConfig";
import useFile from "../../store/useFile";
+import { BANNER_HEIGHT } from "../Banner";
loader.config({
paths: {
@@ -102,7 +103,7 @@ const StyledEditorWrapper = styled.div`
const StyledWrapper = styled.div`
display: grid;
- height: calc(100vh - 67px);
+ height: ${`calc(100vh - 67px - ${BANNER_HEIGHT})`};
grid-template-columns: 100%;
grid-template-rows: minmax(0, 1fr);
`;
diff --git a/src/features/editor/Toolbar/index.tsx b/src/features/editor/Toolbar/index.tsx
index 14285974..06c0b745 100644
--- a/src/features/editor/Toolbar/index.tsx
+++ b/src/features/editor/Toolbar/index.tsx
@@ -1,13 +1,11 @@
import React from "react";
import Link from "next/link";
-import { Flex, Group, Button } from "@mantine/core";
+import { Flex, Group } from "@mantine/core";
import styled from "styled-components";
import toast from "react-hot-toast";
import { AiOutlineFullscreen } from "react-icons/ai";
-import { FaCrown, FaGithub } from "react-icons/fa6";
-import { LuLink } from "react-icons/lu";
+import { FaGithub } from "react-icons/fa6";
import { JSONCrackLogo } from "../../../layout/JsonCrackLogo";
-import { useModal } from "../../../store/useModal";
import { FileMenu } from "./FileMenu";
import { ToolsMenu } from "./ToolsMenu";
import { ViewMenu } from "./ViewMenu";
@@ -43,8 +41,6 @@ function fullscreenBrowser() {
}
export const Toolbar = () => {
- const setVisible = useModal(state => state.setVisible);
-
return (
<StyledTools>
<Group gap="xs" justify="left" w="100%" style={{ flexWrap: "nowrap" }}>
@@ -56,33 +52,8 @@ export const Toolbar = () => {
<FileMenu />
<ViewMenu />
<ToolsMenu />
- <Button
- component={Link}
- href="https://todiagram.com/editor?utm_source=jsoncrack&utm_medium=toolbar"
- target="_blank"
- rel="noopener"
- autoContrast
- color="yellow"
- variant="light"
- size="compact-xs"
- fz="12"
- fw="600"
- leftSection={<FaCrown />}
- >
- Try Pro for Free | No Sign-up
- </Button>
</Group>
<Group gap="xs" justify="right" w="100%" style={{ flexWrap: "nowrap" }}>
- <Button
- color="gray"
- fz="12"
- leftSection={<LuLink />}
- size="compact-sm"
- variant="default"
- onClick={() => setVisible("UpgradeModal", true)}
- >
- Share
- </Button>
<Link href="https://github.com/AykutSarac/jsoncrack.com" rel="noopener" target="_blank">
<StyledToolElement title="GitHub">
<FaGithub size="18" />
diff --git a/src/features/editor/views/GraphView/NotSupported.tsx b/src/features/editor/views/GraphView/NotSupported.tsx
index 3a9fd9e8..0d684cd5 100644
--- a/src/features/editor/views/GraphView/NotSupported.tsx
+++ b/src/features/editor/views/GraphView/NotSupported.tsx
@@ -2,7 +2,6 @@ import React from "react";
import { Anchor, Button, Image, Overlay, Stack, Text } from "@mantine/core";
import styled, { keyframes } from "styled-components";
import useConfig from "../../../../store/useConfig";
-import { useModal } from "../../../../store/useModal";
const shineEffect = keyframes`
0% {
@@ -59,7 +58,6 @@ const ShiningButton = styled.div`
export const NotSupported = () => {
const darkmodeEnabled = useConfig(state => state.darkmodeEnabled);
- const setVisible = useModal(state => state.setVisible);
return (
<Overlay
@@ -77,7 +75,14 @@ export const NotSupported = () => {
This diagram is too large and not supported at JSON Crack.
<br />
Try{" "}
- <Anchor inherit c="teal" fw="500" onClick={() => setVisible("UpgradeModal", true)}>
+ <Anchor
+ inherit
+ c="teal"
+ fw="500"
+ href="https://todiagram.com/editor?utm_source=jsoncrack&utm_medium=data_limit"
+ target="_blank"
+ rel="noopener"
+ >
ToDiagram
</Anchor>{" "}
for larger diagrams and more features.
diff --git a/src/features/editor/views/GraphView/index.tsx b/src/features/editor/views/GraphView/index.tsx
index 3bcf8fdd..96030fc5 100644
--- a/src/features/editor/views/GraphView/index.tsx
+++ b/src/features/editor/views/GraphView/index.tsx
@@ -8,6 +8,7 @@ import { Canvas } from "reaflow";
import type { ElkRoot } from "reaflow/dist/layout/useLayout";
import { useLongPress } from "use-long-press";
import useConfig from "../../../../store/useConfig";
+import { BANNER_HEIGHT } from "../../../Banner";
import { CustomEdge } from "./CustomEdge";
import { CustomNode } from "./CustomNode";
import { NotSupported } from "./NotSupported";
@@ -19,7 +20,7 @@ import useGraph from "./stores/useGraph";
const StyledEditorWrapper = styled.div<{ $widget: boolean; $showRulers: boolean }>`
position: absolute;
width: 100%;
- height: ${({ $widget }) => ($widget ? "100vh" : "calc(100vh - 40px)")};
+ height: ${({ $widget }) => ($widget ? "100vh" : `calc(100vh - 40px - ${BANNER_HEIGHT})`)};
--bg-color: ${({ theme }) => theme.GRID_BG_COLOR};
--line-color-1: ${({ theme }) => theme.GRID_COLOR_PRIMARY};
diff --git a/src/features/modals/SchemaModal/index.tsx b/src/features/modals/SchemaModal/index.tsx
index a886c545..f3f87736 100644
--- a/src/features/modals/SchemaModal/index.tsx
+++ b/src/features/modals/SchemaModal/index.tsx
@@ -5,17 +5,14 @@ import Editor from "@monaco-editor/react";
import { event as gaEvent } from "nextjs-google-analytics";
import { toast } from "react-hot-toast";
import { FaChevronDown } from "react-icons/fa";
-import { FaCrown } from "react-icons/fa6";
import { VscLinkExternal } from "react-icons/vsc";
import { FileFormat } from "../../../enums/file.enum";
import useConfig from "../../../store/useConfig";
import useFile from "../../../store/useFile";
-import { useModal } from "../../../store/useModal";
export const SchemaModal = ({ opened, onClose }: ModalProps) => {
const setContents = useFile(state => state.setContents);
const setJsonSchema = useFile(state => state.setJsonSchema);
- const setVisible = useModal(state => state.setVisible);
const darkmodeEnabled = useConfig(state => (state.darkmodeEnabled ? "vs-dark" : "light"));
const [schema, setSchema] = React.useState(
JSON.stringify(
@@ -116,12 +113,6 @@ export const SchemaModal = ({ opened, onClose }: ModalProps) => {
</Menu.Target>
<Menu.Dropdown>
<Menu.Item onClick={generateMockData}>Generate Mock Data</Menu.Item>
- <Menu.Item
- onClick={() => setVisible("UpgradeModal", true)}
- rightSection={<FaCrown />}
- >
- Validate on Diagrams
- </Menu.Item>
</Menu.Dropdown>
</Menu>
</Button.Group>
diff --git a/src/features/modals/UpgradeModal/index.tsx b/src/features/modals/UpgradeModal/index.tsx
deleted file mode 100644
index 1a90829c..00000000
--- a/src/features/modals/UpgradeModal/index.tsx
+++ /dev/null
@@ -1,282 +0,0 @@
-import React from "react";
-import type { FlexProps, ModalProps } from "@mantine/core";
-import {
- Modal,
- Text,
- Flex,
- List,
- ThemeIcon,
- Divider,
- Button,
- Group,
- Anchor,
- Image,
- Box,
- CloseButton,
- FocusTrap,
- Stack,
- Badge,
-} from "@mantine/core";
-import styled from "styled-components";
-import Cookie from "js-cookie";
-import { FaPlay } from "react-icons/fa6";
-import { GoDependabot } from "react-icons/go";
-import { LuCheck, LuGitCompareArrows, LuInfinity, LuPencilRuler } from "react-icons/lu";
-import useConfig from "../../../store/useConfig";
-
-export const UpgradeContent = (props: FlexProps) => {
- const darkmodeEnabled = useConfig(state => state.darkmodeEnabled);
-
- return (
- <Flex direction="column" gap="0" {...props}>
- <Flex justify="space-between" gap="4" px="sm" wrap="wrap">
- <List
- center
- c="bright"
- fz="lg"
- spacing="4"
- icon={
- <ThemeIcon color="green" variant="transparent">
- <LuCheck size="18" />
- </ThemeIcon>
- }
- >
- <List.Item>No size limit</List.Item>
- <List.Item>Editable diagrams</List.Item>
- <List.Item>Fast and optimized</List.Item>
- </List>
- <List
- center
- c="bright"
- fz="lg"
- spacing="4"
- icon={
- <ThemeIcon color="green" variant="transparent">
- <LuCheck size="18" />
- </ThemeIcon>
- }
- >
- <List.Item>Custom themes</List.Item>
- <List.Item>Modern UI</List.Item>
- <List.Item>
- <Anchor
- href="https://chromewebstore.google.com/detail/todiagram/gpcnkpjdmgihedngamkhendifclghjhn"
- rel="noopener"
- target="_blank"
- inherit
- c="teal"
- >
- Chrome Extension
- </Anchor>
- </List.Item>
- </List>
- </Flex>
- <Box mt="lg">
- <Image
- src={`/assets/diagram-${darkmodeEnabled ? "dark" : "light"}.png`}
- alt="diagram"
- fit="cover"
- mx="auto"
- width="auto"
- style={{
- filter: "drop-shadow(3px -3px 2px rgba(0, 0, 0, 0.2))",
- objectPosition: "top",
- }}
- />
- <Divider maw="600" w="100%" mb="lg" />
- </Box>
- </Flex>
- );
-};
-
-const StyledFeatureItem = styled.div`
- @property --gradient-1 {
- syntax: "<number>";
- initial-value: 0;
- inherits: false;
- }
- @property --gradient-2 {
- syntax: "<number>";
- initial-value: 0;
- inherits: false;
- }
- @property --gradient-3 {
- syntax: "<number>";
- initial-value: 0;
- inherits: false;
- }
-
- background-image:
- radial-gradient(
- 65% 110% at 50% 0,
- rgba(168, 92, 92, var(--gradient-1)) 0,
- rgba(103, 69, 69, 0) 100%
- ),
- radial-gradient(
- 66% 135% at 77% 23%,
- rgba(4, 0, 255, var(--gradient-2)) 0,
- hsla(68, 15%, 59%, 0) 80%
- ),
- radial-gradient(
- 125% 234% at 10% 142%,
- rgba(217, 126, 75, var(--gradient-3)) 0,
- hsla(0, 0%, 100%, 0) 37%
- );
- transition:
- --gradient-1 0.3s,
- --gradient-2 0.3s,
- --gradient-3 0.3s;
- padding: 12px 16px;
- background-color: rgba(27, 23, 40, 0.025);
- border: 1px solid rgba(142, 142, 142, 0.35);
- border-radius: 0.5rem;
- max-width: 350px;
- cursor: pointer;
-
- &.selected {
- --gradient-1: 0.1;
- --gradient-2: 0.15;
- --gradient-3: 0.15;
- border-color: rgba(130, 255, 203, 0.567);
- }
-
- &:hover {
- --gradient-1: 0.1;
- --gradient-2: 0.15;
- --gradient-3: 0.15;
- }
-`;
-
-const FeatureCard = (props: {
- title: string;
- description: string;
- icon: React.ReactNode;
- onClick: () => void;
- selected: boolean;
-}) => {
- return (
- <StyledFeatureItem className={props.selected ? "selected" : ""} onClick={props.onClick}>
- <Flex gap="md" align="flex-start">
- <ThemeIcon variant="light" color="teal" radius="xl" size="36">
- {props.icon}
- </ThemeIcon>
- <Stack gap="4">
- <Flex justify="space-between" align="center">
- <Text fz="md" fw="600" c="bright">
- {props.title}
- </Text>
- <ThemeIcon variant="transparent" color="teal">
- {props.selected ? <LuCheck size={20} /> : null}
- </ThemeIcon>
- </Flex>
- <Text fz="sm" c="gray" opacity={0.8}>
- {props.description}
- </Text>
- </Stack>
- </Flex>
- </StyledFeatureItem>
- );
-};
-
-const FEATURES = [
- {
- title: "No File Size Limits",
- description: "Load and edit even the largest data files without restrictions.",
- icon: <LuInfinity size={20} />,
- },
- {
- title: "Visual Data Editing",
- description: "Edit JSON, YAML, CSV, and XML directly on the diagram.",
- icon: <LuPencilRuler size={20} />,
- },
- {
- title: "Live JSON Schema Validation",
- description: "Instantly see invalid fields highlighted in red on the diagram.",
- icon: <LuGitCompareArrows size={20} />,
- },
- {
- title: "AI Assistant",
- description: "Use AI to filter and transform data based on your needs.",
- icon: <GoDependabot size={20} />,
- },
-];
-
-export const UpgradeModal = ({ opened, onClose }: ModalProps) => {
- const [selectedFeature, setSelectedFeature] = React.useState(0);
-
- const handleCloseModal = () => {
- Cookie.set("upgrade_shown", "true", { expires: 3 });
- onClose();
- };
-
- return (
- <Modal
- size="auto"
- opened={opened}
- onClose={handleCloseModal}
- zIndex={1001}
- centered
- radius="md"
- overlayProps={{ blur: 2 }}
- withCloseButton={false}
- >
- <FocusTrap.InitialFocus />
- <Flex>
- <Stack>
- {FEATURES.map((feature, index) => (
- <FeatureCard
- key={index}
- title={feature.title}
- description={feature.description}
- icon={feature.icon}
- onClick={() => setSelectedFeature(index)}
- selected={selectedFeature === index}
- />
- ))}
- </Stack>
- <Divider orientation="vertical" mx="md" />
- <Box>
- <Flex justify="center" align="center" gap="xs">
- <Badge size="xl" radius="sm" variant="light" color="teal" ml="auto">
- 🔥 NEW
- </Badge>
- <Text fz="24" fw="700" c="bright">
- ToDiagram Editor
- </Text>
- <CloseButton ml="auto" onClick={handleCloseModal} />
- </Flex>
- <Image
- mt="sm"
- src={`/assets/td-${selectedFeature + 1}.webp`}
- w="100%"
- maw="385"
- radius="md"
- alt="upgrade"
- fit="contain"
- />
- <Group justify="center" gap="xs" mt="md">
- <Button
- component="a"
- href="https://todiagram.com/editor?utm_source=jsoncrack&utm_medium=upgrade_modal"
- rel="noopener"
- target="_blank"
- radius="lg"
- size="lg"
- color="teal"
- autoContrast
- leftSection={<FaPlay />}
- fullWidth
- fw="600"
- style={{
- boxShadow: "rgba(0, 0, 0, 0.12) 0px -3px 0px 0px inset",
- border: "none",
- }}
- >
- Upgrade now
- </Button>
- </Group>
- </Box>
- </Flex>
- </Modal>
- );
-};
diff --git a/src/features/modals/index.ts b/src/features/modals/index.ts
index 49d58b61..be818c22 100644
--- a/src/features/modals/index.ts
+++ b/src/features/modals/index.ts
@@ -1,7 +1,6 @@
export { DownloadModal } from "./DownloadModal";
export { ImportModal } from "./ImportModal";
export { NodeModal } from "./NodeModal";
-export { UpgradeModal } from "./UpgradeModal";
export { JWTModal } from "./JWTModal";
export { SchemaModal } from "./SchemaModal";
export { JQModal } from "./JQModal";
diff --git a/src/pages/editor.tsx b/src/pages/editor.tsx
index 6612cf71..b7ea8d6f 100644
--- a/src/pages/editor.tsx
+++ b/src/pages/editor.tsx
@@ -11,6 +11,7 @@ import "allotment/dist/style.css";
import { NextSeo } from "next-seo";
import { SEO } from "../constants/seo";
import { darkTheme, lightTheme } from "../constants/theme";
+import { Banner, BANNER_HEIGHT } from "../features/Banner";
import { BottomBar } from "../features/editor/BottomBar";
import { FullscreenDropzone } from "../features/editor/FullscreenDropzone";
import { Toolbar } from "../features/editor/Toolbar";
@@ -49,7 +50,7 @@ export const StyledEditor = styled(Allotment)`
position: relative !important;
display: flex;
background: ${({ theme }) => theme.BACKGROUND_SECONDARY};
- height: calc(100vh - 40px);
+ height: ${`calc(100vh - 40px - ${BANNER_HEIGHT})`};
@media only screen and (max-width: 320px) {
height: 100vh;
@@ -100,6 +101,7 @@ const EditorPage = () => {
<ModalController />
<StyledEditorWrapper>
<StyledPageWrapper>
+ {process.env.NEXT_PUBLIC_DISABLE_EXTERNAL_MODE === "true" ? null : <Banner />}
<Toolbar />
<StyledEditorWrapper>
<StyledEditor proportionalLayout={false}>