For theming Plone 6.2, I am thinking about having a control panel for colors (etc) defined in CSS variables. Is there a way of finding all CSS variables used on a site?
Probably, I need to use tinycss2 which seem to do a good job of extracting (and splitting them), but I need a way to 'find all used CSS-files on the site'. Is there any way to do that from a view (.py) ?
Rather than crawling rendered pages, enumerate the registered CSS resources/bundles via Plone’s resource registry from the view and feed each CSS file’s text to tinycss2. That gives you declared variables in registered theme CSS, but not inline blocks or variables injected at runtime. For a color control panel, treat the registry scan as the source of declarations and allow manual overrides/fallbacks for anything not found. Also scan compiled theme CSS if it is registered as a resource.