Replies: 3 comments 2 replies
-
If am I, just a doubt. Adding a What if the E.G. \add_action(
AssetManager::ACTION_SETUP,
fn(AssetManager $assetManager) => $assetManager->withRootVars(['custom-property', '20px'])
); It is more logic than say that an asset can define the configuration for the whole page. |
Beta Was this translation helpful? Give feedback.
-
Thanks for your response @widoz :) While i kind of agree with you regarding the The I guess if someone really wants to register it's custom CSS properties (CSS vars) at Hm...you're not wrong with your note, i guess the |
Beta Was this translation helpful? Give feedback.
-
This was implemented with version 2.8. of inpsyde/assets. https://github.com/inpsyde/assets/releases/tag/2.8 I'll close this discussion now. Thanks all for input! :) |
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem? Please describe.
[!] Note: CSS custom properties = CSS variables = CSS vars (used in issue, because i'm lazy).
All modern browsers (Edge, Firefox, Chrome, Safari, Opera) are supporting custom CSS properties and it could come handy when allowing customizing styles via CSS vars instead of overwriting them with own stylesheets and stronger selectors.
WordPress itself does support adding inline styles via
wp_add_inline_style
. Our library already supports adding custom inline CSS viaStyle::withInlineStyles($cssString)
, but this would be mean following code to allow adding CSS vars:which would result into:
But this is not extendable and also does not allow any "overwriting" or configuration from outside.
Describe the solution you'd like
I would like to introduce a new method which is called
Style::withCssVars(array $vars, string $location = ':root');
which would allow to add/change custom CSS variables to a location.The example from above could look like following:
and would produce the same result with less to write.
Additionally we...
a) ... could support automatically prefixing variables with
--
to have easier to read and accessible array keys.b) ... have the possibility to overwrite those variables before they are printed out like following:
Additional context
Beta Was this translation helpful? Give feedback.
All reactions