Skip to content

Commit

Permalink
Implemented light & dark mode switching. Implemented MultiInstances s…
Browse files Browse the repository at this point in the history
…upport.
  • Loading branch information
OrigamingWasTaken committed Jun 29, 2024
1 parent 0d918e3 commit 3ca63ef
Show file tree
Hide file tree
Showing 14 changed files with 487 additions and 402 deletions.
5 changes: 5 additions & 0 deletions frontend/src/lib/appleblox.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// utility functions, other utils.ts file comes from shadcn

export function sleep(ms = 0) {
return new Promise(resolve => setTimeout(resolve, ms));
}
4 changes: 2 additions & 2 deletions frontend/src/lib/components/ui/switch/switch.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
>
<SwitchPrimitive.Thumb
class={cn(
"pointer-events-none block h-5 w-5 rounded-full bg-slate-800 grayscale shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0 data-[state=unchecked]:outline-gray-500 data-[state=unchecked]:outline-[1.7px] data-[state=unchecked]:outline"
"pointer-events-none block h-5 w-5 rounded-full bg-slate-100 dark:bg-slate-800 grayscale shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0 data-[state=unchecked]:outline-gray-500 data-[state=unchecked]:outline-[1.7px] data-[state=unchecked]:outline"
)}
/>
</SwitchPrimitive.Root>
</SwitchPrimitive.Root>
12 changes: 8 additions & 4 deletions frontend/src/windows/main/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import Integrations from "./pages/Integrations.svelte";
import { fly } from "svelte/transition";
import FastFlags from "./pages/FastFlags.svelte";
import { ModeWatcher } from "mode-watcher";
import { Toaster } from "$lib/components/ui/sonner";
import { Progress } from "$lib/components/ui/progress";
import { debug, os } from "@neutralinojs/lib";
import { onMount } from "svelte";
import { hasRoblox } from "./ts/roblox";
import Misc from "./pages/Misc.svelte";
import { toast } from "svelte-sonner";
import { debug, os } from "@neutralinojs/lib";
import { ModeWatcher, setMode } from "mode-watcher";
let currentPage: string;
let launchingRoblox = false;
Expand All @@ -24,11 +24,15 @@
}
// Implement launching logic
}
// Darkmode
setMode("system")
</script>

<main>
<ModeWatcher track={true}/>
<Toaster richColors />
<ModeWatcher defaultMode="dark" />
<!-- Content div -->
{#if launchingRoblox}
<div class="h-full w-full flex justify-center items-center fixed top-0 left-0 flex-col">
Expand Down
144 changes: 72 additions & 72 deletions frontend/src/windows/main/Sidebar/Sidebar.svelte
Original file line number Diff line number Diff line change
@@ -1,75 +1,75 @@
<script lang="ts">
import {Separator} from '$lib/components/ui/separator/index.js';
import {createEventDispatcher} from 'svelte';
import logo from '@/assets/favicon.png';
import {os} from '@neutralinojs/lib';
import IntegrationsIcon from '@/assets/sidebar/integrations.png';
import FastFlagsIcon from '@/assets/sidebar/fastflags.png';
import CommingSoonIcon from '@/assets/sidebar/comingsoon.png';
import RobloxIcon from '@/assets/sidebar/roblox.png';
import MiscIcon from "@/assets/sidebar/misc.png"
import SidebarBtn from './SidebarBtn.svelte';
import Button from '$lib/components/ui/button/button.svelte';
interface SidebarItem {
label: string;
id: string;
icon: string;
}
const sidebarBtns: SidebarItem[] = [
{label: 'Integrations', id: 'integrations', icon: IntegrationsIcon},
{label: 'Fast Flags', id: 'fastflags', icon: FastFlagsIcon},
{label: 'Misc', id: 'misc', icon: MiscIcon},
{label: 'Coming Soon', id: 'none', icon: CommingSoonIcon},
];
export let currentPage: string = 'integrations';
export let id: string;
function sidebarItemClicked(e: CustomEvent) {
if (e.detail === 'none') return;
currentPage = e.detail;
}
const dispatch = createEventDispatcher<{launchRoblox: boolean}>();
</script>

<div class="h-full bg-[#1B1B1B] w-36 fixed top-0 left-0 overflow-x-hidden select-none" {id}>
<a
href="https://github.com/OrigamingWasTaken/appleblox"
class="flex justify-center"
target="_blank"
rel="noreferrer"
on:click={() => {
os.open('https://github.com/OrigamingWasTaken/appleblox').catch(console.error);
}}>
<div class="mt-3 flex">
<img src={logo} class="h-6 mr-1 opacity-85 logo" alt="Svelte Logo" />
<p class="text-white font-bold font-mono logo">AppleBlox</p>
import {Separator} from '$lib/components/ui/separator/index.js';
import {createEventDispatcher} from 'svelte';
import logo from '@/assets/favicon.png';
import {os} from '@neutralinojs/lib';
import IntegrationsIcon from '@/assets/sidebar/integrations.png';
import FastFlagsIcon from '@/assets/sidebar/fastflags.png';
import CommingSoonIcon from '@/assets/sidebar/comingsoon.png';
import RobloxIcon from '@/assets/sidebar/roblox.png';
import MiscIcon from "@/assets/sidebar/misc.png"
import SidebarBtn from './SidebarBtn.svelte';
import Button from '$lib/components/ui/button/button.svelte';
interface SidebarItem {
label: string;
id: string;
icon: string;
}
const sidebarBtns: SidebarItem[] = [
{label: 'Integrations', id: 'integrations', icon: IntegrationsIcon},
{label: 'Fast Flags', id: 'fastflags', icon: FastFlagsIcon},
{label: 'Misc', id: 'misc', icon: MiscIcon},
{label: 'Coming Soon', id: 'none', icon: CommingSoonIcon},
];
export let currentPage: string = 'integrations';
export let id: string;
function sidebarItemClicked(e: CustomEvent) {
if (e.detail === 'none') return;
currentPage = e.detail;
}
const dispatch = createEventDispatcher<{launchRoblox: boolean}>();
</script>

<div class="h-full bg-[#F3F4F6] dark:bg-[#1B1B1B] w-36 fixed top-0 left-0 overflow-x-hidden select-none" {id}>
<a
href="https://github.com/OrigamingWasTaken/appleblox"
class="flex justify-center"
target="_blank"
rel="noreferrer"
on:click={() => {
os.open('https://github.com/OrigamingWasTaken/appleblox').catch(console.error);
}}>
<div class="mt-3 flex">
<img src={logo} class="h-6 mr-1 opacity-85 logo bg-[#dcdcdc] dark:bg-[#1B1B1B] rounded-lg" alt="Svelte Logo" />
<p class="text-black dark:text-white font-bold font-mono logo">AppleBlox</p>
</div>
</a>
<div class="m-4">
<Separator class="my-4 bg-gray-500" />
</div>
</a>
<div class="m-4">
<Separator class="my-4 bg-gray-500" />
</div>
<div class="mt-3 grid grid-cols-1">
{#each sidebarBtns as { label, id, icon }}
<SidebarBtn bind:currentPage {label} {id} {icon} on:sidebarClick={sidebarItemClicked} />
{/each}
<div class="mt-3 grid grid-cols-1">
{#each sidebarBtns as { label, id, icon }}
<SidebarBtn bind:currentPage {label} {id} {icon} on:sidebarClick={sidebarItemClicked} />
{/each}
</div>
<Button
class="flex bg-green-600 hover:bg-green-800 fixed bottom-4 left-5 font-mono"
on:click={() => {
dispatch('launchRoblox', true);
}}>
<p class="font-mono">Launch</p>
<img src={RobloxIcon} alt="Roblox Icon" class="ml-1 mt-[1px] w-5 h-5 towhite" />
</Button>
</div>
<Button
class="flex bg-green-600 hover:bg-green-800 fixed bottom-4 left-5 font-mono"
on:click={() => {
dispatch('launchRoblox', true);
}}>
Launch
<img src={RobloxIcon} alt="Roblox Icon" class="ml-1 mt-[1px] w-5 h-5 towhite" />
</Button>
</div>

<style>
.logo {
filter: drop-shadow(0 0 2em #ff6464aa);
}
</style>

<style>
.logo {
filter: drop-shadow(0 0 2em #ff6464aa);
}
</style>
36 changes: 18 additions & 18 deletions frontend/src/windows/main/Sidebar/SidebarBtn.svelte
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<script lang="ts">
export let label: string;
export let icon: string;
export let id: string;
import {createEventDispatcher} from 'svelte';
export let currentPage: string;
const dispatch = createEventDispatcher<{sidebarClick: string}>();
</script>

<button
class="flex items-center justify-center mb-2"
on:click={() => {
dispatch('sidebarClick', id);
}}>
<img src={icon} alt="Sidebar icon" class="w-[15px] towhite mr-1" />
<p class={`${currentPage === id ? 'text-red-400 hover:text-red-300' : 'text-gray-300 hover:text-gray-50'} transition duration-100 font-mono text-[14px]`}>{label}</p>
</button>
export let label: string;
export let icon: string;
export let id: string;
import {createEventDispatcher} from 'svelte';
export let currentPage: string;
const dispatch = createEventDispatcher<{sidebarClick: string}>();
</script>
<button
class="flex items-center justify-center mb-2"
on:click={() => {
dispatch('sidebarClick', id);
}}>
<img src={icon} alt="Sidebar icon" class="w-[15px] towhite mr-1" />
<p class={`${currentPage === id ? 'text-red-400 hover:text-red-300' : 'text-black hover:opacity-50 dark:text-gray-300 dark:hover:text-gray-50'} transition duration-100 font-mono text-[14px]`}>{label}</p>
</button>
112 changes: 56 additions & 56 deletions frontend/src/windows/main/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,19 @@

/* For WebKit-based browsers */
::-webkit-scrollbar {
width: 12px; /* Width of the scrollbar */
width: 12px; /* Width of the scrollbar */
}

::-webkit-scrollbar-thumb {
background: #5d3b3b; /* Color of the scrollbar thumb (the draggable part) */
border-radius: 15px;
background: #5d3b3b; /* Color of the scrollbar thumb (the draggable part) */
border-radius: 15px;
}


:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;

color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;

Expand All @@ -29,54 +27,50 @@
}

@layer base {
:root {
--background: 0 0% 100%;
--foreground: 240 10% 3.9%;
--card: 0 0% 100%;
--card-foreground: 240 10% 3.9%;
--popover: 0 0% 100%;
--popover-foreground: 240 10% 3.9%;
--primary: 346.8 77.2% 49.8%;
--primary-foreground: 355.7 100% 97.3%;
--secondary: 240 4.8% 95.9%;
--secondary-foreground: 240 5.9% 10%;
--muted: 240 4.8% 95.9%;
--muted-foreground: 240 3.8% 46.1%;
--accent: 240 4.8% 95.9%;
--accent-foreground: 240 5.9% 10%;
--destructive: 0 72.22% 50.59%;
--destructive-foreground: 0 0% 98%;
--border: 240 5.9% 90%;
--input: 240 5.9% 90%;
--ring: 346.8 77.2% 49.8%;
--radius: 0.3rem;
}
.dark {
--background: 20 14.3% 4.1%;
--foreground: 0 0% 95%;
--card: 24 9.8% 10%;
--card-foreground: 0 0% 95%;
--popover: 0 0% 9%;
--popover-foreground: 0 0% 95%;
--primary: 346.8 77.2% 49.8%;
--primary-foreground: 355.7 100% 97.3%;
--secondary: 240 3.7% 15.9%;
--secondary-foreground: 0 0% 98%;
--muted: 0 0% 15%;
--muted-foreground: 240 5% 64.9%;
--accent: 12 6.5% 15.1%;
--accent-foreground: 0 0% 98%;
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 0 85.7% 97.3%;
--border: 240 3.7% 15.9%;
--input: 240 3.7% 15.9%;
--ring: 346.8 77.2% 49.8%;
}
}

.towhite {
-webkit-filter: grayscale(1) invert(1);
filter: grayscale(1) invert(1);
:root {
--background: 360 11% 95%;
--foreground: 360 5% 10%;
--card: 360 11% 90%;
--card-foreground: 360 5% 15%;
--popover: 360 11% 95%;
--popover-foreground: 360 95% 10%;
--primary: 360 38% 56%;
--primary-foreground: 0 0% 100%;
--secondary: 360 11% 70%;
--secondary-foreground: 0 0% 0%;
--muted: 322 11% 85%;
--muted-foreground: 360 5% 35%;
--accent: 322 11% 80%;
--accent-foreground: 360 5% 15%;
--destructive: 0 50% 30%;
--destructive-foreground: 360 5% 90%;
--border: 360 20% 50%;
--input: 360 20% 23%;
--ring: 360 38% 56%;
--radius: 0.3rem;
}
.dark {
--background: 360 11% 10%;
--foreground: 360 5% 90%;
--card: 360 11% 10%;
--card-foreground: 360 5% 90%;
--popover: 360 11% 5%;
--popover-foreground: 360 5% 90%;
--primary: 360 38% 56%;
--primary-foreground: 0 0% 100%;
--secondary: 360 11% 20%;
--secondary-foreground: 0 0% 100%;
--muted: 322 11% 23%;
--muted-foreground: 360 5% 60%;
--accent: 322 11% 23%;
--accent-foreground: 360 5% 90%;
--destructive: 0 50% 30%;
--destructive-foreground: 360 5% 90%;
--border: 360 20% 23%;
--input: 360 20% 23%;
--ring: 360 38% 56%;
--radius: 0.3rem;
}
}

a {
Expand All @@ -93,9 +87,8 @@ body {
line-height: 1.5;
font-weight: 400;

color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;
background-color: light-dark(#fff, #242424);

font-synthesis: none;
text-rendering: optimizeLegibility;
Expand All @@ -106,7 +99,7 @@ body {
place-items: center;
min-width: 320px;
min-height: 100vh;
overflow: hidden;
overflow: hidden;
}

h1 {
Expand All @@ -133,3 +126,10 @@ h1 {
@apply bg-background text-foreground;
}
}

@media (prefers-color-scheme: dark) {
.towhite {
-webkit-filter: grayscale(1) invert(1);
filter: grayscale(1) invert(1);
}
}
Loading

0 comments on commit 3ca63ef

Please sign in to comment.