change dark styling, add more backgrounds
This commit is contained in:
		
							parent
							
								
									e75df5b2df
								
							
						
					
					
						commit
						83fb1230b5
					
				|  | @ -4,7 +4,7 @@ html { | |||
| 
 | ||||
| body { | ||||
| 	margin: 0; | ||||
| 	background-image: url('../img/bg-winter.jpg'); | ||||
| 	background-image: url('../img/bg-spring.jpg'); | ||||
| 	background-position: center; | ||||
| 	background-size: cover; | ||||
| } | ||||
|  | @ -16,6 +16,14 @@ details { | |||
| 	background: rgba(255,255,255,0.8); | ||||
| } | ||||
| 
 | ||||
| .dark details { | ||||
| 	background: rgba(0,0,0,0.8); | ||||
| } | ||||
| 
 | ||||
| summary { | ||||
| 	cursor: pointer; | ||||
| } | ||||
| 
 | ||||
| summary h2 { | ||||
| 	display: inline; | ||||
| 	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() | ||||
| 
 | ||||
| 
 | ||||
| 	// For custom (dark) CSS themes, set the <details> background to the inverse of
 | ||||
| 	// the text colour.
 | ||||
| 	const parseColour    = (str) => str.match(/([0-9.]+)/g).map(parseFloat) | ||||
| 	const dumpColour     = (col) => `rgba(${col.join(',')})` | ||||
| 	const textColour     = parseColour(window.getComputedStyle(document.body).getPropertyValue('color')) | ||||
| 	const invertedColour = [255-textColour[0], 255-textColour[1], 255-textColour[2], 0.8] | ||||
| 	const sheet = document.styleSheets[0] | ||||
| 	sheet.insertRule(` | ||||
| 		details { | ||||
| 			background-color: ${dumpColour(invertedColour)} !important; | ||||
| 		}` | ||||
| 	) | ||||
| 	// For custom (dark) CSS themes that don't recognize the <details> background, set it to black.
 | ||||
| 	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 textCol     = window.getComputedStyle(document.body).getPropertyValue('color') | ||||
| 
 | ||||
| 	if (luminance(parseColour(textCol)) > 0.5) | ||||
| 		document.body.classList.add('dark') | ||||
| }) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	 User
						User