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: improve search

AykutSarac29bb4cad5c14
diff --git a/src/constants/theme.ts b/src/constants/theme.ts
index dd0b235b..bd1e01f8 100644
--- a/src/constants/theme.ts
+++ b/src/constants/theme.ts
@@ -17,21 +17,6 @@ const fixedColors = {
TEXT_DANGER: "#db662e",
};
-const promptInputColors = {
- dark: {
- PROMPT_BG: "#072719",
- PROMPT_PLACEHOLDER_COLOR: "#15593A",
- PROMPT_TEXT_COLOR: "#3DCF8E",
- PROMPT_BORDER_COLOR: "#0C3924",
- },
- light: {
- PROMPT_BG: "#d3ede1",
- PROMPT_PLACEHOLDER_COLOR: "#77c2a1",
- PROMPT_TEXT_COLOR: "#289b67",
- PROMPT_BORDER_COLOR: "#8ad7b3",
- },
-};
-
const nodeColors = {
dark: {
NODE_COLORS: {
@@ -72,7 +57,6 @@ const nodeColors = {
export const darkTheme = {
...fixedColors,
...nodeColors.dark,
- ...promptInputColors.dark,
BLACK_SECONDARY: "#23272A",
SILVER_DARK: "#4D4D4D",
NODE_KEY: "#FAA81A",
@@ -99,7 +83,6 @@ export const darkTheme = {
export const lightTheme = {
...fixedColors,
...nodeColors.light,
- ...promptInputColors.light,
BLACK_SECONDARY: "#F2F2F2",
SILVER_DARK: "#CCCCCC",
NODE_KEY: "#DC3790",
diff --git a/src/features/editor/Toolbar/SearchInput.tsx b/src/features/editor/Toolbar/SearchInput.tsx
index 8cbbe389..054fb8eb 100644
--- a/src/features/editor/Toolbar/SearchInput.tsx
+++ b/src/features/editor/Toolbar/SearchInput.tsx
@@ -1,5 +1,5 @@
import React from "react";
-import { Box, Flex, Text, TextInput } from "@mantine/core";
+import { Flex, Text, TextInput } from "@mantine/core";
import { getHotkeyHandler } from "@mantine/hooks";
import { AiOutlineSearch } from "react-icons/ai";
import { useFocusNode } from "../../../hooks/useFocusNode";
@@ -8,38 +8,29 @@ export const SearchInput = () => {
const [searchValue, setValue, skip, nodeCount, currentNode] = useFocusNode();
return (
- <Box
- style={{
- position: "absolute",
- bottom: "10px",
- left: "10px",
- zIndex: 100,
- }}
- >
- <TextInput
- variant="unstyled"
- type="search"
- size="xs"
- id="search-node"
- w={180}
- value={searchValue}
- onChange={e => setValue(e.currentTarget.value)}
- placeholder="Search Node"
- autoComplete="off"
- autoCorrect="off"
- onKeyDown={getHotkeyHandler([["Enter", skip]])}
- leftSection={<AiOutlineSearch />}
- rightSection={
- searchValue && (
- <Flex h={30} align="center">
- <Text size="xs" c="dimmed" pr="md">
- {searchValue && `${nodeCount}/${nodeCount > 0 ? currentNode + 1 : "0"}`}
- </Text>
- </Flex>
- )
- }
- style={{ borderBottom: "1px solid gray" }}
- />
- </Box>
+ <TextInput
+ variant="unstyled"
+ type="search"
+ size="xs"
+ id="search-node"
+ w={180}
+ value={searchValue}
+ onChange={e => setValue(e.currentTarget.value)}
+ placeholder="Search Node"
+ autoComplete="off"
+ autoCorrect="off"
+ onKeyDown={getHotkeyHandler([["Enter", skip]])}
+ leftSection={<AiOutlineSearch />}
+ rightSection={
+ searchValue && (
+ <Flex h={30} align="center">
+ <Text size="xs" c="dimmed" pr="md">
+ {searchValue && `${nodeCount}/${nodeCount > 0 ? currentNode + 1 : "0"}`}
+ </Text>
+ </Flex>
+ )
+ }
+ style={{ borderBottom: "1px solid gray" }}
+ />
);
};
diff --git a/src/features/editor/views/GraphView/CustomNode/styles.tsx b/src/features/editor/views/GraphView/CustomNode/styles.tsx
index 882e385b..d4a012b6 100644
--- a/src/features/editor/views/GraphView/CustomNode/styles.tsx
+++ b/src/features/editor/views/GraphView/CustomNode/styles.tsx
@@ -49,7 +49,7 @@ export const StyledForeignObject = styled.foreignObject<{ $isObject?: boolean }>
}
.highlight {
- background: rgba(255, 214, 0, 0.3);
+ background: rgba(255, 214, 0, 0.15);
}
.renderVisible {
@@ -95,6 +95,10 @@ export const StyledRow = styled.span<{ $value: string }>`
&:last-of-type {
border-bottom: none;
}
+
+ .searched & {
+ border-bottom: 1px solid ${({ theme }) => theme.TEXT_POSITIVE};
+ }
`;
export const StyledChildrenCount = styled.span`
diff --git a/src/features/editor/views/GraphView/ZoomControl.tsx b/src/features/editor/views/GraphView/ZoomControl.tsx
index 1e88aeca..ed985208 100644
--- a/src/features/editor/views/GraphView/ZoomControl.tsx
+++ b/src/features/editor/views/GraphView/ZoomControl.tsx
@@ -3,9 +3,10 @@ import { ActionIcon, Flex } from "@mantine/core";
import { useHotkeys } from "@mantine/hooks";
import { event as gaEvent } from "nextjs-google-analytics";
import { LuFocus, LuMaximize, LuMinus, LuPlus } from "react-icons/lu";
+import { SearchInput } from "../../Toolbar/SearchInput";
import useGraph from "./stores/useGraph";
-export const ZoomControl = () => {
+export const ZoomControl = ({ isWidget = false }) => {
const zoomIn = useGraph(state => state.zoomIn);
const zoomOut = useGraph(state => state.zoomOut);
const centerView = useGraph(state => state.centerView);
@@ -27,7 +28,7 @@ export const ZoomControl = () => {
style={{
position: "absolute",
bottom: "10px",
- right: "10px",
+ left: "10px",
alignItems: "start",
zIndex: 100,
}}
@@ -78,6 +79,7 @@ export const ZoomControl = () => {
<LuPlus />
</ActionIcon>
</ActionIcon.Group>
+ {!isWidget && <SearchInput />}
</Flex>
);
};
diff --git a/src/features/editor/views/GraphView/index.tsx b/src/features/editor/views/GraphView/index.tsx
index 2a90b542..33b749ce 100644
--- a/src/features/editor/views/GraphView/index.tsx
+++ b/src/features/editor/views/GraphView/index.tsx
@@ -8,11 +8,11 @@ import type { ElkRoot } from "reaflow/dist/layout/useLayout";
import { useLongPress } from "use-long-press";
import useToggleHide from "../../../../hooks/useToggleHide";
import useConfig from "../../../../store/useConfig";
-import { SearchInput } from "../../Toolbar/SearchInput";
import { CustomEdge } from "./CustomEdge";
import { CustomNode } from "./CustomNode";
import { NotSupported } from "./NotSupported";
import { OptionsMenu } from "./OptionsMenu";
+import { SecureInfo } from "./SecureInfo";
import { ZoomControl } from "./ZoomControl";
import useGraph from "./stores/useGraph";
@@ -174,8 +174,8 @@ export const GraphView = ({ isWidget = false }: GraphProps) => {
<>
<LoadingOverlay visible={loading} />
{!isWidget && <OptionsMenu />}
- {!isWidget && <SearchInput />}
- <ZoomControl />
+ {!isWidget && <SecureInfo />}
+ <ZoomControl isWidget={isWidget} />
<StyledEditorWrapper
$widget={isWidget}
onContextMenu={e => e.preventDefault()}