Use css vars for colour themes
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Melon 2022-10-24 17:51:30 +01:00
parent affe4a5541
commit db8ed96b71
Signed by: melon
GPG Key ID: 6C9D970C50D26A25
5 changed files with 45 additions and 13 deletions

3
.env.template Normal file
View File

@ -0,0 +1,3 @@
VITE_API_URL=https://api.example.com
VITE_TITLE=Title
VITE_CSS_VAR=https://example.com/path/to/vars.css

View File

@ -15,6 +15,10 @@
}); });
</script> </script>
<svelte:head>
<link rel="stylesheet" href={import.meta.env.VITE_CSS_VAR} />
</svelte:head>
<div id="app"> <div id="app">
<Router primary={false}> <Router primary={false}>
<header> <header>
@ -70,7 +74,7 @@
height: 80px; height: 80px;
min-height: 80px; min-height: 80px;
max-height: 80px; max-height: 80px;
background-color: #25662854; background-color: var(--primary);
border-radius: 0 0 16px 16px; border-radius: 0 0 16px 16px;
} }

View File

@ -5,8 +5,8 @@
font-weight: 400; font-weight: 400;
color-scheme: light dark; color-scheme: light dark;
color: rgba(255, 255, 255, 0.87); color: var(--primary-text);
background-color: #242424; background-color: var(--primary-bg);
font-synthesis: none; font-synthesis: none;
text-rendering: optimizeLegibility; text-rendering: optimizeLegibility;
@ -17,12 +17,12 @@
a { a {
font-weight: 500; font-weight: 500;
color: #64dd6caa; color: var(--primary-component);
text-decoration: inherit; text-decoration: inherit;
} }
a:hover { a:hover {
color: #53f25bee; color: var(--primary-hover);
} }
body { body {
@ -36,13 +36,13 @@ button {
font-size: 1em; font-size: 1em;
font-weight: 500; font-weight: 500;
font-family: inherit; font-family: inherit;
background-color: #1a1a1a; background-color: var(--primary-component);
cursor: pointer; cursor: pointer;
transition: border-color 0.25s; transition: border-color 0.25s;
} }
button:hover { button:hover {
border-color: #64dd6caa; border-color: var(--primary-hover);
} }
button:focus, button:focus,

View File

@ -3,11 +3,13 @@
import { navigate, useLocation } from "svelte-navigator"; import { navigate, useLocation } from "svelte-navigator";
import { getUser } from "~/api/login"; import { getUser } from "~/api/login";
import { getOAuthApp } from "~/api/oauth"; import { getOAuthApp } from "~/api/oauth";
import LazyComponent from "~/lib/LazyComponent.svelte";
import LazyDelay from "~/lib/LazyDelay.svelte"; import LazyDelay from "~/lib/LazyDelay.svelte";
let location = useLocation(); let location = useLocation();
let app; let app: {
app_name: string;
app_desc: string;
};
onMount(async () => { onMount(async () => {
try { try {
@ -26,13 +28,35 @@
}); });
</script> </script>
<div> <div class="page">
{#if app} {#if app}
<div> <div class="main">
<h2>{app.app_name}</h2> <h2 class="oauth-title">{app.app_name}</h2>
<div>{app.app_desc}</div> <div class="oauth-desc">{app.app_desc}</div>
</div> </div>
{:else} {:else}
<LazyDelay delayMs={500} /> <LazyDelay delayMs={500} />
{/if} {/if}
</div> </div>
<style>
.page {
display: flex;
}
.main {
margin: auto;
background: var(--bg-panel);
padding: 32px;
border-radius: 32px;
}
.main > .oauth-title {
line-height: normal;
text-align: center;
}
.main > .oauth-desc {
text-align: center;
}
</style>

1
src/vite-env.d.ts vendored
View File

@ -4,6 +4,7 @@
interface ImportMetaEnv { interface ImportMetaEnv {
readonly VITE_API_URL: string; readonly VITE_API_URL: string;
readonly VITE_TITLE: string; readonly VITE_TITLE: string;
readonly VITE_CSS_VAR: string;
} }
interface ImportMeta { interface ImportMeta {