-
Notifications
You must be signed in to change notification settings - Fork 339
ENH: Allow CSS variables to manipulate theme #190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1aaaefd
c239050
c4148c4
aa92528
c3f3f84
f116d60
185c2cf
7f4892d
e15dffe
8ddd977
222e14e
e32c826
a156644
f8d70e3
c7a5e65
811e134
d2b7d88
d04e6c5
0f25c1b
8cac2e9
30eba8a
b3c61a7
a04d97c
146129e
3ab8f06
130af5b
8edd3ab
facbf8e
6d7c351
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
:root { | ||
/***************************************************************************** | ||
* Font size | ||
**/ | ||
--font-size-base: 15px; /* base font size - applied at body / html level */ | ||
|
||
/* heading font sizes */ | ||
--font-size-h1: 36px; | ||
--font-size-h2: 32px; | ||
--font-size-h3: 26px; | ||
--font-size-h4: 21px; | ||
--font-size-h5: 18px; | ||
--font-size-h6: 16px; | ||
|
||
/* smaller then heading font sizes*/ | ||
--font-size-milli: 12px; | ||
|
||
/***************************************************************************** | ||
* Font family | ||
**/ | ||
--font-family-base: 'Lato', sans-serif; | ||
--font-family-heading: 'Open Sans', sans-serif; | ||
|
||
/***************************************************************************** | ||
* Color | ||
* | ||
* Colors are defined in rgb string way, "red, green, blue" | ||
**/ | ||
--color-primary: 19, 6, 84; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OOOOO. It's soooo hacky, that I like it. XD |
||
--color-success: 40, 167, 69; | ||
--color-info: 23, 162, 184; | ||
--color-warning: 255, 193, 7; | ||
--color-danger: 220, 53, 69; | ||
--color-text-base: 51, 51, 51; | ||
--color-h1: var(--color-primary); | ||
--color-h2: var(--color-primary); | ||
--color-h3: var(--color-text-base); | ||
--color-h4: var(--color-text-base); | ||
--color-h5: var(--color-text-base); | ||
--color-h6: var(--color-text-base); | ||
--color-paragraph: var(--color-text-base); | ||
--color-link: 0, 91, 129; | ||
--color-link-hover: 227, 46, 0; | ||
--color-headerlink: 198, 15, 15; | ||
--color-headerlink-hover: 255, 255, 255; | ||
--color-preformatted-text: 34, 34, 34; | ||
--color-preformatted-background: 250, 250, 250; | ||
|
||
--color-active-navigation: 19, 6, 84; | ||
--color-navbar-link: 77, 77, 77; | ||
--color-navbar-link-hover: var(--color-active-navigation); | ||
--color-navbar-link-active: var(--color-active-navigation); | ||
--color-sidebar-link: 77, 77, 77; | ||
--color-sidebar-link-hover: var(--color-active-navigation); | ||
--color-sidebar-link-active: var(--color-active-navigation); | ||
--color-toc-link: 119, 117, 122; | ||
--color-toc-link-hover: var(--color-active-navigation); | ||
--color-toc-link-active: var(--color-active-navigation); | ||
|
||
--color-admonition-primary: var(--color-primary); | ||
--color-admonition-success: var(--color-success); | ||
--color-admonition-danger: var(--color-danger); | ||
--color-admonition-warning: var(--color-warning); | ||
--color-admonition-info: var(--color-info); | ||
|
||
/***************************************************************************** | ||
* Icon | ||
**/ | ||
|
||
/* font awesome icons*/ | ||
--icon-check-circle: '\f058'; | ||
--icon-info-circle: '\f05a'; | ||
--icon-exclamation-triangle: '\f071'; | ||
--icon-exclamation-circle: '\f06a'; | ||
--icon-times-circle: '\f057'; | ||
--icon-lightbulb: '\f0eb'; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
// Admonitions CSS inspired by https://squidfunk.github.io/mkdocs-material/getting-started/ | ||
// Admonitions CSS originally inspired by https://squidfunk.github.io/mkdocs-material/getting-started/ | ||
|
||
.admonition { | ||
margin: 1.5625em auto; | ||
padding: 0 .6rem .8rem .6rem !important; | ||
padding: 0 0.6rem 0.8rem 0.6rem !important; | ||
overflow: hidden; | ||
page-break-inside: avoid; | ||
border-left: .2rem solid $blue; | ||
border-radius: .1rem; | ||
box-shadow: 0 0.2rem 0.5rem rgba(0,0,0,.05), 0 0 0.05rem rgba(0,0,0,.1); | ||
transition: color 250ms,background-color 250ms,border-color 250ms; | ||
border-left: 0.2rem solid; | ||
border-color: rgba(var(--color-admonition-primary), 1); | ||
border-radius: 0.1rem; | ||
box-shadow: 0 0.2rem 0.5rem rgba(0, 0, 0, 0.05), | ||
0 0 0.05rem rgba(0, 0, 0, 0.1); | ||
transition: color 250ms, background-color 250ms, border-color 250ms; | ||
|
||
// Last item should have no spacing since we'll control that w/ padding | ||
*:last-child { | ||
|
@@ -28,19 +31,19 @@ | |
.admonition-title { | ||
position: relative; | ||
margin: 0 -0.6rem !important; | ||
padding: .4rem .6rem .4rem 2rem; | ||
padding: 0.4rem 0.6rem 0.4rem 2rem; | ||
font-weight: 700; | ||
background-color: rgba(68,138,255,.1); | ||
background-color: rgba(68, 138, 255, 0.1); | ||
|
||
&:before { | ||
position: absolute; | ||
left: .6rem; | ||
left: 0.6rem; | ||
width: 1rem; | ||
height: 1rem; | ||
color: $blue; | ||
font-family: "Font Awesome 5 Free"; | ||
color: rgba(var(--color-admonition-primary), 1); | ||
font-family: 'Font Awesome 5 Free'; | ||
font-weight: 900; | ||
content: $icon-info-circle; /* info-circle */ | ||
content: var(--icon-info-circle); | ||
} | ||
|
||
// Next element after title needs some extra upper-space | ||
|
@@ -50,109 +53,109 @@ | |
} | ||
|
||
&.attention { | ||
border-color: $orange; | ||
border-color: rgba(var(--color-admonition-warning), 1); | ||
.admonition-title { | ||
background-color: $orange-light; | ||
background-color: rgba(var(--color-admonition-warning), 0.1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! Is this the reason that the colors need to be defined as a RGB tuple? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The RGB tuple is the required argument for the |
||
|
||
&:before { | ||
color: $orange; | ||
content: $icon-exclamation-circle; | ||
color: rgba(var(--color-admonition-warning), 1); | ||
content: var(--icon-exclamation-circle); | ||
} | ||
} | ||
} | ||
|
||
&.caution { | ||
border-color: $orange; | ||
border-color: rgba(var(--color-admonition-warning), 1); | ||
.admonition-title { | ||
background-color: $orange-light; | ||
background-color: rgba(var(--color-admonition-warning), 0.1); | ||
|
||
&:before { | ||
color: $orange; | ||
content: $icon-exclamation-triangle; | ||
color: rgba(var(--color-admonition-warning), 1); | ||
content: var(--icon-exclamation-triangle); | ||
} | ||
} | ||
} | ||
|
||
&.warning { | ||
border-color: $red; | ||
border-color: rgba(var(--color-admonition-warning), 1); | ||
.admonition-title { | ||
background-color: $red-light; | ||
background-color: rgba(var(--color-admonition-warning), 0.1); | ||
|
||
&:before { | ||
color: $red; | ||
content: $icon-exclamation-triangle; | ||
color: rgba(var(--color-admonition-warning), 1); | ||
content: var(--icon-exclamation-triangle); | ||
} | ||
} | ||
} | ||
|
||
&.danger { | ||
border-color: $red; | ||
border-color: rgba(var(--color-admonition-danger), 1); | ||
.admonition-title { | ||
background-color: $red-light; | ||
background-color: rgba(var(--color-admonition-danger), 0.1); | ||
|
||
&:before { | ||
color: $red; | ||
content: $icon-exclamation-triangle; | ||
color: rgba(var(--color-admonition-danger), 1); | ||
content: var(--icon-exclamation-triangle); | ||
} | ||
} | ||
} | ||
|
||
&.error { | ||
border-color: $red; | ||
border-color: rgba(var(--color-admonition-danger), 1); | ||
.admonition-title { | ||
background-color: $red-light; | ||
background-color: rgba(var(--color-admonition-danger), 0.1); | ||
|
||
&:before { | ||
color: $red; | ||
content: $icon-times-circle; | ||
color: rgba(var(--color-admonition-danger), 1); | ||
content: var(--icon-times-circle); | ||
} | ||
} | ||
} | ||
|
||
&.hint { | ||
border-color: $yellow; | ||
border-color: rgba(var(--color-admonition-warning), 1); | ||
.admonition-title { | ||
background-color: $yellow-light; | ||
background-color: rgba(var(--color-admonition-warning), 0.1); | ||
|
||
&:before { | ||
color: $yellow; | ||
content: $icon-lightbulb; | ||
color: rgba(var(--color-admonition-warning), 1); | ||
content: var(--icon-lightbulb); | ||
} | ||
} | ||
} | ||
|
||
&.tip { | ||
border-color: $yellow; | ||
border-color: rgba(var(--color-admonition-info), 1); | ||
.admonition-title { | ||
background-color: $yellow-light; | ||
background-color: rgba(var(--color-admonition-info), 0.1); | ||
|
||
&:before { | ||
color: $yellow; | ||
content: $icon-lightbulb; | ||
color: rgba(var(--color-admonition-info), 1); | ||
content: var(--icon-lightbulb); | ||
} | ||
} | ||
} | ||
|
||
&.important { | ||
border-color: $blue; | ||
border-color: rgba(var(--color-admonition-info), 1); | ||
.admonition-title { | ||
background-color: $blue-light; | ||
background-color: rgba(var(--color-admonition-info), 0.1); | ||
|
||
&:before { | ||
color: $blue; | ||
content: $icon-exclamation-circle; | ||
color: rgba(var(--color-admonition-info), 1); | ||
content: var(--icon-exclamation-circle); | ||
} | ||
} | ||
} | ||
|
||
&.note { | ||
border-color: $blue; | ||
border-color: rgba(var(--color-admonition-info), 1); | ||
.admonition-title { | ||
background-color: $blue-light; | ||
background-color: rgba(var(--color-admonition-info), 0.1); | ||
|
||
&:before { | ||
color: $blue; | ||
content: $icon-info-circle; | ||
color: rgba(var(--color-admonition-info), 1); | ||
content: var(--icon-info-circle); | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if a user overrides those variables in their custom css, do they also always need to define the color as such a tuple?
Eg someone doing
will work or not?
And related to my question below, the reason they are defined here as r, g, b, is that to make things like
rgba(var(--color-sidebar-link-hover), 1)
work? (if that is indeed the reason, a clarifying comment here might be helpful)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As long as the custom CSS is added after the theme's CSS, it'll work. :)