add filter icons

This commit is contained in:
codetypes committed 2024-04-26 23:22:52 +08:00
1 parent 78925c4ae5
commit 0cbbde3820
4 files changed
+96 -63

No files matched your search

+1
View File
@@ -42,6 +42,7 @@
"saveAs": "Save As...",
"saveAsSubtree": "Save As Subtree",
"searchFile": "Search File",
"searchNode": "Search Node",
"services": "Services",
"start": "Start",
"undo": "Undo",
+1
View File
@@ -42,6 +42,7 @@
"saveAs": "另存为...",
"saveAsSubtree": "另存为子树",
"searchFile": "搜索文件",
"searchNode": "搜索节点",
"services": "服务",
"start": "开始",
"undo": "撤销",
+90 -60
View File
@@ -21,6 +21,9 @@ import React, { FC, useCallback, useEffect, useMemo, useRef, useState } from "re
import { useTranslation } from "react-i18next";
import { FiDelete } from "react-icons/fi";
import { IoMdReturnLeft } from "react-icons/io";
import { PiCubeFocus } from "react-icons/pi";
import { RiFocus3Fill, RiFocus3Line } from "react-icons/ri";
import { VscCaseSensitive } from "react-icons/vsc";
import { mergeRefs } from "react-merge-refs";
import { useDebounceCallback } from "usehooks-ts";
import "./register-node";
@@ -1002,69 +1005,96 @@ export const Editor: FC<EditorProps> = ({ onUpdate: updateState, data: editor, .
<Flex
style={{
position: "absolute",
marginTop: "10px",
marginLeft: "10px",
backgroundColor: "#161b22",
padding: "4px 10px 4px 10px",
borderRadius: "4px",
borderLeft: "4px solid #f78166",
boxShadow: "0 0 8px 2px #0000005c",
alignItems: "center",
width: "100%",
justifyContent: "end",
paddingRight: "10px",
paddingTop: "10px",
}}
>
<Input
autoFocus
allowClear
size="small"
style={{ borderRadius: "2px" }}
onChange={(e) => onSearchChange(e.currentTarget.value)}
/>
<div style={{ padding: "0 10px 0 5px" }}>
{results.length ? `${resultIndex + 1}/${results.length}` : ""}
</div>
<Button
icon={<ArrowDownOutlined />}
type="text"
size="small"
style={{ width: "30px" }}
disabled={results.length == 0}
onClick={() => {
if (results.length > 0) {
const idx = (resultIndex + 1) % results.length;
setResultIndex(idx);
editor.graph.focusItem(results[idx]);
selectNode(results[idx]);
<Flex
style={{
backgroundColor: "#161b22",
padding: "4px 10px 4px 10px",
borderRadius: "4px",
borderLeft: "3px solid #f78166",
boxShadow: "0 0 8px 2px #0000005c",
alignItems: "center",
}}
>
<Input
autoFocus
size="small"
style={{
borderRadius: "2px",
paddingTop: "1px",
paddingBottom: "1px",
paddingRight: "2px",
}}
onChange={(e) => onSearchChange(e.currentTarget.value)}
suffix={
<Flex style={{ alignItems: "center" }}>
<Button
type="text"
size="small"
style={{ width: "20px", height: "20px" }}
icon={<VscCaseSensitive style={{ width: "18px", height: "18px" }} />}
/>
<Button
type="text"
size="small"
style={{ width: "20px", height: "20px" }}
icon={<RiFocus3Line />}
/>
</Flex>
}
}}
/>
<Button
icon={<ArrowUpOutlined />}
type="text"
size="small"
style={{ width: "30px" }}
disabled={results.length == 0}
onClick={() => {
if (results.length > 0) {
const idx = (resultIndex + results.length - 1) % results.length;
setResultIndex(idx);
console.log(idx, results[idx]);
editor.graph.focusItem(results[idx]);
selectNode(results[idx]);
}
}}
/>
<Button
icon={<CloseOutlined />}
type="text"
size="small"
style={{ width: "30px" }}
onClick={() => {
setShowingSearch(false);
setResults([]);
setResultIndex(0);
keysRef.current?.focus();
}}
/>
/>
<div style={{ padding: "0 10px 0 5px", minWidth: "40px" }}>
{results.length ? `${resultIndex + 1}/${results.length}` : ""}
</div>
<Button
icon={<ArrowDownOutlined />}
type="text"
size="small"
style={{ width: "30px" }}
disabled={results.length == 0}
onClick={() => {
if (results.length > 0) {
const idx = (resultIndex + 1) % results.length;
setResultIndex(idx);
editor.graph.focusItem(results[idx]);
selectNode(results[idx]);
}
}}
/>
<Button
icon={<ArrowUpOutlined />}
type="text"
size="small"
style={{ width: "30px" }}
disabled={results.length == 0}
onClick={() => {
if (results.length > 0) {
const idx = (resultIndex + results.length - 1) % results.length;
setResultIndex(idx);
console.log(idx, results[idx]);
editor.graph.focusItem(results[idx]);
selectNode(results[idx]);
}
}}
/>
<Button
icon={<CloseOutlined />}
type="text"
size="small"
style={{ width: "30px" }}
onClick={() => {
setShowingSearch(false);
setResults([]);
setResultIndex(0);
keysRef.current?.focus();
}}
/>
</Flex>
</Flex>
)}
+4 -3
View File
@@ -7,9 +7,9 @@ import { app } from "@electron/remote";
import { Button, Flex, Layout, Space, Tabs, Tag, Tooltip } from "antd";
import { FC, useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { BiAddToQueue } from "react-icons/bi";
import { FaExclamationTriangle, FaRegFolderOpen } from "react-icons/fa";
import { PiTreeStructureFill } from "react-icons/pi";
import { VscNewFolder, VscRepo } from "react-icons/vsc";
import useForceUpdate from "use-force-update";
import { useWindowSize } from "usehooks-ts";
import { Editor } from "./editor";
@@ -275,7 +275,7 @@ export const Workspace: FC = () => {
}}
onClick={() => workspace.createProject()}
>
<BiAddToQueue size="20px" />
<VscNewFolder size="20px" />
{t("createProject")}
</Flex>
<Flex
@@ -289,7 +289,7 @@ export const Workspace: FC = () => {
}}
onClick={() => workspace.openProject()}
>
<FaRegFolderOpen size="19px" />
<VscRepo size="19px" />
{t("openProject")}
</Flex>
</Flex>
@@ -337,6 +337,7 @@ export const Workspace: FC = () => {
{[
{ label: t("searchFile"), hotkeys: isMacos ? "⌘ P" : "Ctrl + P" },
{ label: t("build"), hotkeys: isMacos ? "⌘ B" : "Ctrl + B" },
{ label: t("searchNode"), hotkeys: isMacos ? "⌘ F" : "Ctrl + F" },
{ label: t("insertNode"), hotkeys: "Enter" },
{ label: t("deleteNode"), hotkeys: "Backspace" },
].map((v) => (