-
-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(themes) Add CSS layers to ease up variables handling
- introduce "grist-base", "grist-theme" and "grist-custom" css layers in order to easily handle priority of css variables and base css rules - apply css default variables and css reset on the "grist-base" layer. Note that the way default html/body css is loaded has been changed to be simpler, but maybe I assumed too much here, I didn't dig too deep to get the whole context - apply custom theme css variables on the "grist-theme" layer - a potential custom.css file should wrap its code in the "grist-custom" layer, as the updated example file suggests This will allow base/theme/custom CSS to generate the same variable names while being sure custom css takes precedence theme variables, and theme variables take precedence over default variables.
- Loading branch information
1 parent
d107464
commit b77bbf7
Showing
6 changed files
with
81 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/** | ||
* Gets or creates a style element in the head of the document with the given `id`. | ||
* | ||
* Useful for grouping CSS values such as theme custom properties without needing to | ||
* pollute the document with in-line styles. | ||
*/ | ||
export function getOrCreateStyleElement(id: string) { | ||
let style = document.head.querySelector(`#${id}`); | ||
if (style) { return style; } | ||
style = document.createElement('style'); | ||
style.setAttribute('id', id); | ||
document.head.append(style); | ||
return style; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,44 @@ | ||
:root { | ||
/* logo */ | ||
--icon-GristLogo: url("ui-icons/Logo/GristLogo.svg") !important; | ||
--grist-logo-bg: #040404 !important; | ||
--grist-logo-size: 22px 22px !important; | ||
@layer grist-custom { | ||
:root { | ||
/* logo */ | ||
--icon-GristLogo: url("ui-icons/Logo/GristLogo.svg") !important; | ||
--grist-logo-bg: #040404 !important; | ||
--grist-logo-size: 22px 22px !important; | ||
|
||
/* colors */ | ||
--grist-color-light-grey: #F7F7F7 !important; | ||
--grist-color-medium-grey: rgba(217,217,217,0.6) !important; | ||
--grist-color-medium-grey-opaque: #E8E8E8 !important; | ||
--grist-color-dark-grey: #D9D9D9 !important; | ||
--grist-color-light: #FFFFFF !important; | ||
--grist-color-dark: #262633 !important; | ||
--grist-color-dark-bg: #262633 !important; | ||
--grist-color-slate: #929299 !important; | ||
--grist-color-light-green: #16B378 !important; | ||
--grist-color-dark-green: #009058 !important; | ||
--grist-color-darker-green: #007548 !important; | ||
--grist-color-lighter-green: #b1ffe2 !important; | ||
--grist-color-lighter-blue: #87b2f9 !important; | ||
--grist-color-light-blue: #3B82F6 !important; | ||
--grist-color-cursor: #16B378 !important; | ||
--grist-color-selection: rgba(22,179,120,0.15) !important; | ||
--grist-color-selection-opaque: #DCF4EB !important; | ||
--grist-color-selection-darker-opaque: #d6eee5 !important; | ||
--grist-color-inactive-cursor: #A2E1C9 !important; | ||
--grist-color-hover: #bfbfbf !important; | ||
--grist-color-error: #D0021B !important; | ||
--grist-color-warning: #F9AE41 !important; | ||
--grist-color-warning-bg: #dd962c !important; | ||
--grist-color-backdrop: rgba(38,38,51,0.9) !important; | ||
--grist-label-text-bg: #FFFFFF !important; | ||
--grist-label-active-bg: #F0F0F0 !important; | ||
--grist-primary-fg: #16B378 !important; | ||
--grist-primary-fg-hover: #009058 !important; | ||
--grist-primary-bg: #ffffff !important; | ||
--grist-control-bg: #ffffff !important; | ||
--grist-control-fg: #16B378 !important; | ||
--grist-primary-fg-hover: #009058 !important; | ||
--grist-control-border: 1px solid #11B683 !important; | ||
--grist-toast-bg: #040404 !important; | ||
/* colors */ | ||
--grist-color-light-grey: #F7F7F7 !important; | ||
--grist-color-medium-grey: rgba(217,217,217,0.6) !important; | ||
--grist-color-medium-grey-opaque: #E8E8E8 !important; | ||
--grist-color-dark-grey: #D9D9D9 !important; | ||
--grist-color-light: #FFFFFF !important; | ||
--grist-color-dark: #262633 !important; | ||
--grist-color-dark-bg: #262633 !important; | ||
--grist-color-slate: #929299 !important; | ||
--grist-color-light-green: #16B378 !important; | ||
--grist-color-dark-green: #009058 !important; | ||
--grist-color-darker-green: #007548 !important; | ||
--grist-color-lighter-green: #b1ffe2 !important; | ||
--grist-color-lighter-blue: #87b2f9 !important; | ||
--grist-color-light-blue: #3B82F6 !important; | ||
--grist-color-cursor: #16B378 !important; | ||
--grist-color-selection: rgba(22,179,120,0.15) !important; | ||
--grist-color-selection-opaque: #DCF4EB !important; | ||
--grist-color-selection-darker-opaque: #d6eee5 !important; | ||
--grist-color-inactive-cursor: #A2E1C9 !important; | ||
--grist-color-hover: #bfbfbf !important; | ||
--grist-color-error: #D0021B !important; | ||
--grist-color-warning: #F9AE41 !important; | ||
--grist-color-warning-bg: #dd962c !important; | ||
--grist-color-backdrop: rgba(38,38,51,0.9) !important; | ||
--grist-label-text-bg: #FFFFFF !important; | ||
--grist-label-active-bg: #F0F0F0 !important; | ||
--grist-primary-fg: #16B378 !important; | ||
--grist-primary-fg-hover: #009058 !important; | ||
--grist-primary-bg: #ffffff !important; | ||
--grist-control-bg: #ffffff !important; | ||
--grist-control-fg: #16B378 !important; | ||
--grist-primary-fg-hover: #009058 !important; | ||
--grist-control-border: 1px solid #11B683 !important; | ||
--grist-toast-bg: #040404 !important; | ||
} | ||
} |