diff --git a/components/Layout.tsx b/components/Layout.tsx index 2ce4377a..2734f638 100644 --- a/components/Layout.tsx +++ b/components/Layout.tsx @@ -24,14 +24,13 @@ import useInterval from './shared/useInterval' import { Transition } from '@headlessui/react' import { useTranslation } from 'next-i18next' import TermsOfUseModal from './modals/TermsOfUseModal' -import { useTheme } from 'next-themes' const sideBarAnimationDuration = 300 const termsLastUpdated = 1679441610978 const Layout = ({ children }: { children: ReactNode }) => { const { connected } = useWallet() - const { theme } = useTheme() + const themeData = mangoStore((s) => s.themeData) const loadingMangoAccount = mangoStore((s) => s.mangoAccount.initialLoad) const [isCollapsed, setIsCollapsed] = useLocalStorageState( SIDEBAR_COLLAPSE_KEY, @@ -87,7 +86,7 @@ const Layout = ({ children }: { children: ReactNode }) => { ) : null}
{ const { t } = useTranslation(['common', 'search']) const { connected } = useWallet() const group = mangoStore.getState().group + const themeData = mangoStore((s) => s.themeData) const { mangoAccount } = useMangoAccount() const router = useRouter() const { pathname } = router - const { theme } = useTheme() const playAnimation = () => { const set = mangoStore.getState().set @@ -50,17 +50,14 @@ const SideNav = ({ collapsed }: { collapsed: boolean }) => {
- {theme === 'Bonk' && !collapsed ? ( + {themeData.sideImagePath && !collapsed ? ( playAnimation()} - src="/images/themes/bonk/sidenav-image.png" + src={themeData.sideImagePath} alt="next" /> ) : null} @@ -70,24 +67,16 @@ const SideNav = ({ collapsed }: { collapsed: boolean }) => {
- {theme !== 'Bonk' ? ( - next - ) : ( - next - )} + logo { leaveFrom="opacity-100" leaveTo="opacity-0" > - - {theme !== 'Bonk' ? 'Mango' : 'Bongo'} + + {themeData.platformName}
@@ -309,11 +294,7 @@ const MenuItem = ({ hideIconBg ? '' : `flex h-8 w-8 items-center justify-center rounded-full ${ - theme === 'Light' - ? 'bg-th-bkg-2' - : theme === 'Bonk' - ? 'bg-th-button' - : 'bg-th-bkg-3' + theme === 'Light' ? 'bg-th-bkg-2' : 'bg-th-bkg-3' }` } > @@ -375,11 +356,7 @@ export const ExpandableMenuItem = ({ hideIconBg ? '' : `flex h-8 w-8 items-center justify-center rounded-full ${ - theme === 'Light' - ? 'bg-th-bkg-2' - : theme === 'Bonk' - ? 'bg-th-button' - : 'bg-th-bkg-3' + theme === 'Light' ? 'bg-th-bkg-2' : 'bg-th-bkg-3' }` } ${ alignBottom @@ -427,9 +404,7 @@ export const ExpandableMenuItem = ({ className={ hideIconBg ? '' - : `flex h-8 w-8 items-center justify-center rounded-full ${ - theme === 'Bonk' ? 'bg-th-button' : 'bg-th-bkg-3' - }` + : 'flex h-8 w-8 items-center justify-center rounded-full bg-th-bkg-3' } > {icon} diff --git a/components/TopBar.tsx b/components/TopBar.tsx index 60a293fa..c7281c23 100644 --- a/components/TopBar.tsx +++ b/components/TopBar.tsx @@ -30,12 +30,13 @@ import useUnownedAccount from 'hooks/useUnownedAccount' import NotificationsButton from './notifications/NotificationsButton' import Tooltip from './shared/Tooltip' import { copyToClipboard } from 'utils' -import { useTheme } from 'next-themes' +import mangoStore from '@store/mangoStore' const TopBar = () => { const { t } = useTranslation('common') const { mangoAccount } = useMangoAccount() const { connected } = useWallet() + const themeData = mangoStore((s) => s.themeData) const [isOnboarded, setIsOnboarded] = useLocalStorageState(IS_ONBOARDED_KEY) const [action, setAction] = useState<'deposit' | 'withdraw'>('deposit') const [showUserSetup, setShowUserSetup] = useState(false) @@ -49,7 +50,6 @@ const TopBar = () => { const { width } = useViewport() const isMobile = width ? width < breakpoints.sm : false const { isUnownedAccount } = useUnownedAccount() - const { theme } = useTheme() const handleCloseSetup = useCallback(() => { setShowUserSetup(false) @@ -80,11 +80,8 @@ const TopBar = () => { return (
@@ -101,19 +98,11 @@ const TopBar = () => {
) : null} - {theme !== 'Bonk' ? ( - next - ) : ( - next - )} + logo {!connected ? ( mangoAccount ? ( diff --git a/components/settings/DisplaySettings.tsx b/components/settings/DisplaySettings.tsx index 3aa64130..fade53c8 100644 --- a/components/settings/DisplaySettings.tsx +++ b/components/settings/DisplaySettings.tsx @@ -22,8 +22,9 @@ import { TRADE_CHART_UI_KEY, TRADE_LAYOUT_KEY, } from 'utils/constants' -import mangoStore from '@store/mangoStore' +import mangoStore, { DEFAULT_THEME_DATA } from '@store/mangoStore' import { useWallet } from '@solana/wallet-adapter-react' +import { ThemeData } from 'types' const NOTIFICATION_POSITIONS = [ 'bottom-left', @@ -61,6 +62,19 @@ export const THEMES = [ 'olive', ] +const BONK_META_DATA: ThemeData = { + buttonStyle: 'raised', + logoPath: '/images/themes/bonk/bonk-logo.png', + platformName: 'Bongo', + rainAnimationImagePath: '/images/themes/bonk/bonk-animation-logo.png', + sideImagePath: '/images/themes/bonk/sidenav-image.png', + sideTilePath: '/images/themes/bonk/bonk-tile.png', + topTilePath: '/images/themes/bonk/bonk-tile.png', + tvChartTheme: 'Light', + tvImagePath: '', + useGradientBg: true, +} + const DisplaySettings = () => { const { t } = useTranslation(['common', 'settings']) const { theme, setTheme } = useTheme() @@ -96,6 +110,20 @@ const DisplaySettings = () => { } }, [connection, publicKey]) + // set nft skin data to store and localStorage (move this to theme selection). will need to use localStorage for page reloads + useEffect(() => { + const set = mangoStore.getState().set + if (theme === 'Bonk') { + set((s) => { + s.themeData = BONK_META_DATA + }) + } else { + set((s) => { + s.themeData = DEFAULT_THEME_DATA + }) + } + }, [theme]) + // use collectionAddress to enable nft skins? console.log(nfts) diff --git a/components/shared/Button.tsx b/components/shared/Button.tsx index f4bff783..dfaaa738 100644 --- a/components/shared/Button.tsx +++ b/components/shared/Button.tsx @@ -1,3 +1,4 @@ +import mangoStore from '@store/mangoStore' import { useTheme } from 'next-themes' import { forwardRef, FunctionComponent, ReactNode, Ref } from 'react' @@ -27,13 +28,14 @@ const Button: FunctionComponent = ({ ...props }) => { const { theme } = useTheme() + const themeData = mangoStore((s) => s.themeData) return (