Skip to content

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

refactor: remove Banner component and add ToDiagram link in Toolbar

AykutSarac560f7cac8ae9
diff --git a/apps/www/src/features/Banner.tsx b/apps/www/src/features/Banner.tsx
deleted file mode 100644
index 106e5855..00000000
--- a/apps/www/src/features/Banner.tsx
+++ /dev/null
@@ -1,104 +0,0 @@
-import React, { useEffect, useState } from "react";
-import { Anchor, Flex, Button, ActionIcon } from "@mantine/core";
-import { useSessionStorage } from "@mantine/hooks";
-import { MdClose } from "react-icons/md";
-
-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",
- "Generate Mermaid flowcharts, modern and customizable",
-];
-
-const ROTATION_INTERVAL = 6000; // ms between label changes
-const FADE_DURATION = 500; // ms for fade transition
-
-export const Banner = () => {
- const [index, setIndex] = useState(0);
- const [visible, setVisible] = useState(true);
- const [dismissed, setDismissed] = useSessionStorage({
- key: "jsoncrack_banner_dismissed",
- defaultValue: false,
- });
-
- useEffect(() => {
- if (dismissed) return;
-
- 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);
- };
- }, [dismissed]);
-
- const handleDismiss = (e: React.MouseEvent) => {
- e.preventDefault();
- e.stopPropagation();
- setDismissed(true);
- };
-
- if (dismissed) return null;
-
- return (
- <Anchor
- href="https://todiagram.com/editor?utm_source=jsoncrack&utm_medium=top_banner"
- target="_blank"
- rel="noopener"
- underline="never"
- style={{ position: "relative" }}
- >
- <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>
- <ActionIcon
- onClick={handleDismiss}
- size="sm"
- variant="transparent"
- style={{
- position: "absolute",
- right: "8px",
- color: "black",
- }}
- aria-label="Close banner"
- >
- <MdClose size={18} />
- </ActionIcon>
- </Flex>
- </Anchor>
- );
-};
diff --git a/apps/www/src/features/editor/Toolbar/index.tsx b/apps/www/src/features/editor/Toolbar/index.tsx
index 32b7f139..590d3e5b 100644
--- a/apps/www/src/features/editor/Toolbar/index.tsx
+++ b/apps/www/src/features/editor/Toolbar/index.tsx
@@ -1,10 +1,10 @@
-import React from "react";
import Link from "next/link";
import { Flex, Group } from "@mantine/core";
import styled from "styled-components";
import toast from "react-hot-toast";
import { AiOutlineFullscreen } from "react-icons/ai";
import { FaGithub } from "react-icons/fa6";
+import { TbExternalLink } from "react-icons/tb";
import { JSONCrackLogo } from "../../../layout/JSONCrackBrandLogo";
import { FileMenu } from "./FileMenu";
import { ThemeToggle } from "./ThemeToggle";
@@ -12,6 +12,25 @@ import { ToolsMenu } from "./ToolsMenu";
import { ViewMenu } from "./ViewMenu";
import { StyledToolElement } from "./styles";
+const StyledToDiagramLink = styled.a`
+ display: flex;
+ align-items: center;
+ gap: 4px;
+ font-size: 13px;
+ font-weight: 500;
+ padding: 4px 10px;
+ border-radius: 4px;
+ white-space: nowrap;
+ background: linear-gradient(135deg, #ff75b7 0%, #fed761 100%);
+ color: #1a1a1a;
+ text-decoration: none;
+ transition: opacity 0.15s ease;
+
+ &:hover {
+ opacity: 0.85;
+ }
+`;
+
const StyledTools = styled.div`
position: relative;
display: flex;
@@ -55,6 +74,13 @@ export const Toolbar = () => {
<ToolsMenu />
</Group>
<Group gap="xs" justify="right" w="100%" style={{ flexWrap: "nowrap" }}>
+ <StyledToDiagramLink
+ href="https://todiagram.com/editor?utm_source=jsoncrack&utm_medium=toolbar"
+ target="_blank"
+ rel="noopener"
+ >
+ Upgrade to Pro Editor <TbExternalLink size={14} />
+ </StyledToDiagramLink>
<ThemeToggle />
<Link href="https://github.com/AykutSarac/jsoncrack.com" rel="noopener" target="_blank">
<StyledToolElement title="GitHub">
diff --git a/apps/www/src/pages/editor.tsx b/apps/www/src/pages/editor.tsx
index 32cede9d..b7457f6d 100644
--- a/apps/www/src/pages/editor.tsx
+++ b/apps/www/src/pages/editor.tsx
@@ -10,7 +10,6 @@ import "allotment/dist/style.css";
import { generateNextSeo } from "next-seo/pages";
import { SEO } from "../constants/seo";
import { darkTheme, lightTheme } from "../constants/theme";
-import { Banner } from "../features/Banner";
import { BottomBar } from "../features/editor/BottomBar";
import { FullscreenDropzone } from "../features/editor/FullscreenDropzone";
import { Toolbar } from "../features/editor/Toolbar";
@@ -94,7 +93,6 @@ const EditorPage = () => {
<ModalController />
<StyledEditorWrapper>
<StyledPageWrapper>
- {process.env.NEXT_PUBLIC_DISABLE_EXTERNAL_MODE === "true" ? null : <Banner />}
<Toolbar />
<StyledEditorWrapper>
<StyledEditor proportionalLayout={false}>