change dark styling, add more backgrounds
This commit is contained in:
parent
e75df5b2df
commit
83fb1230b5
|
@ -4,7 +4,7 @@ html {
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
background-image: url('../img/bg-winter.jpg');
|
background-image: url('../img/bg-spring.jpg');
|
||||||
background-position: center;
|
background-position: center;
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,14 @@ details {
|
||||||
background: rgba(255,255,255,0.8);
|
background: rgba(255,255,255,0.8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dark details {
|
||||||
|
background: rgba(0,0,0,0.8);
|
||||||
|
}
|
||||||
|
|
||||||
|
summary {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
summary h2 {
|
summary h2 {
|
||||||
display: inline;
|
display: inline;
|
||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 87 KiB |
Binary file not shown.
After Width: | Height: | Size: 81 KiB |
Binary file not shown.
After Width: | Height: | Size: 59 KiB |
Binary file not shown.
After Width: | Height: | Size: 70 KiB |
Binary file not shown.
After Width: | Height: | Size: 90 KiB |
|
@ -11,16 +11,11 @@ document.addEventListener('DOMContentLoaded', (event) => {
|
||||||
setMap()
|
setMap()
|
||||||
|
|
||||||
|
|
||||||
// For custom (dark) CSS themes, set the <details> background to the inverse of
|
// For custom (dark) CSS themes that don't recognize the <details> background, set it to black.
|
||||||
// the text colour.
|
const parseColour = (str) => str.match(/([0-9.]+)/g).map(parseFloat)
|
||||||
const parseColour = (str) => str.match(/([0-9.]+)/g).map(parseFloat)
|
const luminance = ([r,g,b]) => 0.2126*r + 0.7152*g + 0.0722*b
|
||||||
const dumpColour = (col) => `rgba(${col.join(',')})`
|
const textCol = window.getComputedStyle(document.body).getPropertyValue('color')
|
||||||
const textColour = parseColour(window.getComputedStyle(document.body).getPropertyValue('color'))
|
|
||||||
const invertedColour = [255-textColour[0], 255-textColour[1], 255-textColour[2], 0.8]
|
if (luminance(parseColour(textCol)) > 0.5)
|
||||||
const sheet = document.styleSheets[0]
|
document.body.classList.add('dark')
|
||||||
sheet.insertRule(`
|
|
||||||
details {
|
|
||||||
background-color: ${dumpColour(invertedColour)} !important;
|
|
||||||
}`
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue