NIFI-16009 refactor theming#11322
Conversation
|
Will review... |
rfellows
left a comment
There was a problem hiding this comment.
Thanks for tackling this — the core direction (kill the centralized @include registry + the redundant .darkMode double-emit, co-locate styles with components) is clearly right, and I verified the redundancy and code-splitting arguments hold up. A few inline notes below, plus two things that don't have a natural code anchor:
Missing .cursor/rules/ng-deep.mdc. The PR description says this file is added, but git show --name-only doesn't list it. The same criteria are in themes/README.md, but if the intent was a standalone rule file for AI agents to pick up automatically, it looks like it didn't make the commit.
Pre-existing bug worth fixing while you're in the file — apps/nifi/src/app/ui/common/status-history/status-history.component.scss lines 104–106:
:host ::ng-deep #status-history-chart-container text,
#status-history-chart-control-container text { ... }Angular's view-encapsulation processor only applies the :host ::ng-deep prefix to the first selector in a comma-separated list. The second selector gets compiled with attribute scoping (#status-history-chart-control-container[_ngcontent-xxx] text[_ngcontent-xxx]) and never matches the D3-created <text> elements, so the control chart's labels silently don't pick up the intended font. One-line fix: repeat :host ::ng-deep in front of the second selector.
| NiFi's `canvas.component.scss` and `birdseye.component.scss` only contain structural layout rules | ||
| inside `::ng-deep`. Colors use `--mat-sys-*` and `--nf-*` CSS custom properties that already | ||
| resolve correctly for both light and dark mode. No `.darkMode` block is needed inside `::ng-deep` | ||
| for these components. |
There was a problem hiding this comment.
Heads up: apps/nifi/src/app/ui/common/canvas/canvas.component.scss and apps/nifi/src/app/ui/common/birdseye/birdseye.component.scss (the new shared replacements introduced by NIFI-15951 and consumed by connector-canvas) still use the old @mixin styles(); @mixin generate-theme(); :host ::ng-deep { @include styles(); @include generate-theme(); .darkMode { @include generate-theme(); } } pattern — including the redundant double-include for .darkMode. They weren't touched by this PR.
That means the pattern this PR is "removing" actually still ships in the codebase, just relocated. Ideally these get migrated alongside the legacy pages/flow-designer/... versions you already moved. If you'd rather defer it, please mention the exception in the PR description and add a note here so the next maintainer doesn't think the pattern is fully gone.
There was a problem hiding this comment.
Both files cleaned up — redundant .darkMode double-call removed, comments updated to explain why it's not needed.
| // Shadows should always be darker. We explicitly set this so the SVG shadows are correct in both modes. | ||
| $drop-shadow-color: black; | ||
|
|
||
| :host ::ng-deep svg.canvas-svg { |
There was a problem hiding this comment.
Cosmetic: this is a second :host ::ng-deep svg.canvas-svg { … } block — there's already one at line 46. Now that they're co-located in the same file, worth merging into a single block. Easier to scan and avoids the impression that they have different scoping intent.
Summary
NIFI-16009
Refactor frontend theming to eliminate the centralized
*component-theme.scss+ global mixinregistration pattern, replacing it with per-component style ownership and a single
material.scssorchestrator.Background
The NiFi Angular frontend themes components through a two-part pattern: a
_*.component-theme.scssfile alongside each component containing agenerate-theme()mixin,and an
html {}block in each app'sstyles.scssthat@uses every theme file and@includesevery mixin. This pattern has two structural problems.
Redundancy. Angular Material v15+ (MDC) expresses all theming through CSS custom properties
(
--mat-sys-*,--nf-*). These cascade to all descendants automatically and already rebind fordark mode in
material.scss. There is no scenario in which calling@include canvas.generate-theme()insidehtml {}produces a different result than those samestyles placed in
canvas.component.scss. Thestyles.scssmixin registry was emitting the sameCSS twice — once for light mode, and again redundantly for dark mode via a double-call pattern.
Scalability. Bundling all component styles into the eager
styles.scssbundle preventsAngular's code-splitting from delivering component styles alongside their lazy-loaded feature
modules.
What Changed
Shared library (
libs/shared/src/assets/)styles/directory (_app.scss,_listing-table.scss,_prism-theme.scss,_tailwind-theme.scss)themes/material.scssabsorbs structural resets and semantic color utilities from the former_app.scss, becoming the sole eager global orchestratorthemes/components/_table.scss(new) — merged from_listing-table.scss; all@extenddirectives converted to inline CSS custom properties (
@extendcannot cross Sass moduleboundaries)
themes/components/_prism-theme.scss(new) — moved fromstyles/themes/_tailwind-theme.scss(new) — moved fromstyles/themes/purple.scssdeleted (unused alternative theme)themes/README.mdupdated to document the new architecture and::ng-deepdecision criteriaApps
_*.component-theme.scssfiles deleted acrossapps/nifi,apps/nifi-jolt-transform-ui,apps/standard-content-viewer, andapps/update-attribute;each component's styles migrated into its own
*.component.scssstyles.scssin all four apps reduced from 80–105 lines with 20+ component registrationsto ~30 lines: Tailwind, flowfont,
material.scss, Font Awesome — nohtml {}block, nocomponent mixin calls
connector-canvas.component.scsscreated (component previously lacked a stylesheet);styleUrladded toconnector-canvas.component.ts::ng-deepauditAll migrated styles that target DOM not created by Angular's template compiler use
:host ::ng-deepwith an inline comment explaining why. Styles targeting template-definedelements (Angular Material host elements, CDK directive classes, Material density mixins that
emit CSS custom properties) do not use
::ng-deep.Frontend (manual testing — no automated SCSS tests exist)
Run each app in development mode and verify light mode and dark mode:
apps/nifiand spacing
apps/nifi-jolt-transform-uiapps/standard-content-viewerapps/update-attributeIssue Tracking
Pull Request Tracking
NIFI-16009NIFI-16009VerifiedstatusPull Request Formatting
mainbranchVerification
Please indicate the verification steps performed prior to pull request creation.
Build
./mvnw clean install -P contrib-checkLicensing
LICENSEandNOTICEfilesDocumentation