pwa adjustments

This commit is contained in:
2023-07-06 01:12:24 +02:00
parent 5a7c4df70a
commit db8b1a72a4
9 changed files with 50 additions and 12 deletions

View File

@@ -0,0 +1,10 @@
import {argbFromHex, hexFromArgb, themeFromSourceColor} from "@material/material-color-utilities"
export const themeBase = "#6D81C7"
export const themeSuccessBase = "#00ff00"
const theme = themeFromSourceColor(argbFromHex(themeBase), [
{name: "success", value: argbFromHex(themeSuccessBase), blend: true},
])
export const themeColor = hexFromArgb(theme.schemes.dark.background)

View File

@@ -0,0 +1,10 @@
import {themeBase, themeColor, themeSuccessBase} from "$lib/style/theme.server.js"
/** @type {import("./$types").LayoutServerLoad} */
export async function load() {
return {
themeSuccessBase,
themeBase,
themeColor,
}
}

View File

@@ -2,22 +2,19 @@
import "$lib/style/fonts/noto-sans-mono.scss" import "$lib/style/fonts/noto-sans-mono.scss"
import "$lib/style/fonts/material-symbols-rounded.scss" import "$lib/style/fonts/material-symbols-rounded.scss"
import {onMount} from "svelte" import {onMount} from "svelte"
import { import {applyTheme, argbFromHex, themeFromSourceColor} from "@material/material-color-utilities"
applyTheme,
argbFromHex,
hexFromArgb,
themeFromSourceColor,
} from "@material/material-color-utilities"
import Navigation from "$lib/components/Navigation.svelte" import Navigation from "$lib/components/Navigation.svelte"
import {hasSerialPermission} from "$lib/serial/device.js" import {hasSerialPermission} from "$lib/serial/device.js"
import {initSerial} from "$lib/serial/connection.js" import {initSerial} from "$lib/serial/connection.js"
import {pwaInfo} from "virtual:pwa-info" import {pwaInfo} from "virtual:pwa-info"
const theme = themeFromSourceColor(argbFromHex("#6D81C7"), [ /** @type {import('./$types').LayoutServerData} */
{name: "success", value: argbFromHex("#00ff00"), blend: true}, export let data
])
onMount(async () => { onMount(async () => {
const theme = themeFromSourceColor(argbFromHex("#6D81C7"), [
{name: "success", value: argbFromHex("#00ff00"), blend: true},
])
const dark = true // window.matchMedia("(prefers-color-scheme: dark)").matches const dark = true // window.matchMedia("(prefers-color-scheme: dark)").matches
applyTheme(theme, {target: document.body, dark}) applyTheme(theme, {target: document.body, dark})
@@ -46,7 +43,7 @@
{@html webManifestLink} {@html webManifestLink}
<title>dot i/o</title> <title>dot i/o</title>
<meta name="description" content="Tool for CharaChorder devices" /> <meta name="description" content="Tool for CharaChorder devices" />
<meta name="theme-color" content={hexFromArgb(theme.schemes.dark.background)} /> <meta name="theme-color" content={data.themeColor} />
</svelte:head> </svelte:head>
<Navigation /> <Navigation />

View File

@@ -2,5 +2,5 @@ import {redirect} from "@sveltejs/kit"
/** @type {import("./$types").PageLoad} */ /** @type {import("./$types").PageLoad} */
export function load() { export function load() {
throw redirect(300, "/config") throw redirect(302, "/config")
} }

View File

@@ -2,5 +2,5 @@ import {redirect} from "@sveltejs/kit"
/** @type {import("./$types").PageLoad} */ /** @type {import("./$types").PageLoad} */
export function load() { export function load() {
throw redirect(300, "/config/chords") throw redirect(302, "/config/chords")
} }

View File

5
static/icon.svg Normal file
View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
<svg version="1.1" width="144" height="144" viewBox="0 0 144 144" xmlns="http://www.w3.org/2000/svg">
<circle cx="72" cy="72" r="44" fill="black" />
<text x="72" y="82" font-size="36" font-weight="900" font-family="monospace" text-anchor="middle" dominant-baseline="middle" fill="white">i/o</text>
</svg>

After

Width:  |  Height:  |  Size: 352 B

View File

@@ -5,6 +5,7 @@ import preprocess from "svelte-preprocess"
const config = { const config = {
preprocess: [preprocess()], preprocess: [preprocess()],
kit: { kit: {
inlineStyleThreshold: 8192,
paths: { paths: {
relative: false, relative: false,
}, },

View File

@@ -1,6 +1,8 @@
import {sveltekit} from "@sveltejs/kit/vite" import {sveltekit} from "@sveltejs/kit/vite"
import {defineConfig} from "vite" import {defineConfig} from "vite"
import {SvelteKitPWA} from "@vite-pwa/sveltekit" import {SvelteKitPWA} from "@vite-pwa/sveltekit"
// noinspection ES6PreferShortImport
// import {themeColor} from "./src/lib/style/theme.server.js"
export default defineConfig({ export default defineConfig({
plugins: [ plugins: [
@@ -10,6 +12,19 @@ export default defineConfig({
adapterFallback: "/200.html", adapterFallback: "/200.html",
trailingSlash: "never", trailingSlash: "never",
}, },
includeAssets: ["favicon.png"],
manifest: {
name: "dot i/o",
id: "dot_io_v2",
// theme_color: themeColor,
icons: [
{
src: "icon.svg",
sizes: "144x144",
type: "image/svg+xml",
},
],
},
base: "/", base: "/",
workbox: { workbox: {
modifyURLPrefix: { modifyURLPrefix: {