Skip to content

Conversation

@Quanta-Naut
Copy link

I have added layer visibility toggling feature, where one can enable/disable the view of the available layer in the 3d viewer.
Below is the attached video of the working.

Screen.Recording.2025-10-15.150206.mp4

/claim #523
fixes #523

@vercel
Copy link

vercel bot commented Oct 15, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
3d-viewer Ready Ready Preview Comment Oct 16, 2025 2:28pm

@Quanta-Naut
Copy link
Author

@ShiboSoftwareDev @imrishabh18 Do Check it out, Thanks.

Co-authored-by: graphite-app[bot] <96075541+graphite-app[bot]@users.noreply.github.com>
Comment on lines 45 to 47
left: (submenuRef.current && window.innerWidth < position.x + submenuRef.current.offsetWidth + 220)
? position.x - submenuRef.current?.offsetWidth
: position.x + 220,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a reference to submenuRef.current in the positioning logic, but this variable isn't defined in this component. Since this component uses forwardRef, the correct reference to use is the ref parameter that's passed to the component.

The positioning code should be updated to:

left: (ref.current && window.innerWidth < position.x + ref.current.offsetWidth + 220) 
  ? position.x - ref.current?.offsetWidth 
  : position.x + 220,

This will ensure the submenu is properly positioned based on available screen space.

Suggested change
left: (submenuRef.current && window.innerWidth < position.x + submenuRef.current.offsetWidth + 220)
? position.x - submenuRef.current?.offsetWidth
: position.x + 220,
left: (ref.current && window.innerWidth < position.x + ref.current.offsetWidth + 220)
? position.x - ref.current?.offsetWidth
: position.x + 220,

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Copy link
Member

@imrishabh18 imrishabh18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's incorrect smtPad or the via is not a kicad layer

Comment on lines 1 to 143
import React, { forwardRef } from "react"

export type LayerVisibility = {
board: boolean
platedHoles: boolean
smtPads: boolean
vias: boolean
copperPours: boolean
topTrace: boolean
bottomTrace: boolean
topSilkscreen: boolean
bottomSilkscreen: boolean
cadComponents: boolean
}

interface LayerVisibilitySubmenuProps {
layerVisibility: LayerVisibility
presentLayers: Partial<LayerVisibility>
onToggleLayer: (layer: keyof LayerVisibility) => void
onShowAllLayers: () => void
position: { x: number; y: number }
}

export const LayerVisibilitySubmenu = forwardRef<
HTMLDivElement,
LayerVisibilitySubmenuProps
>(
(
{
layerVisibility,
presentLayers,
onToggleLayer,
onShowAllLayers,
position,
},
ref,
) => {
const submenuWidth = 200
const left =
position.x + 220 > window.innerWidth - submenuWidth
? position.x - submenuWidth - 20
: position.x + 220

return (
<div
ref={ref}
style={{
position: "fixed",
top: position.y,
left,
background: "#23272f",
color: "#f5f6fa",
borderRadius: 6,
boxShadow: "0 6px 24px 0 rgba(0,0,0,0.18)",
zIndex: 1001,
minWidth: 180,
border: "1px solid #353945",
padding: 0,
fontSize: 14,
fontWeight: 500,
}}
>
<div
style={{
padding: "12px 18px 8px 18px",
fontSize: 12,
opacity: 0.7,
fontWeight: 500,
color: "#c0c0c0",
borderBottom: "1px solid rgba(255, 255, 255, 0.1)",
marginBottom: "4px",
}}
>
Layer Visibility
</div>
<div
style={{
padding: "8px 18px",
cursor: "pointer",
display: "flex",
alignItems: "center",
gap: 10,
color: "#4ade80",
fontWeight: 500,
fontSize: 14,
borderRadius: 6,
transition: "background 0.1s",
}}
onClick={onShowAllLayers}
onMouseOver={(e) => (e.currentTarget.style.background = "#2d313a")}
onMouseOut={(e) => (e.currentTarget.style.background = "transparent")}
>
Show All Layers
</div>
{Object.entries(layerVisibility)
.filter(([layer]) => presentLayers[layer as keyof LayerVisibility])
.map(([layer, visible]) => (
<div
key={layer}
style={{
padding: "8px 18px",
cursor: "pointer",
display: "flex",
alignItems: "center",
gap: 10,
color: "#f5f6fa",
fontWeight: 400,
fontSize: 14,
borderRadius: 6,
transition: "background 0.1s",
}}
onClick={() => onToggleLayer(layer as keyof LayerVisibility)}
onMouseOver={(e) =>
(e.currentTarget.style.background = "#2d313a")
}
onMouseOut={(e) =>
(e.currentTarget.style.background = "transparent")
}
>
<span style={{ marginRight: 8 }}>{visible ? "✔" : ""}</span>
{layer === "cadComponents"
? "CAD Components"
: layer === "platedHoles"
? "Plated Holes"
: layer === "smtPads"
? "SMT Pads"
: layer === "copperPours"
? "Copper Pours"
: layer === "topTrace"
? "Top Traces"
: layer === "bottomTrace"
? "Bottom Traces"
: layer === "topSilkscreen"
? "Top Silkscreen"
: layer === "bottomSilkscreen"
? "Bottom Silkscreen"
: layer.charAt(0).toUpperCase() + layer.slice(1)}
</div>
))}
</div>
)
},
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file name LayerVisibilitySubmenu.tsx does not follow the project's naming convention. Based on the stated rule "Generally kebab-case", this file should be renamed to layer-visibility-submenu.tsx to maintain consistency with the project's file naming standards.

Spotted by Graphite Agent (based on custom rule: Custom rule)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

@Quanta-Naut
Copy link
Author

@seveibar I had PR the solution earlier.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow configuring viewable layers / objects

2 participants