Skip to content

Commit 84b89e2

Browse files
committed
update theme generation logic
1 parent 7db3e9b commit 84b89e2

11 files changed

Lines changed: 400 additions & 157 deletions

File tree

apps/yaak-client/hooks/usePreferredAppearance.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useEffect, useState } from "react";
2-
import type { Appearance } from "../lib/theme/appearance";
3-
import { getCSSAppearance, subscribeToPreferredAppearance } from "../lib/theme/appearance";
2+
import type { Appearance } from "@yaakapp-internal/theme";
3+
import { getCSSAppearance, subscribeToPreferredAppearance } from "@yaakapp-internal/theme";
44

55
export function usePreferredAppearance() {
66
const [preferredAppearance, setPreferredAppearance] = useState<Appearance>(getCSSAppearance());

apps/yaak-client/hooks/useResolvedAppearance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { settingsAtom } from "@yaakapp-internal/models";
2+
import { resolveAppearance } from "@yaakapp-internal/theme";
23
import { useAtomValue } from "jotai";
3-
import { resolveAppearance } from "../lib/theme/appearance";
44
import { usePreferredAppearance } from "./usePreferredAppearance";
55

66
export function useResolvedAppearance() {

apps/yaak-client/hooks/useResolvedTheme.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useQuery } from "@tanstack/react-query";
22
import { settingsAtom } from "@yaakapp-internal/models";
33
import { useAtomValue } from "jotai";
4-
import { getResolvedTheme, getThemes } from "../lib/theme/themes";
4+
import { getResolvedTheme, getThemes } from "../lib/themes";
55
import { usePluginsKey } from "./usePlugins";
66
import { usePreferredAppearance } from "./usePreferredAppearance";
77

apps/yaak-client/lib/theme/appearance.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

apps/yaak-client/lib/theme/window.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

apps/yaak-client/lib/theme/yaakColor.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import type { GetThemesResponse } from "@yaakapp-internal/plugins";
2-
import { defaultDarkTheme, defaultLightTheme } from "@yaakapp-internal/theme";
3-
import { invokeCmd } from "../tauri";
4-
import type { Appearance } from "./appearance";
5-
import { resolveAppearance } from "./appearance";
6-
7-
export { defaultDarkTheme, defaultLightTheme } from "@yaakapp-internal/theme";
2+
import {
3+
defaultDarkTheme,
4+
defaultLightTheme,
5+
resolveAppearance,
6+
type Appearance,
7+
} from "@yaakapp-internal/theme";
8+
import { invokeCmd } from "./tauri";
89

910
export async function getThemes() {
1011
const themes = (await invokeCmd<GetThemesResponse[]>("cmd_get_themes")).flatMap((t) => t.themes);

apps/yaak-client/theme.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@ import { listen } from "@tauri-apps/api/event";
22
import { getCurrentWebviewWindow } from "@tauri-apps/api/webviewWindow";
33
import { setWindowTheme } from "@yaakapp-internal/mac-window";
44
import type { ModelPayload } from "@yaakapp-internal/models";
5+
import type { Appearance } from "@yaakapp-internal/theme";
6+
import {
7+
applyThemeToDocument,
8+
getCSSAppearance,
9+
subscribeToPreferredAppearance,
10+
} from "@yaakapp-internal/theme";
511
import { getSettings } from "./lib/settings";
6-
import type { Appearance } from "./lib/theme/appearance";
7-
import { getCSSAppearance, subscribeToPreferredAppearance } from "./lib/theme/appearance";
8-
import { getResolvedTheme } from "./lib/theme/themes";
9-
import { applyThemeToDocument } from "@yaakapp-internal/theme";
12+
import { getResolvedTheme } from "./lib/themes";
1013

1114
// NOTE: CSS appearance isn't as accurate as getting it async from the window (next step), but we want
1215
// a good appearance guess so we're not waiting too long

packages/theme/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ export type { DocumentPlatform, YaakColorKey, YaakColors, YaakTheme } from "./wi
1212
export {
1313
addThemeStylesToDocument,
1414
applyThemeToDocument,
15+
completeColorVariables,
16+
completeFullColorVariables,
17+
completePartialColorVariables,
1518
completeTheme,
1619
getThemeCSS,
1720
indent,

0 commit comments

Comments
 (0)