Skip to content

added color themes and functionality to change them as well #10

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 25 additions & 14 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,35 @@
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CoderType</title>
<meta name="description" content="A speed typing game made for coders.">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CoderType</title>
<meta name="description" content="A speed typing game made for coders.">

<link rel="stylesheet" href="./styles/reset.css">
<link rel="stylesheet" href="./styles/theme.css">
<link rel="stylesheet" href="./styles/index.css">
<link rel="stylesheet" href="./styles/reset.css">
<link rel="stylesheet" href="./styles/theme.css">
<link rel="stylesheet" href="./styles/index.css">
<link rel="stylesheet" href="./styles/rosepine.css">
<link rel="stylesheet" href="./styles/catppuccin.css">
<link rel="stylesheet" href="./styles/monokai.css">
<link rel="stylesheet" href="./styles/solarizedlight.css">
</head>

<body>
<main>
<pre id="terminal"><span id="cursor" class="cursor">&nbsp;</span></pre>
<pre id="editor"></pre>
<pre id="stats"></pre>
</main>
<script type="module" src="./scripts/index.ts"></script>
<main>
<select id="select-theme">
<option value="Default">Default</option>
<option value="monokai">Monokai</option>
<option value="rosepine">Rosepine</option>
<option value="catppuccin">Catppuccin</option>
<option value="solarizedlight">Solarized Light</option>
</select>
<pre id="terminal"><span id="cursor" class="cursor">&nbsp;</span></pre>
<pre id="editor"></pre>
<pre id="stats"></pre>
</main>
<script type="module" src="./scripts/index.ts"></script>
</body>

</html>
9 changes: 9 additions & 0 deletions scripts/changeTheme.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export const changeThemeColor = () => {
const themeSelect: HTMLSelectElement = document.querySelector('#select-theme')

themeSelect.onchange = function () {
document.documentElement.className = ''
document.documentElement.classList.add(themeSelect.value)
}

}
3 changes: 3 additions & 0 deletions scripts/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Repo, RepoFile, repoOptions } from "./data";
import { clearEditor, EditorResult, startEditor } from "./editor";
import { chooseOption, clearTerminal, readLine, removeTerminalCursor, separatorLine, writeLines } from "./terminal";
import { changeThemeColor } from "./changeTheme";

const getRoundLine = (round: number, wantsToPlayAgain: boolean) => {
if (round === 1) return "Welcome to coder type!";
Expand Down Expand Up @@ -71,4 +72,6 @@ const runGame = async () => {
}
}

changeThemeColor()

runGame();
17 changes: 17 additions & 0 deletions styles/catppuccin.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.catppuccin:root {
--foreground-color: #d9e0ee;
--background-color: #1e1e2e;
--wrong-color: #f28fad;
}

body {
background-color: var(--background-color);
color: var(--foreground-color);
}

@media (prefers-color-scheme: dark) {
.catppuccin:root {
--foreground-color: #d9e0ee;
--background-color: #1e1e2e;
}
}
18 changes: 18 additions & 0 deletions styles/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,21 @@ main {
background-color: var(--wrong-color);
opacity: 0.8;
}

select {
position: fixed;
top: 40px;
right: 40px;
padding: 10px;
background: transparent;
border: 1px solid var(--foreground-color);
border-radius: 5px;
font-size: 18px;
color: var(--foreground-color);
}

option {
background: var(--background-color);
color: var(--foreground-color);
padding: 3px;
}
17 changes: 17 additions & 0 deletions styles/monokai.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.monokai:root {
--foreground-color: #e2e2dc;
--background-color: #272822;
--wrong-color: #f92672;
}

body {
background-color: var(--background-color);
color: var(--foreground-color);
}

@media (prefers-color-scheme: dark) {
.monokai:root {
--foreground-color: #e2e2dc;
--background-color: #272822;
}
}
17 changes: 17 additions & 0 deletions styles/rosepine.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.rosepine:root {
--foreground-color: #e0def4;
--background-color: #1f1d27;
--wrong-color: #eb6f92;
}

body {
background-color: var(--background-color);
color: var(--foreground-color);
}

@media (prefers-color-scheme: dark) {
.rosepine:root {
--foreground-color: #e0def4;
--background-color: #1f1d27;
}
}
17 changes: 17 additions & 0 deletions styles/solarizedlight.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.solarizedlight:root {
--foreground-color: #181819;
--background-color: #fdf6e3;
--wrong-color: #d33682;
}

body {
background-color: var(--background-color);
color: var(--foreground-color);
}

@media (prefers-color-scheme: dark) {
.solarizedlight:root {
--foreground-color: #181819;
--background-color: #fdf6e3;
}
}
4 changes: 2 additions & 2 deletions styles/theme.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
:root {
--foreground-color: black;
--background-color: white;
--foreground-color: white;
--background-color: black;
--wrong-color: red;
}

Expand Down