Skip to content

Commit

Permalink
Fix mobile connect button (#1077)
Browse files Browse the repository at this point in the history
Co-authored-by: Chase Fleming <[email protected]>
  • Loading branch information
chasefleming and chasefleming authored Jan 7, 2025
1 parent cd6acc2 commit 7b6dcb7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/components/connect-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { Button } from '@site/src/ui/design-system/src/lib/Components/Button';
import { useIsMobile } from '@site/src/hooks/use-is-mobile';
import Dropdown from '@site/src/ui/design-system/src/lib/Components/Dropdown';

const shortenAddress = (address: string, isMobile: boolean) => {
const shortenAddress = (address: string) => {
if (!address) return '';
return isMobile ? `${address.slice(0, 4)}...${address.slice(-3)}` : address;
return `${address.slice(0, 8)}...${address.slice(-3)}`;
};

const ConnectButton: React.FC = () => {
Expand All @@ -26,9 +26,13 @@ const ConnectButton: React.FC = () => {
];

const fullAddress = user.addr ?? 'Unknown';
const displayAddress = shortenAddress(fullAddress, isMobile);
const displayAddress = shortenAddress(fullAddress);

return <Dropdown buttonLabel={displayAddress} items={dropdownItems} />;
return (
<div className="hide-connect-on-mobile">
<Dropdown buttonLabel={displayAddress} items={dropdownItems} />
</div>
);
};

export default ConnectButton;
7 changes: 7 additions & 0 deletions src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,11 @@
width: 300px;
display: block;
margin: 0 auto;
}

/* Only hide in in nav (not main menu on mobile) */
@media (max-width: 960px) {
.navbar__items--right .hide-connect-on-mobile {
display: none !important;
}
}

0 comments on commit 7b6dcb7

Please sign in to comment.