Skip to content

Commit

Permalink
Merge branch 'AykutSarac:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
louyongjiu authored Apr 7, 2024
2 parents 1c9117d + f7e2535 commit d7bd08b
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 225 deletions.
182 changes: 0 additions & 182 deletions src/components/PromptInput/index.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions src/containers/Editor/JsonEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from "react";
import styled from "styled-components";
import { MonacoEditor } from "src/components/MonacoEditor";
import { PromptInput } from "src/components/PromptInput";

const StyledEditorWrapper = styled.div`
display: flex;
Expand All @@ -13,7 +12,6 @@ const StyledEditorWrapper = styled.div`
export const JsonEditor: React.FC = () => {
return (
<StyledEditorWrapper>
<PromptInput />
<MonacoEditor />
</StyledEditorWrapper>
);
Expand Down
10 changes: 2 additions & 8 deletions src/containers/Modals/SchemaModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,11 @@ import React from "react";
import { Stack, Modal, Button, ModalProps, Text, Anchor, Group, Divider } from "@mantine/core";
import Editor from "@monaco-editor/react";
import { toast } from "react-hot-toast";
import { VscLinkExternal, VscLock } from "react-icons/vsc";
import { VscLinkExternal } from "react-icons/vsc";
import useConfig from "src/store/useConfig";
import useFile from "src/store/useFile";
import useModal from "src/store/useModal";
import useUser from "src/store/useUser";

export const SchemaModal: React.FC<ModalProps> = ({ opened, onClose }) => {
const isPremium = useUser(state => state.premium);
const showPremiumModal = useModal(state => state.setVisible("premium"));
const setJsonSchema = useFile(state => state.setJsonSchema);
const [schema, setSchema] = React.useState(
JSON.stringify(
Expand All @@ -34,8 +30,6 @@ export const SchemaModal: React.FC<ModalProps> = ({ opened, onClose }) => {
const darkmodeEnabled = useConfig(state => (state.darkmodeEnabled ? "vs-dark" : "light"));

const onApply = () => {
if (!isPremium) return showPremiumModal(true);

try {
const parsedSchema = JSON.parse(schema);

Expand Down Expand Up @@ -80,7 +74,7 @@ export const SchemaModal: React.FC<ModalProps> = ({ opened, onClose }) => {
<Button variant="outline" onClick={onClear} disabled={!schema}>
Clear
</Button>
<Button onClick={onApply} disabled={!schema} rightSection={!isPremium && <VscLock />}>
<Button onClick={onApply} disabled={!schema}>
Apply
</Button>
</Group>
Expand Down
15 changes: 1 addition & 14 deletions src/containers/Toolbar/OptionsMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { Menu, Text, Flex, Badge } from "@mantine/core";
import { Menu, Text, Flex } from "@mantine/core";
import { BsCheck2 } from "react-icons/bs";
import { MdSettings } from "react-icons/md";
import useConfig from "src/store/useConfig";
Expand All @@ -12,15 +12,13 @@ export const OptionsMenu = () => {
const toggleRulers = useConfig(state => state.toggleRulers);
const toggleCollapseButton = useConfig(state => state.toggleCollapseButton);
const toggleImagePreview = useConfig(state => state.toggleImagePreview);
const toggleAI = useConfig(state => state.toggleAI);

const gesturesEnabled = useConfig(state => state.gesturesEnabled);
const childrenCountVisible = useConfig(state => state.childrenCountVisible);
const darkmodeEnabled = useConfig(state => state.darkmodeEnabled);
const rulersEnabled = useConfig(state => state.rulersEnabled);
const collapseButtonVisible = useConfig(state => state.collapseButtonVisible);
const imagePreviewEnabled = useConfig(state => state.imagePreviewEnabled);
const aiEnabled = useConfig(state => state.aiEnabled);

return (
<Menu shadow="md" trigger="click" closeOnItemClick={false} withArrow>
Expand Down Expand Up @@ -68,17 +66,6 @@ export const OptionsMenu = () => {
>
<Text size="xs">Dark Mode</Text>
</Menu.Item>
<Menu.Item
leftSection={<BsCheck2 opacity={aiEnabled ? 100 : 0} />}
onClick={() => toggleAI(!aiEnabled)}
>
<Flex align="center" gap={2}>
<Text size="xs">JSON Crack AI</Text>
<Badge ml={2} size="xs" variant="light" radius={2}>
Alpha
</Badge>
</Flex>
</Menu.Item>
</Menu.Dropdown>
</Menu>
);
Expand Down
16 changes: 0 additions & 16 deletions src/layout/EditorWrapper/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { lightTheme, darkTheme } from "src/constants/theme";
import useConfig from "src/store/useConfig";

const Toaster = dynamic(() => import("react-hot-toast").then(c => c.Toaster));
const ModalController = dynamic(() => import("src/layout/ModalController"));

const queryClient = new QueryClient({
Expand All @@ -25,21 +24,6 @@ export const EditorWrapper: React.FC<{

return (
<ThemeProvider theme={darkmodeEnabled ? darkTheme : lightTheme}>
<Toaster
position="bottom-right"
containerStyle={{
bottom: 34,
right: 8,
fontSize: 14,
}}
toastOptions={{
style: {
background: "#4D4D4D",
color: "#B9BBBE",
borderRadius: 4,
},
}}
/>
<MantineProvider forceColorScheme={darkmodeEnabled ? "dark" : "light"}>
<QueryClientProvider client={queryClient}>
<ModalController />
Expand Down
17 changes: 17 additions & 0 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { lightTheme } from "src/constants/theme";
import { supabase } from "src/lib/api/supabase";
import useUser from "src/store/useUser";

const Toaster = dynamic(() => import("react-hot-toast").then(c => c.Toaster));

const mantineTheme = createTheme({
primaryShade: 8,
});
Expand Down Expand Up @@ -54,6 +56,21 @@ function JsonCrack({ Component, pageProps }: AppProps) {

<MantineProvider theme={mantineTheme}>
<ThemeProvider theme={lightTheme}>
<Toaster
position="bottom-right"
containerStyle={{
bottom: 34,
right: 8,
fontSize: 14,
}}
toastOptions={{
style: {
background: "#4D4D4D",
color: "#B9BBBE",
borderRadius: 4,
},
}}
/>
<GlobalStyle />
<Component {...pageProps} />
<ExternalMode />
Expand Down
3 changes: 0 additions & 3 deletions src/store/useConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const initialStates = {
gesturesEnabled: false,
rulersEnabled: true,
viewMode: ViewMode.Graph,
aiEnabled: true,
};

export interface ConfigActions {
Expand All @@ -24,14 +23,12 @@ export interface ConfigActions {
toggleGestures: (value: boolean) => void;
toggleRulers: (value: boolean) => void;
setViewMode: (value: ViewMode) => void;
toggleAI: (value: boolean) => void;
}

const useConfig = create(
persist<typeof initialStates & ConfigActions>(
set => ({
...initialStates,
toggleAI: aiEnabled => set({ aiEnabled }),
toggleRulers: rulersEnabled => set({ rulersEnabled }),
toggleGestures: gesturesEnabled => set({ gesturesEnabled }),
toggleLiveTransform: liveTransformEnabled => set({ liveTransformEnabled }),
Expand Down

0 comments on commit d7bd08b

Please sign in to comment.