Skip to content

Add the styles/content.css entry point to the add-on styles loader (#199 A2) - #204

Open
sneridagh wants to merge 3 commits into
a1-css-layer-orderfrom
a2-content-css-entry-point
Open

sneridagh wants to merge 3 commits into
a1-css-layer-orderfrom
a2-content-css-entry-point

Conversation

@sneridagh

Copy link
Copy Markdown
Member

Step A2 of #199: a styles/content.css entry point in the add-on styles loader, so add-ons write block styles once and get them in both the Public UI and the CMSUI.

Stacked on #203 (A1). The base is a1-css-layer-order. Retarget to main once #203 is merged. This PR's own change is only the last commit.

Changes

  • @plone/registry (create-addons-styles-loader.ts):
    • New generated file: .plone/content.css aggregates every add-on's styles/content.css, in add-on order. It emits no Tailwind @source lines, because content CSS is plain CSS by contract.

    • Imported by both UIs: the generated .plone/publicui.css and .plone/cmsui.css now start with:

      @import './content.css' layer(plone-content);
    • Exports: buildContentLoaderCode, plus CONTENT_STYLESHEET and CONTENT_LAYER constants. styles/publicui.css and styles/cmsui.css work exactly as before.

  • Tests: a new __tests__/create-addons-styles-loader.test.js. Until now the styles loader had no tests. It covers:
    • no add-on shipping content styles;
    • several add-ons, in add-on order;
    • no @source lines in content.css, even for add-ons that use Tailwind;
    • both UI loaders importing content.css first, in plone-content;
    • @source still emitted for Tailwind add-ons in the UI loaders;
    • all three files written to .plone/.
  • Docs (docs/conceptual-guides/add-on-styles-loader.md): a "Content styles" section covering:
    • the convention and the layer order;
    • the base-layer convention for theme resets;
    • the authoring rules;
    • "Override block styles from an add-on", with examples and a warning about the @layer-inside-content.css trap.

No add-on ships a styles/content.css yet. A3 adds the first ones, so this PR changes no rendered CSS: the content import is an empty file.

Verified end to end

I built the app with temporary marker rules in @plone/plate/styles/content.css (:where(.a2-marker)) and @plone/agave/styles/content.css (.a2-marker). Both built bundles then contain:

@layer plone-content{:where(.a2-marker){color:#010203}.a2-marker{color:#040506}}

So both UIs get the content styles, in the plone-content layer, with the plate rule before the Agave rule. Tailwind v4 and Vite handle @import … layer() in the generated files, which settles the risk noted in #199. The markers aren't committed.

Validation

  • pnpm --filter @plone/registry test --run: 125 passed, 7 of them new.
  • pnpm --filter @plone/registry check:ts and build: clean.
  • pnpm --filter @plone/aurora build: clean, with and without add-on content styles.
  • pnpm --filter @plone/registry check:exports fails, but with the same node10 resolution and CJS/ESM warnings on every subpath export of the package. That looks pre-existing and unrelated to this change.
  • Vale couldn't run locally (its styles aren't installed in this checkout), so the docs check is left to CI.

Part of #199.

Step A2 of #199. Every add-on's styles/content.css is aggregated into a
generated .plone/content.css, which both the Public UI and the CMSUI
loaders import first, inside the plone-content cascade layer. Add-ons
write block styles once and get them in both user interfaces. Documents
the convention, its authoring rules and how to override block styles.
* a1-css-layer-order:
  Fix the server not loading translations, which broke hydration (#207)
* a1-css-layer-order:
  Move the table drag handle fragment to @plone/quanta
  Releasing @plone/aurora 1.0.0-alpha.16
  Release @plone/contents 1.0.0-alpha.3
  Release @plone/publicui 1.0.0-alpha.8
  Release @plone/cmsui 1.0.0-alpha.11
  Release @plone/agave 1.0.0-alpha.8
  Release @plone/theming 1.0.0-alpha.8
  Release @plone/layout 1.0.0-alpha.13
  Release @plone/blocks 1.0.0-alpha.17
  Release @plone/plate 1.0.0-alpha.22
  Release @plone/react-router 2.0.0-alpha.7
  Release @plone/helpers 2.0.0-alpha.9
  Release @plone/registry 4.0.0-alpha.4
  Release @plone/quanta 1.0.0-alpha.1
  Release @plone/components 5.0.0-alpha.5
  Release @plone/client 2.0.0-alpha.8
  Release @plone/icons 1.0.0-alpha.1
  Release @plone/types 3.0.0-alpha.7
  Split Quanta and icons out of @plone/components into @plone/quanta and @plone/icons (#212)

This branch has not been deployed

No deployments
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