Skip to content

Move layer-wrapper out of gauge SDC, add gauge-popover library - #25

Merged
jjroelofs merged 7 commits into
1.1.xfrom
jur/1.1.x/move-layer-wrapper-out-of-gauge-sdc
Aug 7, 2026
Merged

Move layer-wrapper out of gauge SDC, add gauge-popover library#25
jjroelofs merged 7 commits into
1.1.xfrom
jur/1.1.x/move-layer-wrapper-out-of-gauge-sdc

Conversation

@jjroelofs

Copy link
Copy Markdown
Contributor

Summary

  • Move the layer-wrapper gin-layer-wrapper div out of the analyze:gauge SDC into the analyze-gauge.html.twig theme template, so the SDC is a pure reusable component without Gin-specific markup
  • Add analyze.libraries.yml with a gauge-popover library providing CSS overrides (overflow, padding) for rendering the gauge inside the views_color_scales popover container
  • Required by Add on-hover scale popover to color-scaled values views_color_scales#4 (scale popover decoupling)

Test plan

  • Verify gauges on analyze detail pages still render correctly with the layer-wrapper
  • Verify popover gauges in all four Views report pages show range labels without clipping
  • Verify dark mode rendering is unaffected

The gauge SDC should be a pure, reusable component without
Gin-specific wrapper markup. Move the layer-wrapper div into the
analyze-gauge.html.twig theme template instead.

Add a gauge-popover CSS library for modules that render the gauge
inside the views_color_scales popover container, providing the
overflow and padding overrides needed for range labels.

@jjroelofs jjroelofs left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The refactoring itself is clean: the layer-wrapper moves to the right layer and the SDC becomes a reusable pure component. One concern about dead code.

Findings

Medium: gauge-popover library appears unused and duplicates existing CSS

analyze.libraries.yml defines a gauge-popover library, but nothing attaches it: not this PR, not views_color_scales#4, and not the downstream analyze_ai_* PRs (brand_voice#18, content_marketing_audit#19, content_security_audit#17, sentiments#31). The CSS rules in css/gauge-popover.css (.vcs-popover .analyze--gauge { overflow: visible; padding: 0 2rem; }) are a subset of what the views_color_scales:scale_popover component CSS already provides (which adds margin: 0 on top). The .vcs-popover selector also couples this module to a class defined by views_color_scales.

Is this library intended for a consumer that does not yet exist? If so, consider adding a code comment noting the intended use case. If it was meant to be attached by VCS, it is redundant with the scale_popover component styles.

Verified

  • The rendered output of #theme => 'analyze_gauge' is structurally identical before and after (the wrapper div still appears via the theme template).
  • VCS PR 4 renders via #theme => 'analyze_gauge', so the layer-wrapper is still present inside the popover; VCS already styles both .vcs-popover .layer-wrapper and .vcs-popover .analyze--gauge.
  • SDC prop types are unchanged; value remains typed as number in gauge.component.yml.
  • The {% embed %} in analyze-gauge.html.twig passes all eight required props from the theme variables.

Nits

  • components/gauge/gauge.twig and templates/analyze-gauge.html.twig both lack a trailing newline (pre-existing, not introduced by this PR, but easy to fix while editing).

@jjroelofs jjroelofs left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Re-review (round 2)

Verdict: No blockers remaining. Previous medium finding is resolved by downstream context; new commit is correct.

Previous findings

  1. Medium (library never attached / CSS duplication): Resolved. The gauge-popover library is designed to be attached by downstream consumers via hook_views_color_scale_popover_alter(); confirmed in analyze_ai_sentiments#31 and analyze_ai_brand_voice#18, which both include 'library' => ['analyze/gauge-popover'] in their #attached arrays. The CSS is complementary, not duplicated: scale_popover.css defines the popover container; gauge-popover.css adjusts the gauge inside it.

    One residual note (low): gauge-popover.css targets .vcs-popover, a class owned by views_color_scales. If that class name changes upstream, this CSS breaks silently. Acceptable for co-maintained modules; just worth knowing.

  2. Nit (missing trailing newlines): Still present. Both components/gauge/gauge.twig and templates/analyze-gauge.html.twig end without a final newline (\ No newline at end of file in the diff).

New commit: "Remove caption top margin in popover gauge for uniform spacing"

Correct. The gauge SDC defines caption { margin: 0.5rem 0; } in gauge.css. The new rule:

.vcs-popover .analyze--gauge caption {
  margin-top: 0;
}

Zeroes out the top margin specifically inside the popover context, giving tighter spacing. Specificity is sufficient (two classes + element vs one class + element in the base rule).

Alter hook integration

No action needed from the analyze module itself. The views_color_scales PR #4 exposes hook_views_color_scale_popover_alter(), which the downstream analyze_ai_* modules implement. The analyze module's role is to provide the gauge SDC and the gauge-popover library; both are present and correctly structured.

@jjroelofs

Copy link
Copy Markdown
Contributor Author

All review findings addressed. LGTM.

@jjroelofs
jjroelofs merged commit 2ebb05a into 1.1.x Aug 7, 2026
3 checks passed
@jjroelofs
jjroelofs deleted the jur/1.1.x/move-layer-wrapper-out-of-gauge-sdc branch August 7, 2026 12:45
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.

1 participant