✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.
fix: ui errors
AykutSaracc609c59371cf
diff --git a/src/components/MonacoEditor/index.tsx b/src/components/MonacoEditor/index.tsxindex 2287ae93..f4b427dd 100644--- a/src/components/MonacoEditor/index.tsx+++ b/src/components/MonacoEditor/index.tsx@@ -21,7 +21,7 @@ const editorOptions = {const StyledWrapper = styled.div`display: grid;- height: calc(100vh - 63px);+ height: calc(100vh - 67px);grid-template-columns: 100%;grid-template-rows: minmax(0, 1fr);`;diff --git a/src/components/PromptInput/index.tsx b/src/components/PromptInput/index.tsxnew file mode 100644index 00000000..d16bdeb8--- /dev/null+++ b/src/components/PromptInput/index.tsx@@ -0,0 +1,124 @@+import React from "react";+import { ActionIcon, TextInput, Loader, Tooltip } from "@mantine/core";+import { getHotkeyHandler } from "@mantine/hooks";+import styled from "styled-components";+import { toast } from "react-hot-toast";+import { GoDependabot } from "react-icons/go";+import { VscClose, VscQuestion } from "react-icons/vsc";+import useJsonQuery from "src/hooks/useJsonQuery";+import { supabase } from "src/lib/api/supabase";+import useUser from "src/store/useUser";++function removeWhitespaces(inputString: string) {+ // Remove extra whitespaces and newlines+ const compactString = inputString.replace(/\s+/g, "").replaceAll("interface", "interface ");+ return compactString;+}++const StyledPromptInput = styled(TextInput)`+ .mantine-Input-input {+ font-weight: 500;+ background: ${({ theme }) => theme.PROMPT_BG};+ color: ${({ theme }) => theme.PROMPT_TEXT_COLOR};+ border: none;+ border-bottom: 1px solid ${({ theme }) => theme.PROMPT_BORDER_COLOR};++ :focus-within {+ border-color: #15593a;+ }+ }++ svg {+ color: ${({ theme }) => theme.PROMPT_TEXT_COLOR};+ }++ ::placeholder {+ color: ${({ theme }) => theme.PROMPT_PLACEHOLDER_COLOR};+ }+`;++export const PromptInput = () => {+ const { updateJson, getJsonType } = useJsonQuery();+ const premium = useUser(state => state.premium);+ const [completing, setCompleting] = React.useState(false);+ const [prompt, setPrompt] = React.useState("");+ const [promptVisible, setPromptVisible] = React.useState(true);++ const onSubmit = async () => {+ try {+ setCompleting(true);++ const resp = await supabase.functions.invoke("jq", {+ body: {+ query: prompt,+ jsonModel: removeWhitespaces(getJsonType()),+ },+ });++ // extract jq command+ const jqOutput = resp.data.choices[0].message?.content || "";+ const regex = /'([^']*)'/;+ const match = jqOutput.match(regex);++ if (match && match[1]) {+ const extractedString = match[1];+ updateJson(extractedString);+ } else {+ throw Error("An error occured while parsing result.");+ }+ } catch (error) {+ toast.error("An error occured while parsing result.");+ } finally {+ setCompleting(false);+ }+ };++ if (!promptVisible) return null;++ return (+ <Tooltip.Floating+ disabled={premium}+ label="JSON Crack AI is currently only available to premium users"+ fz="xs"+ withinPortal+ >+ <div>+ <StyledPromptInput+ placeholder="Ask JSON Crack AI to transform the data"+ value={prompt}+ onChange={e => setPrompt(e.currentTarget.value)}+ rightSectionWidth={60}+ maxLength={200}+ disabled={!premium || completing}+ onKeyDown={getHotkeyHandler([["Enter", onSubmit]])}+ onSubmit={onSubmit}+ rightSection={+ <>+ <Tooltip+ label="This feature is in the experimental phase, and its outcomes may not consistently reflect accuracy. It solely utilizes the schema without incorporating values, hence your actions should align with your particular schema. Please note that we do not store your data."+ maw={300}+ multiline+ withinPortal+ fz="xs"+ withArrow+ >+ <ActionIcon variant="transparent">+ <VscQuestion />+ </ActionIcon>+ </Tooltip>+ <ActionIcon+ variant="transparent"+ title="Close"+ onClick={() => setPromptVisible(false)}+ >+ <VscClose />+ </ActionIcon>+ </>+ }+ leftSection={completing ? <Loader size="xs" /> : <GoDependabot strokeWidth={1} />}+ radius={0}+ />+ </div>+ </Tooltip.Floating>+ );+};diff --git a/src/containers/Editor/JsonEditor.tsx b/src/containers/Editor/JsonEditor.tsxindex ac2e0fec..da0778f1 100644--- a/src/containers/Editor/JsonEditor.tsx+++ b/src/containers/Editor/JsonEditor.tsx@@ -1,14 +1,8 @@import React from "react";-import { ActionIcon, TextInput, Loader, Tooltip } from "@mantine/core";-import { getHotkeyHandler, useSessionStorage } from "@mantine/hooks";import styled from "styled-components";-import { toast } from "react-hot-toast";-import { GoDependabot } from "react-icons/go";-import { VscClose, VscQuestion } from "react-icons/vsc";import { MonacoEditor } from "src/components/MonacoEditor";-import useJsonQuery from "src/hooks/useJsonQuery";-import { supabase } from "src/lib/api/supabase";-import useUser from "src/store/useUser";++// import { PromptInput } from "src/components/PromptInput";const StyledEditorWrapper = styled.div`display: flex;@@ -17,109 +11,6 @@ const StyledEditorWrapper = styled.div`user-select: none;`;-function removeWhitespaces(inputString: string) {- // Remove extra whitespaces and newlines- const compactString = inputString.replace(/\s+/g, "").replaceAll("interface", "interface ");- return compactString;-}--const StyledPromptInput = styled(TextInput)`- .mantine-Input-input {- font-weight: 500;- background: ${({ theme }) => theme.PROMPT_BG};- color: ${({ theme }) => theme.PROMPT_TEXT_COLOR};- border: none;- border-bottom: 1px solid ${({ theme }) => theme.PROMPT_BORDER_COLOR};-- :focus-within {- border-color: #15593a;- }- }-- svg {- color: ${({ theme }) => theme.PROMPT_TEXT_COLOR};- }-- ::placeholder {- color: ${({ theme }) => theme.PROMPT_PLACEHOLDER_COLOR};- }-`;--const PromptInput = () => {- const { updateJson, getJsonType } = useJsonQuery();- const premium = useUser(state => state.premium);- const [completing, setCompleting] = React.useState(false);- const [prompt, setPrompt] = React.useState("");- const [promptVisible, setPromptVisible] = useSessionStorage({- key: "promptVisible",- defaultValue: true,- });-- const onSubmit = async () => {- try {- setCompleting(true);-- const resp = await supabase.functions.invoke("jq", {- body: {- query: prompt,- jsonModel: removeWhitespaces(getJsonType()),- },- });-- updateJson(resp.data.choices[0].message?.content || "");- } catch (error) {- toast.error("An error occured while parsing result.");- } finally {- setCompleting(false);- }- };-- if (!promptVisible) return null;-- return (- <Tooltip.Floating- disabled={premium}- label="JSON Crack AI is currently only available to premium users"- fz="xs"- withinPortal- >- <div>- <StyledPromptInput- placeholder="Ask JSON Crack AI to transform the data"- value={prompt}- onChange={e => setPrompt(e.currentTarget.value)}- rightSectionWidth={60}- maxLength={200}- disabled={!premium || completing}- onKeyDown={getHotkeyHandler([["Enter", onSubmit]])}- onSubmit={onSubmit}- rightSection={- <>- <Tooltip- label="This feature is in the experimental phase, and its outcomes may not consistently reflect accuracy. It solely utilizes the schema without incorporating values, hence your actions should align with your particular schema. Please note that we do not store your data."- maw={300}- multiline- withinPortal- fz="xs"- withArrow- >- <ActionIcon>- <VscQuestion />- </ActionIcon>- </Tooltip>- <ActionIcon title="Close" onClick={() => setPromptVisible(false)}>- <VscClose />- </ActionIcon>- </>- }- leftSection={completing ? <Loader size="xs" /> : <GoDependabot strokeWidth={1} />}- radius={0}- />- </div>- </Tooltip.Floating>- );-};-export const JsonEditor: React.FC = () => {return (<StyledEditorWrapper>diff --git a/src/containers/Editor/Panes.tsx b/src/containers/Editor/Panes.tsxindex 408415b0..201e20f2 100644--- a/src/containers/Editor/Panes.tsx+++ b/src/containers/Editor/Panes.tsx@@ -9,7 +9,7 @@ export const StyledEditor = styled(Allotment)`position: relative !important;display: flex;background: ${({ theme }) => theme.BACKGROUND_SECONDARY};- height: calc(100vh - 63px);+ height: calc(100vh - 67px);@media only screen and (max-width: 320px) {height: 100vh;diff --git a/src/containers/Modals/JQModal/index.tsx b/src/containers/Modals/JQModal/index.tsxindex 74e83329..c8cb32c1 100644--- a/src/containers/Modals/JQModal/index.tsx+++ b/src/containers/Modals/JQModal/index.tsx@@ -1,14 +1,11 @@import React from "react";-import { Stack, Modal, Button, ModalProps, Text, Anchor, Group } from "@mantine/core";-import Editor from "@monaco-editor/react";+import { Stack, Modal, Button, ModalProps, Text, Anchor, Group, TextInput } from "@mantine/core";import { VscLinkExternal } from "react-icons/vsc";import useJsonQuery from "src/hooks/useJsonQuery";-import useConfig from "src/store/useConfig";export const JQModal: React.FC<ModalProps> = ({ opened, onClose }) => {const { updateJson } = useJsonQuery();const [query, setQuery] = React.useState("");- const darkmodeEnabled = useConfig(state => (state.darkmodeEnabled ? "vs-dark" : "light"));const onApply = () => {updateJson(query);@@ -21,23 +18,15 @@ export const JQModal: React.FC<ModalProps> = ({ opened, onClose }) => {jq is a lightweight and flexible command-line JSON processor. JSON Crack uses simplifiedversion of jq, not all features are supported.<br />- <Anchor target="_blank" href="https://jqlang.github.io/jq/manual/">+ <Anchor fz="sm" target="_blank" href="https://jqlang.github.io/jq/manual/">Read documentation. <VscLinkExternal /></Anchor></Text>- <Editor- value={query ?? ""}- theme={darkmodeEnabled}- onChange={e => setQuery(e!)}- height={300}- language="markdown"- options={{- formatOnPaste: true,- formatOnType: true,- minimap: {- enabled: false,- },- }}+ <TextInput+ leftSection="jq"+ placeholder="Enter jq query"+ value={query}+ onChange={e => setQuery(e.currentTarget.value)}/><Group justify="right"><Button onClick={onApply}>Display on Graph</Button>diff --git a/src/containers/Views/GraphView/index.tsx b/src/containers/Views/GraphView/index.tsxindex 1fb181fe..6bbcd861 100644--- a/src/containers/Views/GraphView/index.tsx+++ b/src/containers/Views/GraphView/index.tsx@@ -28,7 +28,7 @@ interface GraphProps {const StyledEditorWrapper = styled.div<{ $widget: boolean; $showRulers: boolean }>`position: absolute;width: 100%;- height: ${({ $widget }) => ($widget ? "calc(100vh - 36px)" : "calc(100vh - 63px)")};+ height: ${({ $widget }) => ($widget ? "calc(100vh - 40px)" : "calc(100vh - 67px)")};--bg-color: ${({ theme }) => theme.GRID_BG_COLOR};--line-color-1: ${({ theme }) => theme.GRID_COLOR_PRIMARY};@@ -68,7 +68,7 @@ const StyledEditorWrapper = styled.div<{ $widget: boolean; $showRulers: boolean}@media only screen and (max-width: 768px) {- height: ${({ $widget }) => ($widget ? "calc(100vh - 36px)" : "100vh")};+ height: ${({ $widget }) => ($widget ? "calc(100vh - 40px)" : "100vh")};}@media only screen and (max-width: 320px) {