Skip to content

Commit 46d1182

Browse files
committed
update modal ui
1 parent 594ffe4 commit 46d1182

File tree

5 files changed

+37
-34
lines changed

5 files changed

+37
-34
lines changed

public/assets/hp-dark.png

309 KB
Loading

public/assets/hp-light.png

310 KB
Loading

src/features/modals/UpgradeModal/index.tsx

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,26 @@ import {
1010
ThemeIcon,
1111
CloseButton,
1212
FocusTrap,
13+
Image,
14+
Divider,
1315
} from "@mantine/core";
16+
import Cookie from "js-cookie";
1417
import { LuCrown, LuTrendingUp } from "react-icons/lu";
18+
import useConfig from "src/store/useConfig";
1519

1620
export const UpgradeModal = ({ opened, onClose }: ModalProps) => {
21+
const darkmodeEnabled = useConfig(state => state.darkmodeEnabled);
22+
23+
const handleCloseModal = () => {
24+
Cookie.set("upgrade_shown", "true", { expires: 3 });
25+
onClose();
26+
};
27+
1728
return (
1829
<Modal
19-
size="430"
30+
size="700"
2031
opened={opened}
21-
onClose={onClose}
32+
onClose={handleCloseModal}
2233
zIndex={1001}
2334
centered
2435
radius="lg"
@@ -28,23 +39,31 @@ export const UpgradeModal = ({ opened, onClose }: ModalProps) => {
2839
>
2940
<FocusTrap.InitialFocus />
3041
<Flex>
42+
<Image
43+
src={`/assets/hp-${darkmodeEnabled ? "dark" : "light"}.png`}
44+
alt="diagram"
45+
maw={300}
46+
height="auto"
47+
style={{ objectPosition: "left" }}
48+
/>
49+
<Divider orientation="vertical" />
3150
<Stack gap="24" px="40" py="20">
3251
<Flex justify="space-between">
3352
<Title c="bright" fw="500" fz="24">
3453
Upgrade to unlock all features
3554
</Title>
36-
<CloseButton onClick={onClose} />
55+
<CloseButton onClick={handleCloseModal} />
3756
</Flex>
3857
<Flex gap="20">
3958
<ThemeIcon color="violet" variant="light" size="xl" radius="xl">
4059
<LuCrown size="20" />
4160
</ThemeIcon>
4261
<Stack gap="4">
4362
<Title c="gray" order={3} fw="500" fz="16">
44-
New diagram structure
63+
Load up to 4 MBs
4564
</Title>
4665
<Text fz="14" c="dimmed">
47-
50% less size, faster & customizable!
66+
We made it easy to visualize, format, and explore JSON data, faster than ever.
4867
</Text>
4968
</Stack>
5069
</Flex>
@@ -54,7 +73,7 @@ export const UpgradeModal = ({ opened, onClose }: ModalProps) => {
5473
</ThemeIcon>
5574
<Stack gap="4">
5675
<Title c="gray" order={3} fw="500" fz="16">
57-
Powerful
76+
Powerful, colorful editor
5877
</Title>
5978
<Text fz="14" c="dimmed">
6079
Modify data, preview images, inspect nodes, and more!
@@ -73,7 +92,7 @@ export const UpgradeModal = ({ opened, onClose }: ModalProps) => {
7392
>
7493
Try premium for free, no registration
7594
</Button>
76-
<Button size="md" variant="subtle" color="gray" radius="md" onClick={onClose}>
95+
<Button size="md" variant="subtle" color="gray" radius="md" onClick={handleCloseModal}>
7796
Maybe later
7897
</Button>
7998
</Stack>

src/layout/Landing/HeroSection.tsx

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,6 @@ export const HeroSection = () => {
136136
>
137137
Go to Editor
138138
</Button>
139-
<Button
140-
component="a"
141-
color="#202842"
142-
href="https://todiagram.com/editor?utm_source=jsoncrack.com&utm_medium=cta&utm_campaign=hero"
143-
target="_blank"
144-
size="md"
145-
variant="light"
146-
radius="md"
147-
fw="500"
148-
>
149-
Try Premium for Free
150-
</Button>
151139
</Flex>
152140
<Flex gap="lg" wrap="wrap" justify="center" visibleFrom="xs">
153141
<Button
@@ -161,18 +149,6 @@ export const HeroSection = () => {
161149
>
162150
Go to Editor
163151
</Button>
164-
<Button
165-
component="a"
166-
color="#202842"
167-
href="https://todiagram.com/editor?utm_source=jsoncrack.com&utm_medium=cta&utm_campaign=hero"
168-
target="_blank"
169-
size="lg"
170-
variant="light"
171-
radius="md"
172-
fw="500"
173-
>
174-
Try Premium for Free
175-
</Button>
176152
</Flex>
177153
</Stack>
178154
</StyledHeroSectionBody>

src/pages/editor.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import { useEffect } from "react";
22
import dynamic from "next/dynamic";
33
import { useRouter } from "next/router";
44
import { useMantineColorScheme } from "@mantine/core";
@@ -7,6 +7,7 @@ import styled, { ThemeProvider } from "styled-components";
77
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
88
import { Allotment } from "allotment";
99
import "allotment/dist/style.css";
10+
import Cookie from "js-cookie";
1011
import { NextSeo } from "next-seo";
1112
import { SEO } from "src/constants/seo";
1213
import { darkTheme, lightTheme } from "src/constants/theme";
@@ -16,6 +17,7 @@ import { Toolbar } from "src/features/editor/Toolbar";
1617
import useGraph from "src/features/editor/views/GraphView/stores/useGraph";
1718
import useConfig from "src/store/useConfig";
1819
import useFile from "src/store/useFile";
20+
import useModal from "src/store/useModal";
1921

2022
const ModalController = dynamic(() => import("src/features/modals/ModalController"));
2123
const ExternalMode = dynamic(() => import("src/features/editor/ExternalMode"));
@@ -69,12 +71,18 @@ const EditorPage = () => {
6971
const checkEditorSession = useFile(state => state.checkEditorSession);
7072
const darkmodeEnabled = useConfig(state => state.darkmodeEnabled);
7173
const fullscreen = useGraph(state => state.fullscreen);
74+
const setVisible = useModal(state => state.setVisible);
7275

73-
React.useEffect(() => {
76+
useEffect(() => {
77+
const isUpgradeShown = Cookie.get("upgrade_shown");
78+
if (!isUpgradeShown) setVisible("UpgradeModal", true);
79+
}, [setVisible]);
80+
81+
useEffect(() => {
7482
if (isReady) checkEditorSession(query?.json);
7583
}, [checkEditorSession, isReady, query]);
7684

77-
React.useEffect(() => {
85+
useEffect(() => {
7886
setColorScheme(darkmodeEnabled ? "dark" : "light");
7987
}, [darkmodeEnabled, setColorScheme]);
8088

0 commit comments

Comments
 (0)