mirror of
https://github.com/outline/outline.git
synced 2025-07-13 22:26:41 +00:00
* Upgrade Prettier to v3.6.2 and eslint-plugin-prettier to v5.5.1 - Upgraded prettier from ^2.8.8 to ^3.6.2 (latest version) - Upgraded eslint-plugin-prettier from ^4.2.1 to ^5.5.1 for compatibility - Applied automatic formatting changes from new Prettier version - All existing ESLint and Prettier configurations remain compatible * Applied automatic fixes * Trigger CI --------- Co-authored-by: codegen-sh[bot] <131295404+codegen-sh[bot]@users.noreply.github.com> Co-authored-by: Tom Moor <tom@getoutline.com>
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import { useMemo } from "react";
|
|
import { breakpoints } from "@shared/styles";
|
|
import {
|
|
buildDarkTheme,
|
|
buildLightTheme,
|
|
buildPitchBlackTheme,
|
|
} from "@shared/styles/theme";
|
|
import { CustomTheme } from "@shared/types";
|
|
import type { Theme } from "~/stores/UiStore";
|
|
import useMediaQuery from "~/hooks/useMediaQuery";
|
|
import useStores from "./useStores";
|
|
|
|
/**
|
|
* Builds a theme based on the current user's preferences, the current device
|
|
* and the custom theme provided.
|
|
*
|
|
* @param customTheme Custom theme to merge with the default theme
|
|
* @param overrideTheme Optional override the theme to use
|
|
* @returns The theme to use
|
|
*/
|
|
export default function useBuildTheme(
|
|
customTheme: Partial<CustomTheme> = {},
|
|
overrideTheme?: Theme
|
|
) {
|
|
const { ui } = useStores();
|
|
const isMobile = useMediaQuery(`(max-width: ${breakpoints.tablet}px)`);
|
|
const isPrinting = useMediaQuery("print");
|
|
const resolvedTheme = overrideTheme ?? ui.resolvedTheme;
|
|
|
|
const theme = useMemo(
|
|
() =>
|
|
isPrinting
|
|
? buildLightTheme(customTheme)
|
|
: isMobile
|
|
? resolvedTheme === "dark"
|
|
? buildPitchBlackTheme(customTheme)
|
|
: buildLightTheme(customTheme)
|
|
: resolvedTheme === "dark"
|
|
? buildDarkTheme(customTheme)
|
|
: buildLightTheme(customTheme),
|
|
[customTheme, isMobile, isPrinting, resolvedTheme]
|
|
);
|
|
|
|
return theme;
|
|
}
|