Skip to content

Commit

Permalink
fix colors
Browse files Browse the repository at this point in the history
  • Loading branch information
grulex committed Oct 29, 2023
1 parent 6af3eab commit 470888d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
8 changes: 7 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"dotenv": "^16.3.1",
"sanitize-html": "^2.11.0",
"svelte-i18n": "^4.0.0",
"svelte-icons-pack": "^2.1.0"
"svelte-icons-pack": "^2.1.0",
"tinycolor2": "^1.6.0"
}
}
11 changes: 11 additions & 0 deletions src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import DefaultTheme from "./DefaultTheme.svelte";
import { setupI18n, isLoading, _ } from '$lib/i18n';
import { onMount } from "svelte";
import tinycolor from 'tinycolor2';
let isOpenedByTelegram = false;
onMount(() => {
Expand All @@ -12,6 +13,16 @@
lang = 'en'
}
setupI18n({ withLocale: lang });
let bgColor = window.getComputedStyle(document.documentElement).getPropertyValue('--tg-theme-bg-color');
let bgSecondaryColor = window.getComputedStyle(document.documentElement).getPropertyValue('--tg-theme-secondary-bg-color');
bgColor = tinycolor(bgColor);
bgSecondaryColor = tinycolor(bgSecondaryColor);
console.log(bgColor.getBrightness(), bgSecondaryColor.getBrightness())
if (bgColor.getBrightness() < bgSecondaryColor.getBrightness()) {
document.documentElement.style.setProperty('--tg-theme-bg-color', bgSecondaryColor.toString());
document.documentElement.style.setProperty('--tg-theme-secondary-bg-color', bgColor.toString());
}
});
</script>
Expand Down
3 changes: 2 additions & 1 deletion src/routes/wishlists/[wishlist_id]/+layout.server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { error } from '@sveltejs/kit';
import {env} from "$lib/env.js";
import {safetySanitizeWithLinks} from "$lib/safety_html.js";

export async function load({ params, cookies }) {
export async function load({ params, cookies, parent }) {
await parent(); // todo? maybe we should not wait for parent? now it for registration, when executing first request
let token = cookies.get("tg_init_data");
if (env.TG_DEV_INIT_DATA_BASE64) {
token = env.TG_DEV_INIT_DATA_BASE64;
Expand Down

0 comments on commit 470888d

Please sign in to comment.