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

Move connect button to the navigation bar on small screens #525

Merged
merged 3 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion cypress/e2e/keyboard-navigation.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('keyboard navigation and accessibility', () => {

closeErrorReportingNotice();
pressTabAndAssertFocusOutline(() => cy.dataCy('api3-logo'));
pressTabAndAssertFocusOutline(() => cy.findAllByText('Connect Wallet').filter(':visible'));
pressTabAndAssertFocusOutline(() => cy.findAllByText('Connect Wallet').parent().filter(':visible'));

pressTabAndAssertFocusOutline(() => cy.findAllByText('Staking').filter(':visible').closest('a'));
pressTabAndAssertFocusOutline(() => cy.findAllByText('Governance').filter(':visible').closest('a'));
Expand Down
14 changes: 2 additions & 12 deletions src/components/navigation/navigation.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

.navigation {
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 0 16px;
Expand All @@ -18,7 +17,6 @@
}

@media (min-width: $md) {
flex-direction: row;
padding: 0 24px 0 40px;
height: 120px;

Expand All @@ -33,16 +31,8 @@
}
}

.navigationMenu {
.right {
display: flex;
gap: 16px;
align-items: center;
justify-content: space-between;
align-self: flex-start;
box-sizing: border-box;
width: 100%;

@media (min-width: $md) {
align-self: center;
height: unset;
}
}
10 changes: 5 additions & 5 deletions src/components/navigation/navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import styles from './navigation.module.scss';
const Navigation = () => {
return (
<div className={styles.navigation}>
<div className={styles.navigationMenu}>
<Link to="/" data-cy="api3-logo">
<img src={images.api3DaoLogoLightTheme} alt="logo" className={styles.api3DaoLogo} />
</Link>
<Link to="/" data-cy="api3-logo">
<img src={images.api3DaoLogoLightTheme} alt="logo" className={styles.api3DaoLogo} />
</Link>
<div className={styles.right}>
<SignIn position="navigation" />
<MobileMenu />
</div>
<SignIn position="navigation" />
</div>
);
};
Expand Down
16 changes: 6 additions & 10 deletions src/components/sign-in/sign-in.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,14 @@
}

.connectButton {
width: calc(100% - 64px);
min-width: 165px;
max-width: 404px;
margin-top: 24px;
white-space: nowrap;

button {
width: 100%;
}
.connectButtonLabel {
padding: 0 8px;

@media (min-width: $md) {
margin-top: 0;
max-width: 224px;
@media (min-width: $md) {
padding: 0 24px;
}
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/components/sign-in/sign-in.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { SUPPORTED_NETWORKS, useProviderSubscriptions } from '../../contracts';
import DisconnectIcon from './disconnect-icon';
import Button from '../button';
import { ExclamationTriangleFillIcon } from '../icons';
import { useWindowDimensions } from '../../hooks/use-window-dimensions';

type Props = {
dark?: boolean;
Expand Down Expand Up @@ -77,6 +78,7 @@ const SignIn = ({ dark, position }: Props) => {
const { provider, networkName } = useChainData();
const { disconnect } = useDisconnect();
const { switchNetwork } = useSwitchNetwork();
const { isDesktop } = useWindowDimensions();
useProviderSubscriptions();

const switchToMainnet = () => {
Expand All @@ -96,11 +98,11 @@ const SignIn = ({ dark, position }: Props) => {
{!provider && (
<ConnectButton
type={dark ? 'primary' : 'secondary'}
size="sm"
size="xxs"
md={{ size: 'md' }}
className={styles.connectButton}
>
Connect Wallet
<span className={styles.connectButtonLabel}>{isDesktop ? 'Connect Wallet' : 'Connect'}</span>
</ConnectButton>
)}
{provider && <ConnectedStatus dark={dark} position={position} />}
Expand Down
Loading