Просмотр исходного кода

fix(rack): cables render via DOM-measured overlay, thicker cabled-port stroke

The cable overlay measured port rects with a selector that matched nothing (data-mount lives on the mount wrapper, not the port button), so cables never rendered. Ports are now located via their own data-port attribute plus the closest data-mount ancestor, and cabled ports get a thicker stroke so the whole port reads as occupied.
Nacho 2 месяцев назад
Родитель
Сommit
e6193eb9b0
2 измененных файлов с 5 добавлено и 3 удалено
  1. 1 1
      app/src/components/rack/Faceplate.tsx
  2. 4 2
      app/src/pages/Rack.tsx

+ 1 - 1
app/src/components/rack/Faceplate.tsx

@@ -127,7 +127,7 @@ export function Faceplate({
               {sfp ? (
                 <span className="block rounded-[1px] bg-current" style={{ width: 18, height: 6 }} aria-hidden />
               ) : (
-                <EthernetPort size={16} strokeWidth={2} aria-hidden />
+                <EthernetPort size={16} strokeWidth={st.cabled || st.drafting ? 3 : 2} aria-hidden />
               )}
             </button>
           )

+ 4 - 2
app/src/pages/Rack.tsx

@@ -176,9 +176,11 @@ function RackCanvas() {
     if (!layer) return
     const base = layer.getBoundingClientRect()
     const out: Record<string, { x: number; y: number }> = {}
-    for (const btn of layer.parentElement?.querySelectorAll('button[data-mount][data-port]') ?? []) {
+    for (const btn of layer.parentElement?.querySelectorAll('button[data-port]') ?? []) {
+      const mountId = (btn.closest('[data-mount]') as HTMLElement | null)?.getAttribute('data-mount')
+      if (!mountId) continue
       const r = (btn as HTMLElement).getBoundingClientRect()
-      out[`${btn.getAttribute('data-mount')}|${btn.getAttribute('data-port')}`] = {
+      out[`${mountId}|${btn.getAttribute('data-port')}`] = {
         x: r.x + r.width / 2 - base.x,
         y: r.y + r.height / 2 - base.y,
       }