Skip to content

Commit

Permalink
refactor: rename UserAgentContext to IsMobileUAContext, update all oc…
Browse files Browse the repository at this point in the history
…currences
  • Loading branch information
viktoriabakun authored and olegshilov committed Sep 3, 2024
1 parent 2e43bda commit a113f2b
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 30 deletions.
6 changes: 3 additions & 3 deletions apps/shell/src/providers/app-providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
CosmosProvider,
ReactQueryProvider,
Toaster,
UserAgentProvider,
IsMobileUAProvider,
WalletProvider,
} from '@haqq/shell-shared';
import { WalletModals } from '../components/wallet-modals';
Expand All @@ -31,7 +31,7 @@ export function AppProviders({
: createWagmiConfig(walletConnectProjectId);

return (
<UserAgentProvider isMobileUA={isMobileUA}>
<IsMobileUAProvider isMobileUA={isMobileUA}>
<WagmiProvider config={actualWagmiConfig} initialState={initialState}>
<ReactQueryProvider withDevtools dehydratedState={dehydratedState}>
<CosmosProvider>
Expand All @@ -43,6 +43,6 @@ export function AppProviders({
</CosmosProvider>
</ReactQueryProvider>
</WagmiProvider>
</UserAgentProvider>
</IsMobileUAProvider>
);
}
2 changes: 1 addition & 1 deletion libs/shared/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export * from './providers/cosmos-provider';
export * from './providers/react-query-provider';
export * from './providers/toaster';
export * from './providers/wallet-provider';
export * from './providers/user-agent-provider';
export * from './providers/is-mobile-ua-provider';

export * from './hooks/use-account-info/use-account-info';
export * from './hooks/use-address/use-address';
Expand Down
24 changes: 24 additions & 0 deletions libs/shared/src/providers/is-mobile-ua-provider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use client';
import { createContext, ReactNode, useContext } from 'react';

export const IsMobileUAContext = createContext(false);

export function IsMobileUAProvider({
isMobileUA,
children,
}: {
isMobileUA: boolean;
children: ReactNode;
}) {
return (
<IsMobileUAContext.Provider value={isMobileUA}>
{children}
</IsMobileUAContext.Provider>
);
}

export function useIsMobileUA() {
const isMobileUA = useContext(IsMobileUAContext);

return isMobileUA;
}
24 changes: 0 additions & 24 deletions libs/shared/src/providers/user-agent-provider.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions libs/ui-kit/src/lib/header-mobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import clsx from 'clsx';
import Image from 'next/image';
import Link from 'next/link';
import { useScrollLock } from 'usehooks-ts';
import { useUserAgent } from '@haqq/shell-shared';
import { useIsMobileUA } from '@haqq/shell-shared';
import { BurgerButton } from './burger-button';
import { Container } from './container';
import { HeaderNavLink } from './header-nav-link';
Expand Down Expand Up @@ -143,7 +143,7 @@ function AnimatedOrNot({
baseHeaderStyles,
children,
}: PropsWithChildren<{ baseHeaderStyles: string }>) {
const { isMobileUA } = useUserAgent();
const isMobileUA = useIsMobileUA();

return isMobileUA ? (
<StaticHeader baseHeaderStyles={baseHeaderStyles}>{children}</StaticHeader>
Expand Down

0 comments on commit a113f2b

Please sign in to comment.