Skip to content

Commit

Permalink
Add a dark theme (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
curiousdannii committed Jun 23, 2022
1 parent d59f60a commit 6b81d00
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"dependencies": {
"emglken": "^0.4.0",
"jquery": "^3.6.0",
"js-cookie": "^3.0.1",
"lodash-es": "^4.17.21"
},
"devDependencies": {
Expand Down
11 changes: 11 additions & 0 deletions src/common/launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ https://github.com/curiousdannii/parchment
*/

import Cookies from 'js-cookie'

import Blorb from '../upstream/asyncglk/src/blorb/blorb.ts'
import get_default_options from './options.js'
import {FileView} from '../upstream/asyncglk/src/blorb/iff.ts'
Expand Down Expand Up @@ -36,6 +38,15 @@ class ParchmentLauncher

launch() {
try {
// Apply the dark theme if set
const theme = this.options.theme
|| Cookies.get(this.options.theme_cookie)
// Or if the browser tells us to prefer dark
|| (matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : '')
if (theme) {
document.documentElement.setAttribute('data-theme', theme)
}

const storyfile_path = this.get_storyfile_path()
if (!storyfile_path) {
// Set up all the ways we can load a story
Expand Down
2 changes: 2 additions & 0 deletions src/common/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ export default function get_default_options() {
proxy_url: 'https://proxy.iplayif.com/proxy/',
//single_file: 0
//story: PATH_TO_STORY
//theme: can be set to 'dark'
theme_cookie: 'parchment_theme',
}
}
2 changes: 1 addition & 1 deletion src/upstream/asyncglk
3 changes: 2 additions & 1 deletion src/web/parchment.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ https://github.com/curiousdannii/parchment
*/

body {
background: var(--glkote-page-bg);
color: var(--glkote-buffer-fg);
height: 100%;
margin: 0px;
}

/* Essential styles for GlkOte */
#gameport {
background: var(--glkote-page-bg);
bottom: 0px;
left: 0px;
margin: 0 auto;
Expand Down
3 changes: 2 additions & 1 deletion src/web/web.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
@import url('../upstream/asyncglk/src/glkote/web/glkote.css');
@import url('../fonts/fonts.css');
@import url('../upstream/glkote/dialog.css');
@import url('../upstream/asyncglk/src/glkote/web/light.css');
@import url('../upstream/asyncglk/src/glkote/web/light.css');
@import url('../upstream/asyncglk/src/glkote/web/dark.css');

0 comments on commit 6b81d00

Please sign in to comment.