✨ Innovative and open-source visualization application that transforms various data formats, such as JSON, YAML, XML and CSV into interactive graphs.
refactor: simplify highlight and cleanupHighlight functions, update CSS for searched and highlighted states
AykutSaracc98031a5237a
diff --git a/apps/www/src/lib/utils/search.ts b/apps/www/src/lib/utils/search.tsindex 58f54c71..88c3f055 100644--- a/apps/www/src/lib/utils/search.ts+++ b/apps/www/src/lib/utils/search.ts@@ -3,18 +3,15 @@ export const searchQuery = (param: string) => {};export const cleanupHighlight = () => {- const nodes = document.querySelectorAll("foreignObject.searched, .highlight");+ const nodes = document.querySelectorAll(".searched, .highlight");for (let i = 0; i < nodes.length; i++) {- const node = nodes[i];- node.classList.remove("searched", "highlight");+ nodes[i].classList.remove("searched", "highlight");}};export const highlightMatchedNodes = (nodes: NodeListOf<Element>, selectedNode: number) => {for (let i = 0; i < nodes.length; i++) {- const node = nodes[i];- const foreignObject = node.parentElement?.closest("foreignObject");- if (foreignObject) foreignObject.classList.add("searched");+ nodes[i].classList.add("searched");}nodes[selectedNode].classList.add("highlight");diff --git a/packages/jsoncrack-react/src/components/Node.module.css b/packages/jsoncrack-react/src/components/Node.module.cssindex 41705fba..aa50cb9d 100644--- a/packages/jsoncrack-react/src/components/Node.module.css+++ b/packages/jsoncrack-react/src/components/Node.module.css@@ -82,17 +82,14 @@padding: 0 10px;}-.foreignObject:global(.searched) {- background: rgba(27, 255, 0, 0.1);- border: 1px solid var(--text-positive);- border-radius: 2px;- box-sizing: border-box;-}--.foreignObject :global(.highlight) {- background: rgba(255, 214, 0, 0.15);+.row:global(.searched),+.textNodeWrapper:global(.searched) {+ background: rgba(34, 197, 94, 0.18);+ box-shadow: inset 3px 0 0 rgba(34, 197, 94, 0.6);}-.foreignObject:global(.searched) .row {- border-bottom: 1px solid var(--text-positive);+.row:global(.highlight),+.textNodeWrapper:global(.highlight) {+ background: rgba(22, 163, 74, 0.55);+ box-shadow: inset 3px 0 0 #15803d;}