From 132a16503c3c813dbd28b58c286ebb02bfd2d802 Mon Sep 17 00:00:00 2001
From: "Thomas F. K. Jorna" <thomasfkjorna@gmail.com>
Date: Sat, 7 Aug 2021 14:29:01 +0200
Subject: feat: configurable label size and length

---
 pages/index.tsx | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

(limited to 'pages/index.tsx')

diff --git a/pages/index.tsx b/pages/index.tsx
index 75efbfa..d3d6a44 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -950,9 +950,12 @@ export const Graph = forwardRef(function (props: GraphProps, graphRef: any) {
       }
 
       const nodeTitle = (node as OrgRoamNode).title!
-      const label = nodeTitle.substring(0, Math.min(nodeTitle.length, 40))
+      const label =
+        nodeTitle.length > visuals.labelLength
+          ? nodeTitle.substring(0, visuals.labelLength) + '...'
+          : nodeTitle
       // const label = 'label'
-      const fontSize = 14 / (0.75 * Math.min(Math.max(0.5, globalScale), 3))
+      const fontSize = visuals.labelFontSize / (0.75 * Math.min(Math.max(0.5, globalScale), 3))
       const textWidth = ctx.measureText(label).width
       const bckgDimensions = [textWidth * 1.1, fontSize].map((n) => n + fontSize * 0.5) as [
         number,
-- 
cgit v1.2.3

