Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mobile connect button #1077

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/components/connect-button.tsx
Original file line number Diff line number Diff line change
@@ -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 = () => {
@@ -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
@@ -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;
}
}