chore: added theme/css; fixed wterminal.css
This commit is contained in:
		@@ -1,7 +1,3 @@
 | 
			
		||||
:root {
 | 
			
		||||
  color-scheme: light dark;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
html,
 | 
			
		||||
body {
 | 
			
		||||
  margin: 0px;
 | 
			
		||||
@@ -9,13 +5,16 @@ body {
 | 
			
		||||
  height: 100%;
 | 
			
		||||
  display: flex;
 | 
			
		||||
  flex-direction: column;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
html{
 | 
			
		||||
  /* colors */
 | 
			
		||||
  background-image: linear-gradient(-30deg, #C0E0FF6F 70%, #FFE0C04F);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
main {
 | 
			
		||||
  margin: auto;
 | 
			
		||||
  width: 80%;
 | 
			
		||||
  min-width: 80%;
 | 
			
		||||
  padding: 10px;
 | 
			
		||||
  min-height: 40%;
 | 
			
		||||
  overflow-y: scroll;
 | 
			
		||||
@@ -51,7 +50,7 @@ main p {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
header {
 | 
			
		||||
  padding: 3px 16px 3px 16px;
 | 
			
		||||
  padding: 3px 8px 3px 8px;
 | 
			
		||||
  border-bottom: 1px solid black;
 | 
			
		||||
  background-image: linear-gradient(#0000006f, #0000007f);
 | 
			
		||||
  text-shadow: 1px 1px 1px #0000004f;
 | 
			
		||||
@@ -86,35 +85,32 @@ footer p {
 | 
			
		||||
  margin: 0px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@media(prefers-color-scheme: dark) {
 | 
			
		||||
html.theme-dark {
 | 
			
		||||
  color-scheme: dark;
 | 
			
		||||
  background-image: linear-gradient(-10deg, #1010206F 60%, #5050506F);
 | 
			
		||||
  color: white;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
  html,
 | 
			
		||||
  body {
 | 
			
		||||
    background-image: linear-gradient(-10deg, #1010206F 60%, #5050506F);
 | 
			
		||||
  }
 | 
			
		||||
.theme-dark>body>main {
 | 
			
		||||
  border: 1px solid darkgray;
 | 
			
		||||
  background-color: black;
 | 
			
		||||
  box-shadow: 3px 3px 5px #101010C0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
  main {
 | 
			
		||||
    border: 1px solid darkgray;
 | 
			
		||||
    background-color: black;
 | 
			
		||||
    box-shadow: 3px 3px 5px #101010C0;
 | 
			
		||||
  }
 | 
			
		||||
.theme-dark>body>main>h1 {
 | 
			
		||||
  text-shadow: 0px 0px 3px blue, 2px 2px 6px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
  main h1 {
 | 
			
		||||
    text-shadow: 0px 0px 3px blue, 2px 2px 6px;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  header {
 | 
			
		||||
    /* border-bottom: 1px solid darkgray; */
 | 
			
		||||
.theme-dark>body>header {
 | 
			
		||||
    background-image: linear-gradient(#FFFFFF1f, #FFFFFF3f);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
  header a {
 | 
			
		||||
    /* color: white */
 | 
			
		||||
    /* background-color: #0000004f; */
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  footer {
 | 
			
		||||
    /* border-top: 1px solid darkgray; */
 | 
			
		||||
.theme-dark>body>footer {
 | 
			
		||||
    background-image: linear-gradient(#FFFFFF4f, #FFFFFF0f);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@media(orientation: portrait){
 | 
			
		||||
  main{
 | 
			
		||||
    margin: 1em;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,7 @@
 | 
			
		||||
 | 
			
		||||
<body>
 | 
			
		||||
  <header>
 | 
			
		||||
    <button title="Dark theme on/off" onclick="toggleTheme();">☀</button>
 | 
			
		||||
    <a href="index.html">Willem Games</a>
 | 
			
		||||
  </header>
 | 
			
		||||
 | 
			
		||||
@@ -39,6 +40,7 @@
 | 
			
		||||
    <p class="float-right">Author: Ward Truyen</p>
 | 
			
		||||
  </footer>
 | 
			
		||||
 | 
			
		||||
  <script src="js/theme.js"></script>
 | 
			
		||||
  <script src="term/wterminal-autoextend.js"></script>
 | 
			
		||||
</body>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,7 @@
 | 
			
		||||
 | 
			
		||||
<body>
 | 
			
		||||
  <header>
 | 
			
		||||
    <button title="Dark theme on/off" onclick="toggleTheme();">☀</button>
 | 
			
		||||
    <a href="index.html">Willem Games</a>
 | 
			
		||||
  </header>
 | 
			
		||||
 | 
			
		||||
@@ -37,6 +38,7 @@
 | 
			
		||||
    <p class="float-right">Author: Ward Truyen</p>
 | 
			
		||||
  </footer>
 | 
			
		||||
 | 
			
		||||
  <script src="js/theme.js"></script>
 | 
			
		||||
  <script src="term/wterminal-autoextend.js"></script>
 | 
			
		||||
</body>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -14,6 +14,7 @@
 | 
			
		||||
 | 
			
		||||
<body>
 | 
			
		||||
  <header>
 | 
			
		||||
    <button title="Dark theme on/off" onclick="toggleTheme();">☀</button>
 | 
			
		||||
    <a href="index.html">Willem Games</a>
 | 
			
		||||
  </header>
 | 
			
		||||
 | 
			
		||||
@@ -36,6 +37,7 @@
 | 
			
		||||
    <p class="float-right">Author: Ward Truyen</p>
 | 
			
		||||
  </footer>
 | 
			
		||||
 | 
			
		||||
  <script src="js/theme.js"></script>
 | 
			
		||||
  <script src="js/game-pong-context2d.js"></script>
 | 
			
		||||
  <script src="js/game-tetris-context2d.js"></script>
 | 
			
		||||
</body>
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,7 @@
 | 
			
		||||
 | 
			
		||||
<body>
 | 
			
		||||
  <header>
 | 
			
		||||
    <button title="Dark theme on/off" onclick="toggleTheme();">☀</button>
 | 
			
		||||
    <a href="index.html">Willem Games</a>
 | 
			
		||||
  </header>
 | 
			
		||||
 | 
			
		||||
@@ -32,6 +33,7 @@
 | 
			
		||||
  <footer>
 | 
			
		||||
    <p class="float-right">Author: Ward Truyen</p>
 | 
			
		||||
  </footer>
 | 
			
		||||
  <script src="js/theme.js"></script>
 | 
			
		||||
</body>
 | 
			
		||||
 | 
			
		||||
</html>
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										38
									
								
								src/js/theme.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										38
									
								
								src/js/theme.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,38 @@
 | 
			
		||||
function toggleTheme() {
 | 
			
		||||
  const theme = "theme-dark";//localStorage.getItem('theme');
 | 
			
		||||
  const root = document.querySelector(":root");
 | 
			
		||||
  root.classList.toggle(theme);
 | 
			
		||||
  if (root.classList.contains(theme)) {
 | 
			
		||||
    localStorage.setItem('theme', theme);
 | 
			
		||||
  } else {
 | 
			
		||||
    localStorage.setItem('theme', "theme-light");
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function setTheme(themeName) {
 | 
			
		||||
  console.log("setting them: " + themeName);
 | 
			
		||||
  const root = document.querySelector(":root");
 | 
			
		||||
  root.classList.add(themeName);
 | 
			
		||||
  localStorage.setItem('theme', themeName);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function detectTheme() {
 | 
			
		||||
  const theme = localStorage.getItem('theme');
 | 
			
		||||
  if (theme === 'theme-dark' || theme === 'theme-light') {
 | 
			
		||||
    setTheme(theme);
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
 | 
			
		||||
    setTheme('theme-dark');
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (window.matchMedia('(prefers-color-scheme: light)').matches) {
 | 
			
		||||
    setTheme('theme-light');
 | 
			
		||||
    return;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  setTheme('theme-light');
 | 
			
		||||
}
 | 
			
		||||
detectTheme();
 | 
			
		||||
@@ -66,7 +66,7 @@
 | 
			
		||||
  background-color: #DDD;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.wterminal-container input[type="submit"]:hover, button:hover{
 | 
			
		||||
.wterminal-container input[type="submit"]:hover, .wterminal-container button:hover{
 | 
			
		||||
  background-color: #DDD;
 | 
			
		||||
  cursor: pointer;
 | 
			
		||||
}
 | 
			
		||||
@@ -78,7 +78,7 @@
 | 
			
		||||
  margin: 0;
 | 
			
		||||
  margin-left: 2px;
 | 
			
		||||
}
 | 
			
		||||
.wterminal-container input[type="submit"], button{
 | 
			
		||||
.wterminal-container input[type="submit"], .wterminal-container button{
 | 
			
		||||
  width: unset;
 | 
			
		||||
  height: unset;
 | 
			
		||||
  margin: 0;
 | 
			
		||||
 
 | 
			
		||||
@@ -13,6 +13,7 @@
 | 
			
		||||
 | 
			
		||||
<body>
 | 
			
		||||
  <header>
 | 
			
		||||
    <button title="Dark theme on/off" onclick="toggleTheme();">☀</button>
 | 
			
		||||
    <a href="index.html">Willem Games</a>
 | 
			
		||||
  </header>
 | 
			
		||||
 | 
			
		||||
@@ -61,6 +62,7 @@
 | 
			
		||||
    <p class="float-right">Author: Ward Truyen</p>
 | 
			
		||||
  </footer>
 | 
			
		||||
 | 
			
		||||
  <script src="js/theme.js"></script>
 | 
			
		||||
  <script src="term/wterminal-autoextend.js"></script>
 | 
			
		||||
</body>
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user