Skip to content

1613: Section Color: render One column through the shared layout organism - #512

Open
dblanken-yale wants to merge 1 commit into
1616-section-color-parityfrom
1613-block-contrast-section-backgrounds
Open

1613: Section Color: render One column through the shared layout organism#512
dblanken-yale wants to merge 1 commit into
1616-section-color-parityfrom
1613-block-contrast-section-backgrounds

Conversation

@dblanken-yale

Copy link
Copy Markdown
Contributor

1613: Section Color: Audit block contrast against the new One column / 70-30 section backgrounds

Description of work

Based on 1616-section-color-parity, not develop.

This branch exists for two reasons, and the first one is the fix for the blocking finding on
yalesites-org/yalesites-project#1514.

Why the One column background did not render on the multidev

The review found that a One column section with a Component Theme rendered as a bare
<div class="layout layout--onecol"> on the PR multidev, while the 70/30 section on the same page
worked. Neither of the suspected causes was it: the theme value is saved through the editor
form, and it does reach the template.

yalesites_profile/composer.json pins yalesites-org/atomic: 1.82.0, and the One column theme
wiring exists only on the 1616-section-color-parity branch of this repo — the released tags do
not have it:

$ git show v1.83.0:templates/layouts/layout--onecol.html.twig | grep -c yds-layout
0

A Pantheon multidev only swaps in companion branches whose name matches the pushed branch, and
this repo had no 1613-block-contrast-section-backgrounds branch, so the multidev built against
released atomic 1.82.0, whose onecol template emits no section markup at all. That also explains
the part of the evidence that pointed away from the real cause: both CSS rules the review found
are present, because .layout--onecol.yds-layout ships from ys_layouts (on the PR branch) and
.yds-layout[data-component-theme] has been in this theme's dist for a long time. CSS present
plus template absent is exactly the released-atomic combination.

So: this branch existing is the fix. It is an integration gap, not a code bug.

The change itself

layout--onecol.html.twig now embeds @organisms/layout/layout with
component__layout: 'one-column' rather than adopting the yds-layout class and
data-component-theme attribute by hand, so all four Layout Builder sections emit one signature
from one template:

<div class="yds-layout layout layout--onecol" data-component-theme="one"
     data-component-layout="one-column" data-component-padding="default"
     data-component-has-divider="false" data-component-width="site">

layout--onecol is passed through as an extra class because core's stylesheets and both of the
page's margin rules (.main-content > *:first-child in page-layouts.scss,
.main-content .layout.layout--onecol:last-of-type in this theme's layout-builder.css) select on
it.

What changes for an unthemed section. It now carries data-component-theme="default" where it
previously carried no section markup at all. That was the main risk and it was checked rather than
assumed: everything --color-layout-border feeds — the CTA atom's fill, the divider atom, tabs,
pull-quote — is already guarded on
[data-component-theme]:not([data-component-theme='default']), so an unthemed section picks up
none of it. Two supporting changes live in the companion PRs: _yds-layout.scss excludes
one-column from the default-theme section-margin rule, and onecol.css scopes its vertical
padding to a themed section now that yds-layout is no longer a themed-only signal.

The "render nothing for an unthemed empty section" guard is deliberately unchanged. The post,
event and page default displays each ship a trailing empty one-column Content Section, so rendering
those would hand :last-of-type to an empty wrapper and drop the pre-footer margin on every node
using them.

Functional testing steps:

  1. Check out 1613-block-contrast-section-backgrounds in this repo, component-library-twig and
    yalesites-project (all based on 1616-section-color-parity).
  2. npm run build in component-library-twig, then lando drush cr.
  3. lando drush php:script scripts/local/1613-section-contrast-fixture.php
  4. Visit /1613-one-column-section-backgrounds and confirm all six backgrounds paint, and that
    each section's markup carries both data-component-theme and
    data-component-layout="one-column".
  5. Visit any ordinary page and confirm an unthemed One column section is visually unchanged and now
    reports data-component-theme="default".
  6. Test the editor path specifically, per the review: add a One column section through Layout
    Builder, set a Component Theme, save, and confirm it paints.

Verification performed

  • One column measured in Drupal across all six section themes; every one paints, with a correctly
    inverted foreground: one rgb(0,54,107), two rgb(247,247,247), three rgb(33,33,33), four
    rgb(39,107,190), five rgb(217,217,217), six rgb(97,168,255).
  • Unthemed pages confirmed rendering data-component-theme="default" data-component-layout="one-column".
  • Storybook confirms single-region rendering: yds-layout layout, one-column, no __inner, no
    __primary, no __secondary, 0 dividers.
  • Screenshots (Drupal and Storybook) are committed in
    1613: Section Color: Audit block contrast against the new One column / 70-30 section backgrounds component-library-twig#707 under
    components/03-organisms/layout/layout/screenshots/.

References yalesites-org/YaleSites-Internal#1613

layout--onecol.html.twig now embeds @organisms/layout/layout with
component__layout: 'one-column' instead of hand-rolling the yds-layout class
and the data-component-theme attribute itself, so all four section layouts
emit one signature from one template. layout--onecol is passed through as an
extra class because core's stylesheets and both of the page's margin rules
select on it.

Because it always renders through the organism now, an unthemed section
carries data-component-theme="default" where it previously carried no section
markup at all. Two rules depend on that and are noted in the template:
_yds-layout.scss excludes one-column from the default-theme section-margin
rule, and ys_layouts/layouts/onecol/onecol.css scopes its vertical padding to
a themed section, since yds-layout is no longer a themed-only signal.

The "render nothing for an unthemed empty section" guard is unchanged. The
post, event and page default displays each ship a trailing empty one-column
Content Section, so rendering those would hand :last-of-type to an empty
wrapper and drop the pre-footer margin on every node using them.
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.

1 participant