Skip to content

feat(themes): add theme inheritance and Canvas and Daybreak palettes - #8523

Open
somethingwithproof wants to merge 12 commits into
developfrom
feature/theme-token-skins
Open

somethingwithproof wants to merge 12 commits into
developfrom
feature/theme-token-skins

Conversation

@somethingwithproof

@somethingwithproof somethingwithproof commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

A theme can now name a parent in a parent file and ship only what differs. get_theme_paths() falls back to the parent's copy of any file the child does not provide, so nothing loads twice. The parent name must be a lowercase directory name with its own main.css, cannot be the theme itself, and only one level is followed. Each child still ships main.css, rrdtheme.php and index.php, so is_valid_theme() and cacti_validate_theme() are unchanged.

Canvas and Daybreak are the first children of Midwinter. Each one is a color and font token set with light and dark modes plus matching RRDtool colors, and inherits Midwinter's layout, scripts and graph fonts. Canvas follows GitHub Primer's functional colors (MIT, credited in its README), and Daybreak pairs a bright primary palette with a near-black dark mode and an amber accent.

Validation: every text and background pair in the new palettes meets 4.5:1. The new palette spec checks color scheme, body text contrast and font stacks for each theme in both modes, and runs in the theme correctness job; changed CSS line coverage is 97.9% locally. A new test loads every theme's rrdtheme.php and rejects invalid RRDtool colors. Inheritance tests cover child precedence, parent fallback and rejected parent names (2 of 9 fail against the old resolver). Ui Pest suite (287), PHPStan and PHP CS Fixer pass.

Bundled fonts follow in #8524. No 1.2.x backport.

Plugin authors: get_selected_theme() still returns the theme name alone, so a plugin that loads css/<theme>.css finds nothing for Canvas or Daybreak. Use get_theme_chain(), which returns the selected theme followed by its parent (for example ['canvas', 'midwinter']), and load the first stylesheet that exists:

foreach (get_theme_chain() as $theme) {
	if (file_exists($config['base_path'] . '/plugins/monitor/css/' . $theme . '.css')) {
		print get_md5_include_css('plugins/monitor/css/' . $theme . '.css');
		break;
	}
}

Inheritance is a single level, so the list holds at most two names. An invalid theme name returns an empty list. Monitor, Thold, MacTrack, QuickTree, IntroPage, ServCheck, Syslog, APCUPSD and HMIB ship a midwinter.css and need this change to style Canvas and Daybreak.

@somethingwithproof
somethingwithproof requested a review from a team as a code owner October 26, 2026 23:43
@somethingwithproof
somethingwithproof requested review from cigamit and removed request for a team October 26, 2026 23:43
somethingwithproof added a commit that referenced this pull request Oct 26, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
somethingwithproof added a commit that referenced this pull request Oct 27, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@somethingwithproof
somethingwithproof force-pushed the feature/theme-token-skins branch from 2fde2a9 to 2779f8f Compare October 27, 2026 00:08
@somethingwithproof somethingwithproof changed the title feat(themes): add theme inheritance and Basalt, Canvas and Daybreak palettes feat(themes): add theme inheritance and Canvas and Daybreak palettes Oct 27, 2026
somethingwithproof added a commit that referenced this pull request Nov 2, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@somethingwithproof
somethingwithproof force-pushed the feature/theme-token-skins branch from 2779f8f to 5d1661f Compare November 2, 2026 20:10
github-actions Bot pushed a commit that referenced this pull request Nov 3, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@github-actions
github-actions Bot force-pushed the feature/theme-token-skins branch from 5d1661f to cd550fe Compare November 3, 2026 20:46
github-actions Bot pushed a commit that referenced this pull request Nov 4, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@github-actions
github-actions Bot force-pushed the feature/theme-token-skins branch from cd550fe to ad46c4b Compare November 4, 2026 08:46
github-actions Bot pushed a commit that referenced this pull request Nov 4, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@github-actions
github-actions Bot force-pushed the feature/theme-token-skins branch from fb55350 to 6eebd25 Compare November 4, 2026 20:46
github-actions Bot pushed a commit that referenced this pull request Nov 5, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@github-actions
github-actions Bot force-pushed the feature/theme-token-skins branch from 6eebd25 to 8dfd5bb Compare November 5, 2026 08:45
github-actions Bot pushed a commit that referenced this pull request Nov 6, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@github-actions
github-actions Bot force-pushed the feature/theme-token-skins branch from 8dfd5bb to b67b597 Compare November 6, 2026 08:45
somethingwithproof added a commit that referenced this pull request Nov 9, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@somethingwithproof
somethingwithproof force-pushed the feature/theme-token-skins branch from 9783f4f to 98dfa0c Compare November 9, 2026 08:02
somethingwithproof added a commit that referenced this pull request Nov 12, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@somethingwithproof somethingwithproof added this to the v1.3.0 milestone Nov 13, 2026
@somethingwithproof somethingwithproof added enhancement General tag for an enhancement gui UI related issue labels Nov 13, 2026
github-actions Bot pushed a commit that referenced this pull request Nov 16, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@github-actions
github-actions Bot force-pushed the feature/theme-token-skins branch from a915fb6 to 631876d Compare November 16, 2026 08:58
github-actions Bot pushed a commit that referenced this pull request Nov 16, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@github-actions
github-actions Bot force-pushed the feature/theme-token-skins branch from 631876d to 23390e6 Compare November 16, 2026 20:49
@somethingwithproof somethingwithproof added the release:1.3 Namespaced Cacti workflow label label Nov 17, 2026
somethingwithproof added a commit that referenced this pull request Nov 17, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
somethingwithproof added a commit that referenced this pull request Nov 19, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
github-actions Bot pushed a commit that referenced this pull request Nov 19, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@github-actions
github-actions Bot force-pushed the feature/theme-token-skins branch from ccc4745 to 0cb8ed4 Compare November 19, 2026 20:50
somethingwithproof added a commit that referenced this pull request Nov 25, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
github-actions Bot pushed a commit that referenced this pull request Nov 25, 2026
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@github-actions
github-actions Bot force-pushed the feature/theme-token-skins branch from 5d022cd to ce54838 Compare November 25, 2026 20:49
A theme directory with a parent file now falls back to that parent for any file it does not ship, so a palette variant only needs its own colors, main.css and rrdtheme.php.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Each is a midwinter child that ships only its light and dark colors, fonts and graph colors, and includes the parent's rrdtheme.php for fonts and borders.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Loads each palette theme's real import chain and asserts its color scheme, body text contrast and font stacks, and runs in the theme correctness job so the new stylesheets count toward changed-line coverage.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Loads each rrdtheme.php in-process and requires rrdtool hex colors with matching keys across the base, light and dark sets, since a malformed value breaks every graph drawn in that theme.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Chromium reports no used range for an @import rule, so the canvas and
daybreak main.css imports could never be covered and held the changed CSS
lines at 97.9%, below the 100% gate the theme stack sets. An added
@import now counts when the same browser session loaded both the
importing file and the imported sheet.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Canvas and Daybreak import midwinter/main.css with its md5 as a cache
buster, and midwinter/update_hash.php never rewrites another theme's
imports. Any later change to the parent leaves browsers on the old
sheet without a failing check. The new test recomputes every import
hash and checks that main.css and rrdtheme.php load the theme named in
the parent file, which the READMEs now describe.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
The changed-code coverage job runs only its listed native fixtures and
browser specs. None of them loaded the Canvas or Daybreak stylesheets or
called the theme inheritance helpers, so every changed theme line and the
new lib/functions.php code read as uncovered, although the Pest and theme
specs assert them.

Add a ThemeInheritanceMatrix fixture that runs the checked-in
get_include_relpath(), get_theme_candidate_paths(), get_theme_parent()
and get_theme_paths() against a private theme tree, covering the child
copy, parent fallback, single-level, theme-root and invalid-parent cases,
and loads each palette theme's index.php and rrdtheme.php; a Pest test
runs the fixture so it cannot drift from the suite. Run the theme
correctness, cleanup and palette specs in the same job with
CACTI_THEME_COVERAGE set so they record stylesheet coverage.

Return the candidate paths on one line: Xdebug attributes a multi-line
array return to its elements, and the report counts the bare "return ["
line as an unexecuted statement.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Selectmenu and autocomplete paint the highlighted item with midwinter's
.ui-menu .ui-state-active rule, which puts --text-color-lighter on
--background-active-section. Canvas dark set that background to Primer's
#1F6FEB, leaving the item text at 4.26:1. Darken it to #1A65DB (4.91:1,
and 5.35:1 for the white text on selected navigation items) and test the
highlighted item in both dark palettes.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Plugins pick per-theme stylesheets by the exact name get_selected_theme()
returns, so Canvas and Daybreak users lose a plugin's midwinter.css.
get_theme_chain() returns the theme followed by its parent, for example
['canvas', 'midwinter'], reusing get_theme_parent(), so a plugin can try
each name in order.  get_selected_theme() is unchanged.  A theme name
that is not a plain directory name yields an empty list, since callers
build paths from it.

Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
Signed-off-by: Thomas Vincent <thomasvincent@gmail.com>
@github-actions
github-actions Bot force-pushed the feature/theme-token-skins branch from ce54838 to 5b508b7 Compare November 26, 2026 08:51
@sonarqubecloud

Copy link
Copy Markdown

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

enhancement General tag for an enhancement gui UI related issue release:1.3 Namespaced Cacti workflow label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant