Skip to content

Commit

Permalink
chore: started on light theme
Browse files Browse the repository at this point in the history
  • Loading branch information
Tormak9970 committed Apr 18, 2023
1 parent 608b3c5 commit 1de420f
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 20 deletions.
23 changes: 20 additions & 3 deletions public/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
--foreground-light: #3d3d3d;
--foreground-light-hover: #474747;

--shadow: #0e0e0e;

--highlight: #04e200;
--highlight-hover: #05FF00;
--highlight-dim: #039900;
Expand All @@ -33,6 +35,9 @@

--selection-color: #3891ff7a;

--link-color: #00bbff;
--link-color-visited: #005eff;

--success: #36ff04;

--save: #14a101;
Expand All @@ -42,6 +47,18 @@
--toastContainerTop: 2.5rem;
}

[data-theme="light"] {
--font-color: rgb(14, 14, 14);
--background: #ffffff;
--background-hover: #e5f7e8;
--foreground: #cfecd2;
--foreground-hover: #b3d8b6;
--foreground-light: #8de095;
--foreground-light-hover: #67db72;

--shadow: #868383;
}

.splitpanes {
background-color: var(--background) !important;
}
Expand All @@ -52,8 +69,8 @@

.splitpanes__splitter {
background-color: var(--background-hover) !important;
border-left: 1px solid var(--foreground-light) !important;
border-right: 1px solid var(--foreground-light) !important;
border-left: 1px solid var(--foreground-light) !important;
border-right: 1px solid var(--foreground-light) !important;
position: relative;
}
.splitpanes__splitter:before {
Expand Down Expand Up @@ -92,7 +109,7 @@
transition-property: transform, visibility, opacity;
border-radius: 2px;

box-shadow: 3px 6px 10px 4px #0e0e0e;
box-shadow: 3px 6px 10px 4px var(--shadow);
}

.tippy-arrow {
Expand Down
1 change: 1 addition & 0 deletions src-tauri/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"version": "",
"theme": 0,
"steamGridDbApiKey": "",
"steamApiKeyMap": {},
"hiddenGameIds": []
Expand Down
7 changes: 7 additions & 0 deletions src/Stores.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ export enum Platforms {
NON_STEAM="Non Steam"
}

export enum Theme {
DARK,
LIGHT
}

export const theme = sharedStore(Theme.DARK, "theme");

export const needsSGDBAPIKey = sharedStore(true, "needsSGDBAPIKey");
export const needsSteamKey = sharedStore(true, "needsSteamKey");

Expand Down
4 changes: 2 additions & 2 deletions src/components/Titlebar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import { onMount } from "svelte";
import { exit } from "@tauri-apps/api/process";
import { WindowController } from "../lib/controllers/WindowController";
import { canSave } from "../Stores";
import { dialog } from "@tauri-apps/api";
import { canSave } from "../Stores";
import { dialog } from "@tauri-apps/api";
export let title: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import Accordion from "../../layout/Accordion.svelte";
import VerticalSpacer from "../../spacers/VerticalSpacer.svelte";
import SectionTitle from "../SectionTitle.svelte";
import { SettingsManager } from "../../../lib/utils/SettingsManager";
import { LogController } from "../../../lib/controllers/LogController";
/**
* Creates a function to update the specified filter.
Expand Down Expand Up @@ -34,12 +36,27 @@
return word.substring(0,1).toUpperCase().concat(word.substring(1));
}
}
function onDarkModeChange(checked: boolean): void {
document.documentElement.setAttribute("data-theme", checked ? "dark" : "light");
SettingsManager.updateSetting("theme", checked ? 0 : 1);
LogController.log(`Set theme to "${checked ? "dark" : "light"}".`);
}
</script>

<Pane minSize={15} size={20}>
<SectionTitle title="Filters" />
<SectionTitle title="Options" />

<div class="content" style="height: 36px;">
<div style="margin-left: 6px; display: flex; justify-content: space-between;">
<Toggle label="Dark Mode" onChange={onDarkModeChange}/>
</div>

<div class="border" />
<VerticalSpacer />
</div>

<div class="content">
<div class="content" style="height: calc(100% - 85px);">
{#each Object.keys($dbFilters[$gridType]) as section}
<Accordion
label="{section == "oneoftag" ? "Tags" : toUpperCaseSplit(section)}"
Expand All @@ -64,7 +81,13 @@
<style>
.content {
margin: 0px 6px;
padding: 0px 6px;
overflow: auto;
max-height: calc(100% - 45px)
max-height: calc(100% - 65px)
}
.border {
margin-top: 10px;
border-bottom: 1px solid var(--foreground);
}
</style>
2 changes: 1 addition & 1 deletion src/components/interactables/Button.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
font-size: 12px;
cursor: pointer;
color: rgb(231, 231, 231);
color: var(--font-color);
transition: background-color 0.15s ease-in-out;
}
Expand Down
5 changes: 4 additions & 1 deletion src/lib/controllers/AppController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { ToastController } from "./ToastController";
import { SettingsManager } from "../utils/SettingsManager";
import { LogController } from "./LogController";
import { get } from "svelte/store";
import { GridTypes, Platforms, activeUserId, appLibraryCache, canSave, currentPlatform, gridType, hiddenGameIds, isOnline, loadingGames, needsSGDBAPIKey, needsSteamKey, nonSteamGames, originalAppLibraryCache, originalSteamShortcuts, selectedGameAppId, selectedGameName, steamGames, steamGridDBKey, steamKey, steamShortcuts, steamUsers } from "../../Stores";
import { GridTypes, Platforms, activeUserId, appLibraryCache, canSave, currentPlatform, gridType, hiddenGameIds, isOnline, loadingGames, needsSGDBAPIKey, needsSteamKey, nonSteamGames, originalAppLibraryCache, originalSteamShortcuts, selectedGameAppId, selectedGameName, steamGames, steamGridDBKey, steamKey, steamShortcuts, steamUsers, theme } from "../../Stores";
import { CacheController } from "./CacheController";
import { RustInterop } from "./RustInterop";
import type { SGDBImage } from "../models/SGDB";
Expand Down Expand Up @@ -95,6 +95,9 @@ export class AppController {
needsSteamKey.set(false);
}

theme.set(settings.theme);
document.documentElement.setAttribute("data-theme", settings.theme == 0 ? "dark" : "light");

hiddenGameIds.set(settings.hiddenGameIds);

if (activeUser.id32 == "0") {
Expand Down
1 change: 1 addition & 0 deletions src/types/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
type AppSettings = {
version: string;
theme: number;
steamGridDbApiKey: string;
steamApiKeyMap: {
[userId32: string]: string
Expand Down
14 changes: 8 additions & 6 deletions src/windows/globalStyles.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import "/theme.css";

@font-face {
font-family: "Raleway-Num";
src: url("/font/Raleway-Regular.ttf") format("truetype");
Expand Down Expand Up @@ -49,19 +51,19 @@ body {
width: 100%;
height: 100%;

background-color: #1a1a1a;
color: rgb(231, 231, 231);
background-color: var(--background);
color: var(--font-color);
font-family: 'Raleway-Num', 'Raleway', sans-serif;

overflow: hidden;
}

a {
color: #00bbff;
color: var(--link-color);
}

a:visited {
color: #005eff;
color: var(--link-color-visited);
}

::-webkit-scrollbar {
Expand All @@ -74,12 +76,12 @@ a:visited {
}

::-webkit-scrollbar-thumb {
background: #383838;
background: var(--foreground-light);
border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
background: #039900;
background: var(--foreground-light-hover);
}

::-webkit-scrollbar-corner {
Expand Down
6 changes: 3 additions & 3 deletions src/windows/main/Main.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import Titlebar from "../../components/Titlebar.svelte";
import { Splitpanes } from 'svelte-splitpanes';
import Footer from "../../components/Footer.svelte";
import Filters from "../../components/core/filters/Filters.svelte";
import Options from "../../components/core/filters/Options.svelte";
import Games from "../../components/core/games/Games.svelte";
import Grids from "../../components/core/grids/Grids.svelte";
import { AppController } from "../../lib/controllers/AppController";
Expand Down Expand Up @@ -69,8 +69,8 @@
</Titlebar>
<div class="content">
<Splitpanes>
<Filters />
<Options />

<Games />

<Grids />
Expand Down
8 changes: 7 additions & 1 deletion src/windows/settings/Settings.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { open } from "@tauri-apps/api/shell"
import { onDestroy, onMount } from "svelte";
import { activeUserId, needsSGDBAPIKey, needsSteamKey, steamGridDBKey, steamKey } from "../../Stores";
import { activeUserId, needsSGDBAPIKey, needsSteamKey, steamGridDBKey, steamKey, theme } from "../../Stores";
import Titlebar from "../../components/Titlebar.svelte";
import Button from "../../components/interactables/Button.svelte";
import HorizontalSpacer from "../../components/spacers/HorizontalSpacer.svelte";
Expand All @@ -10,8 +10,10 @@
import { LogController } from "../../lib/controllers/LogController";
import { SettingsManager } from "../../lib/utils/SettingsManager";
import { WindowController } from "../../lib/controllers/WindowController";
import type { Unsubscriber } from "svelte/store";
let settingsFocusUnsub: any;
let themeUnsub: Unsubscriber;
let canSave = false;
let isFocused = false;
Expand Down Expand Up @@ -85,12 +87,16 @@
settingsFocusUnsub = await WindowController.settingsWindow.onFocusChanged(({ payload: focused }) => {
isFocused = focused;
});
themeUnsub = theme.subscribe((theme) => {
document.documentElement.setAttribute("data-theme", theme == 0 ? "dark" : "light");
});
await SettingsManager.setSettingsPath();
});
onDestroy(() => {
if (settingsFocusUnsub) settingsFocusUnsub();
if (themeUnsub) themeUnsub();
});
</script>

Expand Down

0 comments on commit 1de420f

Please sign in to comment.