Move layer-wrapper out of gauge SDC, add gauge-popover library - #25
Conversation
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
left a comment
There was a problem hiding this comment.
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-wrapperand.vcs-popover .analyze--gauge. - SDC prop types are unchanged;
valueremains typed asnumberingauge.component.yml. - The
{% embed %}inanalyze-gauge.html.twigpasses all eight required props from the theme variables.
Nits
components/gauge/gauge.twigandtemplates/analyze-gauge.html.twigboth lack a trailing newline (pre-existing, not introduced by this PR, but easy to fix while editing).
jjroelofs
left a comment
There was a problem hiding this comment.
Re-review (round 2)
Verdict: No blockers remaining. Previous medium finding is resolved by downstream context; new commit is correct.
Previous findings
-
Medium (library never attached / CSS duplication): Resolved. The
gauge-popoverlibrary is designed to be attached by downstream consumers viahook_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#attachedarrays. The CSS is complementary, not duplicated:scale_popover.cssdefines the popover container;gauge-popover.cssadjusts the gauge inside it.One residual note (low):
gauge-popover.csstargets.vcs-popover, a class owned byviews_color_scales. If that class name changes upstream, this CSS breaks silently. Acceptable for co-maintained modules; just worth knowing. -
Nit (missing trailing newlines): Still present. Both
components/gauge/gauge.twigandtemplates/analyze-gauge.html.twigend without a final newline (\ No newline at end of filein 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.
…-wrapper-out-of-gauge-sdc
|
All review findings addressed. LGTM. |
Summary
layer-wrapper gin-layer-wrapperdiv out of theanalyze:gaugeSDC into theanalyze-gauge.html.twigtheme template, so the SDC is a pure reusable component without Gin-specific markupanalyze.libraries.ymlwith agauge-popoverlibrary providing CSS overrides (overflow, padding) for rendering the gauge inside theviews_color_scalespopover containerTest plan