Use css variables for editor markup
Question
Given that all modern browsers (https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties#Browser_compatibility) support CSS variables, the added value of using SCSS for them is limited.
I do not propose fully removing SCSS, what I do propose is the following:
- Replace all uses of
darken()andlighten()functions and replace them with SCSS variable in_gjs_variables.scss. - For all sass variables used in
_gjs_variables.scssreplace it with css variable:
// This
$primaryColor: #444 !default;
// Becomes
:root {
--gjs-primary-color: #444;
}
$primaryColor: var(--gjs-primary-color);
This is a simple change that should not result in a BC break. After doing this theming the editor will become even simpler since we can just specify the variables directly in CSS and we're done; no recompilation needed.
Answers (3)
Hi @artf After a year, I wonder if your opinion on this matter changed? We'd love to use it and IE11 becomes less and less of a thing ;) @SamMousa if you need help with the PR, we can contribute as well. Looking forward to hearing back from you! Philipp
After a year, I wonder if your opinion on this matter changed?
Unfortunately, it doesn't depend only on my decision, from what I know, they're still a good percentage of users relying on IE11 compatibility. So, the only solution would be creating a good SCSS file import usage (avoid writing the same styles declaration twice) and generate a new CSS file with custom properties.
For now, I'll close the issue as the traction for this is very low, but a PR would still be welcome
I'll make a PR if you're open to this.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #2853
[QUESTION] Do you have plans to remove dependency on Document.execCommand in RTE?
I noticed that in https://github.com/artf/grapesjs/issues/74 when the move to the Pell based editor is listed it's use of Document.execComm...
Issue #2586
[Question]: How update style manager panel using few devices and custom css class
There is a custom class added to simple grapesjs project: If there is no devices and user adds the class into the selectors field Settings...
Issue #340
css variables undefined value bug
I am trying to extend the editor to support css vars i added: to the page and i get in the browser: can you explain how the editor parses t...
Issue #6152
BUG: CSS added via custom code persists after custom code component is removed
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? any Reproducible demo link https://grapesj...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.