diff --git a/client/api/api.ts b/client/api/api.ts index c7e0b96..4205d7e 100644 --- a/client/api/api.ts +++ b/client/api/api.ts @@ -157,6 +157,10 @@ function submitListen(id: string, ts: Date): Promise { }); } +function getCfg(): Promise { + return fetch(`/apis/web/v1/config`).then(r => r.json() as Promise) +} + function getApiKeys(): Promise { return fetch(`/apis/web/v1/user/apikeys`).then( (r) => r.json() as Promise @@ -277,6 +281,7 @@ function getNowPlaying(): Promise { } export { +<<<<<<< HEAD getLastListens, getTopTracks, getTopAlbums, @@ -308,6 +313,37 @@ export { submitListen, getNowPlaying, }; +======= + getLastListens, + getTopTracks, + getTopAlbums, + getTopArtists, + getActivity, + getStats, + search, + replaceImage, + mergeTracks, + mergeAlbums, + mergeArtists, + imageUrl, + login, + logout, + getCfg, + deleteItem, + updateUser, + getAliases, + createAlias, + deleteAlias, + setPrimaryAlias, + getApiKeys, + createApiKey, + deleteApiKey, + updateApiKeyLabel, + deleteListen, + getAlbum, + getExport, +} +>>>>>>> 5d0491a (feat: add server-side configuration with default theme (#90)) type Track = { id: number; title: string; @@ -390,6 +426,7 @@ type ApiKey = { created_at: Date; }; type ApiError = { +<<<<<<< HEAD error: string; }; type Config = { @@ -417,3 +454,27 @@ export type { Config, NowPlaying, }; +======= + error: string +} +type Config = { + default_theme: string +} + +export type { + getItemsArgs, + getActivityArgs, + Track, + Artist, + Album, + Listen, + SearchResponse, + PaginatedResponse, + ListenActivityItem, + User, + Alias, + ApiKey, + ApiError, + Config +} +>>>>>>> 5d0491a (feat: add server-side configuration with default theme (#90)) diff --git a/client/app/components/themeSwitcher/ThemeSwitcher.tsx b/client/app/components/themeSwitcher/ThemeSwitcher.tsx index 74997ae..25670b2 100644 --- a/client/app/components/themeSwitcher/ThemeSwitcher.tsx +++ b/client/app/components/themeSwitcher/ThemeSwitcher.tsx @@ -1,69 +1,78 @@ -import { useState } from 'react'; -import { useTheme } from '../../hooks/useTheme'; -import themes from '~/styles/themes.css'; -import ThemeOption from './ThemeOption'; -import { AsyncButton } from '../AsyncButton'; +import { useState } from "react"; +import { useTheme } from "../../hooks/useTheme"; +import themes from "~/styles/themes.css"; +import ThemeOption from "./ThemeOption"; +import { AsyncButton } from "../AsyncButton"; export function ThemeSwitcher() { -<<<<<<< HEAD - const { setTheme } = useTheme(); -======= - const { theme, themeName, setTheme } = useTheme(); ->>>>>>> fbaa6a6 (Rework theme provider to provide the actual Theme object throughtout the app, in addition to the name) - const initialTheme = { - bg: "#1e1816", - bgSecondary: "#2f2623", - bgTertiary: "#453733", - fg: "#f8f3ec", - fgSecondary: "#d6ccc2", - fgTertiary: "#b4a89c", - primary: "#f5a97f", - primaryDim: "#d88b65", - accent: "#f9db6d", - accentDim: "#d9bc55", - error: "#e26c6a", - warning: "#f5b851", - success: "#8fc48f", - info: "#87b8dd", - } - - const { setCustomTheme, getCustomTheme, resetTheme } = useTheme() - const [custom, setCustom] = useState(JSON.stringify(getCustomTheme() ?? initialTheme, null, " ")) - - const handleCustomTheme = () => { - console.log(custom) - try { - const themeData = JSON.parse(custom) - setCustomTheme(themeData) - setCustom(JSON.stringify(themeData, null, " ")) - console.log(themeData) - } catch(err) { - console.log(err) - } - } + const { setTheme } = useTheme(); + const initialTheme = { + bg: "#1e1816", + bgSecondary: "#2f2623", + bgTertiary: "#453733", + fg: "#f8f3ec", + fgSecondary: "#d6ccc2", + fgTertiary: "#b4a89c", + primary: "#f5a97f", + primaryDim: "#d88b65", + accent: "#f9db6d", + accentDim: "#d9bc55", + error: "#e26c6a", + warning: "#f5b851", + success: "#8fc48f", + info: "#87b8dd", + }; - return ( -
-
-
-

Select Theme

-
- Reset -
-
-
- {Object.entries(themes).map(([name, themeData]) => ( - - ))} -
-
-
-

Use Custom Theme

-
-