Files
plane/web/core/hooks/use-resolved-asset-path.tsx
Anmol Singh Bhatia 4432be15e4 [WEB-3166] chore: global empty state components (#6414)
* chore: detailed and simple empty state component added

* chore: section empty state component added

* chore: asset path helper hook added
2025-01-17 13:52:08 +05:30

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}`;
};