Skip to content

Display board variant in the BOM header - #574

Merged
qu1ck merged 3 commits into
openscopeproject:masterfrom
tytelmaier:feat/display-board-variant
Oct 2, 2026
Merged

qu1ck merged 3 commits into
openscopeproject:masterfrom
tytelmaier:feat/display-board-variant

Conversation

@tytelmaier

@tytelmaier tytelmaier commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

The patch and additional test checks were developed with AI assistance. I tested the resulting plugin on my board using KiCad 10.0.6.

KiCad native variants are already exported as pcbdata.metadata.variant, but the generated iBOM page does not display that value. This change adds Variant: <name> beside the board title and revision, making it possible to identify which variant a generated BOM represents without relying on its filename.

For example, an export for SPI_no_INT_pull_up displays Variant: SPI_no_INT_pull_up. The label describes the variant recorded at generation time; it does not switch variants or track subsequent changes in KiCad.

The implementation changes three frontend files:

  • InteractiveHtmlBom/web/ibom.html: adds Variant as an initially hidden third <td class="title"> in the existing metadata table, alongside the board title and revision, and moves the title/revision column widths into CSS.
  • InteractiveHtmlBom/web/ibom.css: reuses the existing table-cell typography and ellipsis styling for Variant. When Variant is visible, a fixed table layout distributes the title, revision, and variant across three equal-width columns. During window-width changes, the variant label behaves the same way as the board name and revision: it stays on the same metadata row and truncates with an ellipsis (...) when space is limited, rather than wrapping to a second row. As the window widens, more of the text becomes visible again. When the variant is hidden, the original title/revision layout is retained.
  • InteractiveHtmlBom/web/ibom.js: populates the label from the optional metadata field, sets its full text as a hover tooltip, and toggles its visibility and layout. It uses textContent so special characters in variant names are displayed literally. Repeated metadata population also clears stale text and layout state when the field becomes unavailable.

Display behavior depends on the exported data, without requiring ECAD-specific logic in the browser:

Exported metadata.variant Display
Nonempty string Variant: <exact name>
Empty string Variant: Default
Missing property Hidden; original header layout retained
null or another non-string value Hidden defensively

For older KiCad versions without native variants, the current KiCad parser normally exports an empty string from the default configuration, so the label reads Variant: Default. Older data that omits the field renders without the label. The change introduces no new KiCad API calls or version requirements; the existing capability checks in the parser remain unchanged. Default is the display fallback for an empty value, not an indication that the installed KiCad version supports native variants.

Other supported ECAD inputs retain their existing behavior:

  • Eagle / Autodesk Fusion: the current parser includes a selected variant in the board title and does not emit a separate metadata.variant field. That title remains unchanged, and the new label stays hidden, avoiding duplicate variant information.
  • EasyEDA: the parser's generated metadata omits the variant field, so the label stays hidden. If supplied metadata includes a string variant, the shared display rules above apply.
  • Generic JSON and integrations using that format: the schema already allows an optional string metadata.variant. Inputs that provide it receive the label; inputs that omit it keep the original header. No schema changes or additional required fields are introduced.

This is a display-only change. Parsers, component selection, DNP filtering, legacy field-based variant filters, and BOM generation are unchanged. Existing standalone HTML exports must be regenerated to include the new header.

Validation covered named, default, missing, invalid, long, Unicode, and HTML-like variant values in headless Edge; matching revision typography; full-text tooltips; both themes; all three BOM layouts; header collapse/expand; print visibility; and repeated metadata population. At widths from 375 to 2564 pixels, the variant stays on the metadata row and truncates without adding horizontal overflow or overlapping the toolbar. Missing-field header geometry matches the original committed frontend.

Fresh examples were generated from STK8321_devboard.kicad_pcb using installed KiCad 10, with --kicad-variant SPI_no_INT_pull_up and --dnp-field kicad_dnp. Browser checks verified that the named variant contains only C1, C2, J1, R1, and U1, with R2-R8 skipped and absent from the displayed BOM. Tracks were excluded from these examples to keep verification independent of the separate via-rendering work.

JavaScript syntax and whitespace checks passed. Older KiCad and other ECAD applications were not executed directly: their compatibility was assessed through parser/schema inspection and frontend checks with the corresponding optional or missing metadata shapes.

Examples:
What was before:

before

Named variant:

named

Missing variant:

missing

Default variant:

default

Variant name behavior with Unicode, quotes, and HTML-like text display:

special

Variant long name:

long

Header behavior with narrow layout:

narrow

@qu1ck

qu1ck commented Sep 28, 2026

Copy link
Copy Markdown
Member

I don't like how inefficiently the space is used in your last screenshot. Especially since with new kicad there will always be variant: default, which has 0 useful information if you don't have any other variant, which is majority of cases.

I think if we want to cram more info into the header block it should have some sort of dynamic layout: use more rows, maybe shrink the fonts when window is so narrow, utilize unused space for missing fields like company.

@tytelmaier

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback. KiCad's <Default> selection is the base configuration rather than a named variant: it uses each component's DNP property without applying variant-specific DNP overrides. I agree that showing Variant: Default adds little information and that the header needs to use its available space better. I've reworked the changes to address both points:

  • Only named variants are shown. Empty, whitespace-only, missing or invalid metadata.variant values hide the label. A variant explicitly named Default is still displayed. The current metadata cannot distinguish a default-only board from the default selection on a board with multiple variants, so both empty cases are hidden.
  • The metadata layout adapts to its available width. Board name/company, revision/date and variant form three groups. They use equal columns on wide headers, then rearrange into two columns and finally one as space narrows. Company remains beneath the board name, and date beneath revision.
  • Long names truncate before forcing a layout change. Board name, revision and variant use an ellipsis, with their full text available on hover. The column layout depends on available space rather than the length of a particular variant name.
  • Empty fields collapse. An empty company field does not reserve a separate line, and entirely empty groups are removed from the layout. Populated company and date fields remain visible.
  • Headings become slightly smaller in compact layouts. Board name, revision and variant reduce together from 20pt to 18pt when the metadata area is at most 52rem wide. This follows the space available to the metadata, rather than the whole window. Company and date keep their existing font size.
  • The toolbar can move below the metadata. When it no longer fits beside the header information, it moves onto its own row and is centered.

These are frontend changes only; parsing, BOM generation and DNP filtering are unchanged. Older KiCad and other ECAD inputs without variant information do not gain a variant label. The responsive layout also applies to their existing metadata.

I regenerated the examples from the STK8321 project and checked the header at 12 viewport widths, including long names, missing metadata, both themes and the different BOM layouts. The named-variant example still correctly excludes R2-R8. Browser checks were run in Edge; compatibility with older KiCad and other ECAD inputs was checked using metadata fixtures.

The screenshots below show the layout as the viewport width decreases. Each image is cropped to the header and the top of the BOM; the stated width is the browser viewport width.

2560px viewport (2560 x 1440 monitor): three columns with the full variant name visible.

company-2560

1850px viewport: three columns, with a long variant name truncated.

company-1850

1280px viewport: variant on the next row, with company and date beneath their headings.

company-1280

900px viewport: metadata stacked while the toolbar still fits beside it.

company-900

600px viewport: toolbar below the metadata.

company-600

@qu1ck
qu1ck merged commit 5114701 into openscopeproject:master Oct 2, 2026
2 checks passed
@qu1ck

qu1ck commented Oct 2, 2026

Copy link
Copy Markdown
Member

This is much better, thanks!

qu1ck pushed a commit that referenced this pull request Oct 7, 2026
Since #574 the BOM header shows the variant from pcbdata.metadata.variant,
and the %v/%V name format substitutions read the same key. The Eagle and
Fusion parser never set it and instead appended ", Variant: X" to the
title, so the variant header stayed hidden, the title got truncated and
%V always produced "default". Put the current variant into
metadata.variant like the KiCad parser does and keep the title as the
file name.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants