mirror of
https://github.com/makeplane/plane.git
synced 2025-12-20 13:49:33 +01:00
18 lines
512 B
TypeScript
18 lines
512 B
TypeScript
|
|
import { useTheme } from "next-themes";
|
||
|
|
|
||
|
|
type AssetPathConfig = {
|
||
|
|
basePath: string;
|
||
|
|
additionalPath?: string;
|
||
|
|
extension?: string;
|
||
|
|
};
|
||
|
|
|
||
|
|
export const useResolvedAssetPath = ({ basePath, additionalPath = "", extension = "webp" }: AssetPathConfig) => {
|
||
|
|
// hooks
|
||
|
|
const { resolvedTheme } = useTheme();
|
||
|
|
|
||
|
|
// resolved theme
|
||
|
|
const theme = resolvedTheme === "light" ? "light" : "dark";
|
||
|
|
|
||
|
|
return `${additionalPath && additionalPath !== "" ? `${basePath}${additionalPath}` : basePath}-${theme}.${extension}`;
|
||
|
|
};
|