Several changes

- added theme switching
- added dark theme support for the splash window
This commit is contained in:
Observer KRypt0n_ 2021-12-29 14:56:54 +02:00
parent faee9c4a35
commit e762825d91
No known key found for this signature in database
GPG key ID: DC5D4EC1303465DA
7 changed files with 31 additions and 11 deletions

View file

@ -167,10 +167,10 @@ This is our current roadmap goals. You can find older ones [here](ROADMAP.md)
* <s>Tooltips for some options</s> * <s>Tooltips for some options</s>
* <s>Debugger</s> * <s>Debugger</s>
* <s>Splash screen</s> * <s>Splash screen</s>
* <s>Theming system</s>
* Game pre-installation * Game pre-installation
* Launcher auto-updates * Launcher auto-updates
* Statistics window * Statistics window
* Theming system
* Chengelog window * Chengelog window
* Default runner auto-installation * Default runner auto-installation
* Ability to change the temp directory where the launcher should download some files * Ability to change the temp directory where the launcher should download some files

View file

@ -22,7 +22,7 @@
"fullScreen": false, "fullScreen": false,
"alwaysOnTop": false, "alwaysOnTop": false,
"icon": "/public/icons/64x64.png", "icon": "/public/icons/64x64.png",
"enableInspector": true, "enableInspector": false,
"borderless": false, "borderless": false,
"maximize": false, "maximize": false,
"hidden": true, "hidden": true,

View file

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 645 KiB

View file

@ -4,16 +4,20 @@
@mixin themable($theme-name, $theme-map) @mixin themable($theme-name, $theme-map)
body[data-theme=#{$theme-name}] body[data-theme=#{$theme-name}]
background-color: map.get($theme-map, "background")
div div
width: 60% width: 60%
margin: 56px auto 0 auto margin: 56px auto 0 auto
video img
width: 100% width: 100%
image-rendering: optimizeQuality
h2, p h2, p
margin: 0 margin: 0
text-align: center text-align: center
color: map.get($theme-map, "text")
p p
color: grey color: grey

View file

@ -2,6 +2,8 @@
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { _, locale, locales } from 'svelte-i18n'; import { _, locale, locales } from 'svelte-i18n';
import Configs from './ts/Configs';
import Checkbox from './components/Checkbox.svelte'; import Checkbox from './components/Checkbox.svelte';
import SelectionBox from './components/SelectionBox.svelte'; import SelectionBox from './components/SelectionBox.svelte';
import DXVKSelectionList from './components/DXVKSelectionList.svelte'; import DXVKSelectionList from './components/DXVKSelectionList.svelte';
@ -92,13 +94,18 @@
selectedItem = visibleElement.getAttribute('id'); selectedItem = visibleElement.getAttribute('id');
}; };
const switchTheme = (theme: string) => {
if (theme === 'system')
theme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
document.body.setAttribute('data-theme', theme as string);
};
let dxvkRecommendable = true, let dxvkRecommendable = true,
runnersRecommendable = true; runnersRecommendable = true;
// Auto theme switcher // Auto theme switcher
// TODO: an option to disable it Configs.get('theme').then((theme) => switchTheme(theme as string));
if (window.matchMedia('(prefers-color-scheme: dark)').matches)
document.body.setAttribute('data-theme', 'dark');
// Do some stuff when all the content will be loaded // Do some stuff when all the content will be loaded
onMount(() => { onMount(() => {
@ -136,6 +143,7 @@
lang="settings.general.items.theme.title" lang="settings.general.items.theme.title"
prop="theme" prop="theme"
items={themes} items={themes}
valueChanged={switchTheme}
/> />
<Checkbox lang="settings.general.items.discord" prop="discord.enabled" /> <Checkbox lang="settings.general.items.discord" prop="discord.enabled" />

View file

@ -2,9 +2,14 @@
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import { _, locale } from 'svelte-i18n'; import { _, locale } from 'svelte-i18n';
import Configs from './ts/Configs';
import Window from './ts/neutralino/Window'; import Window from './ts/neutralino/Window';
import Splash from './assets/webms/loading.webm'; import Splash from './assets/gifs/running-qiqi.gif';
import SplashSecret from './assets/gifs/loading-marie-please.gif';
const splash = Math.round(Math.random() * 100) < 100 ? Splash : SplashSecret;
let phrase = Math.round(Math.random() * 2); let phrase = Math.round(Math.random() * 2);
@ -37,14 +42,17 @@
}); });
// Auto theme switcher // Auto theme switcher
// TODO: an option to disable it Configs.get('theme').then((theme) => {
if (window.matchMedia('(prefers-color-scheme: dark)').matches) if (theme === 'system')
document.body.setAttribute('data-theme', 'dark'); theme = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
document.body.setAttribute('data-theme', theme as string);
});
</script> </script>
{#if typeof $locale === 'string'} {#if typeof $locale === 'string'}
<main> <main>
<video src={Splash} loop muted autoplay></video> <img src={splash} alt="" />
<h2>{$_('splash.title')}</h2> <h2>{$_('splash.title')}</h2>
<p>{$_(`splash.phrases.${phrase}`)}</p> <p>{$_(`splash.phrases.${phrase}`)}</p>