Skip to content

Commit

Permalink
Merge branch 'main' into chalabi/mobile_on_desktop
Browse files Browse the repository at this point in the history
Signed-off-by: Joseph Chalabi <[email protected]>
  • Loading branch information
chalabi2 authored Dec 18, 2024
2 parents a8cb41d + 3708021 commit d5ee8ec
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ yarn-error.log*
next-env.d.ts

.idea/

certificates
13 changes: 8 additions & 5 deletions components/react/authSignerModal.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { Fragment, useEffect } from 'react';
import { Dialog, Transition } from '@headlessui/react';
import { useEffect } from 'react';
import { SignData } from '@cosmos-kit/web3auth';
import { SignDoc } from '@liftedinit/manifestjs/dist/codegen/cosmos/tx/v1beta1/tx';
import { TxBody, AuthInfo } from '@liftedinit/manifestjs/dist/codegen/cosmos/tx/v1beta1/tx';
import { decodePubkey } from '@cosmjs/proto-signing';
import { useWallet, useChain } from '@cosmos-kit/react';
import Image from 'next/image';
import { getRealLogo } from '@/utils';
import { useTheme } from '@/contexts';

type DisplayDataToSignProps = {
data: SignData;
Expand Down Expand Up @@ -121,6 +119,7 @@ const SignModal = ({
const { address } = useChain('manifest');
const walletIcon = wallet.wallet?.logo;
const walletName = wallet.wallet?.prettyName;
const { theme } = useTheme();

useEffect(() => {
const modal = document.getElementById('sign-modal') as HTMLDialogElement;
Expand All @@ -138,7 +137,11 @@ const SignModal = ({
<div className="modal-box max-w-lg w-full dark:bg-[#1D192D] bg-[#FFFFFF] rounded-lg shadow-xl">
<div className="flex justify-between items-center pb-4">
<div className="flex items-center gap-3">
<img src={getRealLogo(walletIconString)} alt="Wallet type logo" className="w-8 h-8" />
<img
src={getRealLogo(walletIconString, theme === 'dark')}
alt="Wallet type logo"
className="w-8 h-8"
/>
<h3 className="text-xl font-semibold">{walletName?.toString()} Direct Signer</h3>
</div>
<button className="btn btn-sm btn-circle btn-ghost" onClick={onClose}>
Expand Down
30 changes: 26 additions & 4 deletions components/react/sideNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Link from 'next/link';
import { useRouter } from 'next/router';
import { IconWallet, WalletSection } from '../wallet';
import { useTheme } from '@/contexts/theme';
import { useCallback } from 'react';
import { TailwindModal } from './modal';
import packageInfo from '../../package.json';

Expand All @@ -17,7 +16,8 @@ import {
LightIcon,
} from '@/components/icons';

import { MdContacts, MdOutlineNetworkPing } from 'react-icons/md';
import { MdContacts } from 'react-icons/md';
import { getRealLogo } from '@/utils';
import env from '@/config/env';

interface SideNavProps {
Expand Down Expand Up @@ -192,8 +192,30 @@ export default function SideNav({ isDrawerVisible, setDrawerVisible }: SideNavPr
<WalletSection chainName="manifest" />
</div>
</ul>
<div className="flex flex-row justify-center items-center">
<p className="text-sm text-gray-500">v{version}</p>
<div className="flex flex-row justify-between items-center">
<Link href="https://github.com/liftedinit/manifest-app" target="_blank">
<p className="text-sm text-gray-500">v{version}</p>
</Link>
<div className="flex flex-row justify-between items-center gap-3">
<Link href="https://discord.gg/ndYMdRmFpG" target="_blank">
<Image
src={getRealLogo('/discord', theme === 'dark')}
alt={'Discord'}
width={12}
height={12}
className="w-4 h-4 rounded-xl"
/>
</Link>
<Link href="https://x.com/ManifestAIs" target="_blank">
<Image
src={getRealLogo('/x', theme === 'dark')}
alt={'Twitter'}
width={12}
height={12}
className="w-4 h-4 rounded-xl"
/>
</Link>
</div>
</div>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions components/react/views/Connected.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { getRealLogo, shiftDigits, truncateString } from '@/utils';
import Image from 'next/image';
import { MdContacts } from 'react-icons/md';
import { Contacts } from './Contacts';
import { useTheme } from '@/contexts';

export const Connected = ({
onClose,
Expand All @@ -30,6 +31,7 @@ export const Connected = ({
const { balance } = useBalance(address ?? '');
const [copied, setCopied] = useState(false);
const [showContacts, setShowContacts] = useState(false);
const { theme } = useTheme();

const copyAddress = () => {
if (address) {
Expand Down Expand Up @@ -57,7 +59,9 @@ export const Connected = ({
<Image
height={0}
width={0}

src={name === 'Cosmos MetaMask Extension' ? '/metamask.svg' : getRealLogo(logo)}

Check warning on line 64 in components/react/views/Connected.tsx

View check run for this annotation

Codecov / codecov/patch

components/react/views/Connected.tsx#L62-L64

Added lines #L62 - L64 were not covered by tests
alt={name}
className="w-8 h-8 rounded-full mr-2"
/>
Expand Down
4 changes: 4 additions & 0 deletions components/react/views/Connecting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Dialog } from '@headlessui/react';
import { XMarkIcon } from '@heroicons/react/24/outline';
import { ChevronLeftIcon } from '@heroicons/react/20/solid';
import { getRealLogo } from '@/utils';
import { useTheme } from '@/contexts';

export const Connecting = ({
onClose,
Expand All @@ -20,6 +21,7 @@ export const Connecting = ({
title: string;
subtitle: string;
}) => {
const { theme } = useTheme();
return (
<div className="mt-3 text-center sm:mt-1.5">
<div className="flex justify-between items-center mb-2">
Expand All @@ -43,7 +45,9 @@ export const Connecting = ({
</div>
<div className="flex flex-col w-full h-full mt-4 sm:px-8 sm:py-6">
<img

src={name === 'Cosmos MetaMask Extension' ? '/metamask.svg' : getRealLogo(logo)}

Check warning on line 50 in components/react/views/Connecting.tsx

View check run for this annotation

Codecov / codecov/patch

components/react/views/Connecting.tsx#L48-L50

Added lines #L48 - L50 were not covered by tests
alt={name}
className="flex-shrink-0 w-20 h-20 mx-auto aspect-1"
/>
Expand Down
4 changes: 4 additions & 0 deletions components/react/views/Error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { XMarkIcon, ArrowPathIcon } from '@heroicons/react/24/outline';
import { ChevronLeftIcon } from '@heroicons/react/20/solid';
import Image from 'next/image';
import { getRealLogo } from '@/utils';
import { useTheme } from '@/contexts';
export const Error = ({
currentWalletName,
onClose,
Expand All @@ -18,6 +19,7 @@ export const Error = ({
onReconnect: () => void;
logo: string;
}) => {
const { theme } = useTheme();
return (
<div className="mt-3 text-center sm:mt-1.5">
<div className="flex flex-row items-center justify-between">
Expand Down Expand Up @@ -45,11 +47,13 @@ export const Error = ({
<div className="flex flex-col w-full h-full py-6 mt-4 sm:px-8">
<div className="p-3 border rounded-full border-red-600 mx-auto aspect-1 flex-shrink-0">
<Image

src={
currentWalletName === 'Cosmos MetaMask Extension'
? '/metamask.svg'
: getRealLogo(logo)
}

Check warning on line 56 in components/react/views/Error.tsx

View check run for this annotation

Codecov / codecov/patch

components/react/views/Error.tsx#L50-L56

Added lines #L50 - L56 were not covered by tests
alt="Wallet type logo"
className="flex-shrink-0 w-16 h-16 aspect-1"
width={16}
Expand Down
4 changes: 4 additions & 0 deletions components/react/views/NotExist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Dialog } from '@headlessui/react';
import { XMarkIcon, ArrowDownTrayIcon } from '@heroicons/react/24/outline';
import { ChevronLeftIcon } from '@heroicons/react/20/solid';
import { getRealLogo } from '@/utils';
import { useTheme } from '@/contexts';

export const NotExist = ({
onClose,
Expand All @@ -17,6 +18,7 @@ export const NotExist = ({
logo: string;
name: string;
}) => {
const { theme } = useTheme();
return (
<div className="mt-3 text-center sm:mt-1.5">
<div className="flex justify-between items-center mb-2">
Expand All @@ -40,7 +42,9 @@ export const NotExist = ({
</div>
<div className="flex flex-col w-full h-full py-6 mt-4 sm:px-8">
<img

src={name === 'Cosmos MetaMask Extension' ? '/metamask.svg' : getRealLogo(logo)}

Check warning on line 47 in components/react/views/NotExist.tsx

View check run for this annotation

Codecov / codecov/patch

components/react/views/NotExist.tsx#L45-L47

Added lines #L45 - L47 were not covered by tests
alt={name}
className="flex-shrink-0 w-16 h-16 mx-auto aspect-1"
/>
Expand Down
9 changes: 6 additions & 3 deletions components/react/views/WalletList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const WalletList = ({
onWalletClicked: (name: string, isMobileConnect?: boolean) => void;

Check warning on line 13 in components/react/views/WalletList.tsx

View check run for this annotation

Codecov / codecov/patch

components/react/views/WalletList.tsx#L13

Added line #L13 was not covered by tests
wallets: ChainWalletBase[];
}) => {
// Can't use `useTheme` here because it's not wrapped in a ThemeProvider
const isDarkMode = document.documentElement.classList.contains('dark');

const social = wallets.filter(wallet =>
Expand Down Expand Up @@ -53,6 +54,7 @@ export const WalletList = ({
<div className={`${isMobile ? 'hidden' : 'block'}`}>
<div className="space-y-2 mb-4">
{browser.map(({ walletInfo: { name, prettyName, logo } }) => (

<div key={name} className="w-full">
<button
onClick={() => onWalletClicked(name)}
Expand Down Expand Up @@ -84,6 +86,7 @@ export const WalletList = ({
)}
</button>
</div>

Check warning on line 89 in components/react/views/WalletList.tsx

View check run for this annotation

Codecov / codecov/patch

components/react/views/WalletList.tsx#L57-L89

Added lines #L57 - L89 were not covered by tests
))}
</div>

Expand All @@ -99,7 +102,7 @@ export const WalletList = ({
className="flex items-center justify-center p-4 dark:bg-[#ffffff0c] bg-[#f0f0ff5c] dark:hover:bg-[#0000004c] hover:bg-[#a8a8a84c] rounded-lg transition"
>
<img
src={getRealLogo(logo?.toString() ?? '')}
src={getRealLogo(logo?.toString() ?? '', isDarkMode)}
alt={prettyName}
className={`${prettyName === 'Reddit' || prettyName === 'Google' ? 'w-8 h-8' : 'w-7 h-7'} rounded-md`}
/>
Expand All @@ -118,7 +121,7 @@ export const WalletList = ({
className="flex items-center w-full p-3 rounded-lg dark:bg-[#ffffff0c] bg-[#f0f0ff5c] dark:hover:bg-[#0000004c] hover:bg-[#a8a8a84c] transition"
>
<img
src={getRealLogo(logo?.toString() ?? '')}
src={getRealLogo(logo?.toString() ?? '', isDarkMode)}
alt={prettyName}
className="w-10 h-10 rounded-xl mr-3"
/>
Expand All @@ -138,7 +141,7 @@ export const WalletList = ({
className="flex items-center justify-center p-4 dark:bg-[#ffffff0c] bg-[#f0f0ff5c] dark:hover:bg-[#0000004c] hover:bg-[#a8a8a84c] rounded-lg transition"
>
<img
src={isDarkMode ? logo?.toString() + '_light.svg' : logo?.toString() + '_dark.svg'}
src={getRealLogo(logo?.toString() ?? '', isDarkMode)}
alt={prettyName}
className={`${prettyName === 'Reddit' || prettyName === 'Google' ? 'w-8 h-8' : 'w-7 h-7'} rounded-md`}
/>
Expand Down
5 changes: 2 additions & 3 deletions utils/logos.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { ExtendedValidatorSDKType } from '@/components';

export const getRealLogo = (logo: string) => {
const isDarkMode = document.documentElement.classList.contains('dark');
export const getRealLogo = (logo: string, isDarkMode?: boolean) => {
const localAndHasExtension = /^\/(?!.*\.[0-9a-z]+$)/i.test(logo);
return localAndHasExtension
? isDarkMode
? isDarkMode === true
? logo?.toString() + '_light.svg'
: logo?.toString() + '_dark.svg'
: logo;
Expand Down

0 comments on commit d5ee8ec

Please sign in to comment.