From 72d9c18d84c76061fa4a9f09848ad8a761c8ce18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E5=88=BA=E8=9E=88?= Date: Sun, 10 Nov 2024 14:26:55 +0800 Subject: [PATCH] refactor: introduce getNodeStyle function for consistent node styling across cards --- src/utils/node.ts | 11 ++++++++++- src/views/snapshot/OverlapCard.vue | 6 ++---- src/views/snapshot/RuleCard.vue | 6 ++---- src/views/snapshot/SearchCard.vue | 18 ++++++++---------- src/views/snapshot/WindowCard.vue | 8 ++++---- 5 files changed, 26 insertions(+), 23 deletions(-) diff --git a/src/utils/node.ts b/src/utils/node.ts index 9e6a4de..956272f 100644 --- a/src/utils/node.ts +++ b/src/utils/node.ts @@ -146,7 +146,6 @@ const getLabelSuffix = (node: RawNode) => { return node.attr.text || node.attr.desc || node.attr.vid || node.attr.id; }; const labelKey = Symbol(`labelKey`); -const labelLimit = 20; export const getNodeLabel = (node: RawNode): string => { if (Reflect.has(node, labelKey)) { return Reflect.get(node, labelKey); @@ -231,3 +230,13 @@ export const isRawNode = (node: any): node is RawNode => { } return false; }; + +export const getNodeStyle = (node: RawNode, focusNode?: RawNode) => { + const qf = Boolean(node.idQf || node.textQf || node.quickFind); + const fontWeight = qf ? 'bold' : undefined; + const color = node.id === focusNode?.id ? '#00F' : undefined; + return { + fontWeight, + color, + }; +}; diff --git a/src/views/snapshot/OverlapCard.vue b/src/views/snapshot/OverlapCard.vue index e9e2a92..9206ed8 100644 --- a/src/views/snapshot/OverlapCard.vue +++ b/src/views/snapshot/OverlapCard.vue @@ -1,6 +1,6 @@