Skip to content

Commit

Permalink
Revert "Remove assetUrl prefix (#1133)"
Browse files Browse the repository at this point in the history
This reverts commit 7cf582a.
  • Loading branch information
tarrencev committed Dec 10, 2024
1 parent 7cf582a commit a62f2b6
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/keychain/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export function ControllerThemeProvider({
children,
theme = defaultTheme,
}: PropsWithChildren<{ theme?: ControllerTheme }>) {
useThemeEffect({ theme });
useThemeEffect({ theme, assetUrl: "" });
const chakraTheme = useChakraTheme(theme);

return (
Expand Down
2 changes: 1 addition & 1 deletion packages/keychain/src/components/Provider/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { PropsWithChildren, useEffect, useMemo } from "react";
export function ControllerThemeProvider({ children }: PropsWithChildren) {
const { theme } = useConnection();

useThemeEffect({ theme });
useThemeEffect({ theme, assetUrl: "" });
const chakraTheme = useChakraTheme(theme);

return (
Expand Down
1 change: 1 addition & 0 deletions packages/profile/.env.development
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
VITE_CARTRIDGE_API_URL="https://api.cartridge.gg"
VITE_KEYCHAIN_URL="http://localhost:3001"
VITE_RPC_SEPOLIA="https://api.cartridge.gg/x/starknet/sepolia"
VITE_POSTHOG_KEY=phc_UWaJajNQ00PjHhveZ81SJ2zVtBicKrzewdZHGiyavQQ
VITE_POSTHOG_HOST=https://profile.cartridge.gg/ingest
1 change: 1 addition & 0 deletions packages/profile/.env.production
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
VITE_CARTRIDGE_API_URL="https://api.cartridge.gg"
VITE_KEYCHAIN_URL="https://x.cartridge.gg"
VITE_RPC_SEPOLIA="https://api.cartridge.gg/x/starknet/sepolia"
VITE_POSTHOG_KEY=phc_UWaJajNQ00PjHhveZ81SJ2zVtBicKrzewdZHGiyavQQ
VITE_POSTHOG_HOST=https://profile.cartridge.gg/ingest
2 changes: 1 addition & 1 deletion packages/profile/src/components/context/theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export function ThemeProvider({
setTheme(JSON.parse(val));
}, [themeParam, origin]);

useThemeEffect({ theme });
useThemeEffect({ theme, assetUrl: import.meta.env.VITE_KEYCHAIN_URL });

const value = {
colorScheme,
Expand Down
16 changes: 11 additions & 5 deletions packages/ui-next/src/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import { useEffect } from "react";
import { hexToHsl } from "@cartridge/utils";

export function useThemeEffect({ theme }: { theme: ControllerTheme }) {
export function useThemeEffect({
theme,
assetUrl,
}: {
theme: ControllerTheme;
assetUrl: string;
}) {
useEffect(() => {
if (!theme) return;

Expand All @@ -11,12 +17,12 @@ export function useThemeEffect({ theme }: { theme: ControllerTheme }) {

document.documentElement.style.setProperty(
"--theme-icon-url",
`url("${theme.icon}")`,
`url("${assetUrl}${theme.icon}")`,
);
const coverUrl =
typeof theme.cover === "string"
? `url("${theme.cover}")`
: `url("${theme.cover[appliedColorMode]}")`;
? `url("${assetUrl}${theme.cover}")`
: `url("${assetUrl}${theme.cover[appliedColorMode]}")`;
document.documentElement.style.setProperty("--theme-cover-url", coverUrl);

if (!theme.colors) return;
Expand All @@ -39,7 +45,7 @@ export function useThemeEffect({ theme }: { theme: ControllerTheme }) {
hexToHsl(val),
);
}
}, [theme]);
}, [theme, assetUrl]);
}

// dup of @cartridge/controller/types
Expand Down

0 comments on commit a62f2b6

Please sign in to comment.