Skip to content

Commit

Permalink
Merge pull request #4098 from CrocSwap/merged-mobile-refactors
Browse files Browse the repository at this point in the history
Merge all mobile refactors PR
  • Loading branch information
benwolski authored Sep 11, 2024
2 parents 7616a91 + 4aee5eb commit 598898b
Show file tree
Hide file tree
Showing 59 changed files with 3,740 additions and 1,359 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0"/>
<link
rel="apple-touch-icon"
sizes="180x180"
Expand Down
5 changes: 4 additions & 1 deletion src/App/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,13 @@ input[type='number'] {
overflow-y: auto;
overflow-x: hidden;
height: calc(100vh - 56px);

background: var(--dark1);

}
.content-container-trade {
background: var(--dark1);
}
}


7 changes: 6 additions & 1 deletion src/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ export default function App() {
}
}
}, [isEscapePressed]);

useEffect(() => {
appHeaderDropdown.setIsActive(false);
}, [location]);

const showMobileVersion = useMediaQuery('(max-width: 800px)');
// const showChatPanel =
// currentLocation !== '/' &&
Expand Down Expand Up @@ -133,7 +138,7 @@ export default function App() {
height:
location.pathname == '/'
? 'calc(100vh - 56px)'
: '100vh',
: '100dvh',
}}
>
{showPoints && showPointSystemPopup && (
Expand Down
7 changes: 5 additions & 2 deletions src/App/components/PageHeader/Account/Account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { UserDataContext } from '../../../../contexts/UserDataContext';
import LevelDropdown from './LevelDropdown/LevelDropdown';
import { ChainDataContext } from '../../../../contexts/ChainDataContext';
import NotificationCenter from '../../../../components/Global/NotificationCenter/NotificationCenter';
import useMediaQuery from '../../../../utils/hooks/useMediaQuery';
// TODO: use user context instead of UseAccount
interface propsIF {
accountAddress: string;
Expand All @@ -43,6 +44,8 @@ export default function Account(props: propsIF) {
const { isUserConnected } = useContext(UserDataContext);

const { connectedUserXp } = useContext(ChainDataContext);
const smallScreen = useMediaQuery('(max-width: 500px)');


const [_, copy] = useCopyToClipboard();

Expand Down Expand Up @@ -194,8 +197,8 @@ export default function Account(props: propsIF) {
overflow='visible'
alignItems='center'
>
{isUserConnected && walletDisplay}
{isUserConnected && levelDisplay}
{isUserConnected && !smallScreen && walletDisplay}
{isUserConnected && !smallScreen && levelDisplay}
{isUserConnected && <ExchangeBalanceDropdown />}
<NotificationCenter />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { lookupChain } from '@crocswap-libs/sdk/dist/context';
import { BrandContext } from '../../../../contexts/BrandContext';
import { lookupChainId } from '../../../../ambient-utils/dataLayer';
import { useSwitchNetwork, useWeb3ModalAccount } from '@web3modal/ethers/react';
import useMediaQuery from '../../../../utils/hooks/useMediaQuery';

interface propsIF {
customBR?: string;
Expand All @@ -42,6 +43,8 @@ export default function NetworkSelector(props: propsIF) {
} = useContext(CrocEnvContext);
const { networks, platformName, includeCanto } = useContext(BrandContext);
const { switchNetwork } = useSwitchNetwork();
const smallScreen = useMediaQuery('(max-width: 600px)');


const linkGenIndex: linkGenMethodsIF = useLinkGen('index');
const [searchParams, setSearchParams] = useSearchParams();
Expand Down Expand Up @@ -332,6 +335,7 @@ export default function NetworkSelector(props: propsIF) {
>
<DropdownMenu2
marginTop={'50px'}
marginRight={smallScreen ? '70px' : ''}
titleWidth={'80px'}
title={lookupChain(chainId).displayName}
expandable={networks.length > 1}
Expand Down
16 changes: 1 addition & 15 deletions src/App/components/PageHeader/PageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -450,21 +450,7 @@ const PageHeader = function () {
gap={8}
overflow='visible'
>
{/* {desktopScreen && (
<FlexContainer fontSize='body' color={'orange'}>
{APP_ENVIRONMENT !== 'production' ? (
<FlexContainer
alignItems='center'
gap={4}
>
{`${BRANCH_NAME} - v${appVersion}`}
{APP_ENVIRONMENT !== 'testnet' && (
<BiGitBranch color='yellow' />
)}
</FlexContainer>
) : null}
</FlexContainer>
)} */}

<NetworkSelector />
{!isUserConnected && connectWagmiButton}
<Account {...accountProps} />
Expand Down
1 change: 0 additions & 1 deletion src/components/Form/Form.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const ButtonBase = styled.button<{
isFuta?: boolean;
}>`
width: ${({ width }) => width || '100%'};
max-width: 500px;
height: ${({ height }) => height || 'auto'};
outline: none;
padding: 12px 16px;
Expand Down
108 changes: 19 additions & 89 deletions src/components/Global/ContentContainer/ContentContainer.module.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
.window {
position: relative;
.trade_route {
background: transparent;
margin-top: 0;
border-radius: var(--border-radius);
}

color: var(--text2);
.swap_route {
border: 0.5px solid var(--accent-accent1, #7371fc);
border-radius: var(--border-radius);
box-shadow: var(--swap-box-shadow);
box-shadow: inset 0px 0px 20px 0px rgba(115, 113, 252, 0.25);
}

background-color: var(--accent1);
background: var(--accent1);
.container {
width: 100%;
}

.main_content {
Expand All @@ -14,7 +21,7 @@

display: flex;
flex-direction: column;
gap: 8px;
gap: 1rem;
}

.swap_main_content {
Expand All @@ -40,97 +47,20 @@
transition: var(--transition);
}

.swap_route {
background: var(--accent1);
padding: 1px;
border-radius: var(--border-radius);
box-shadow: var(--swap-box-shadow);
}

/* media queries */

@media (min-width: 1200px) {
.container {
max-width: 1140px;
}

.customWidthAuto {
max-width: 1240px;
}
}

@media (min-width: 992px) {
.container {
max-width: 960px;
}
.customWidthAuto {
max-width: auto;
@media (max-width: 768px) {
.trade_route {
/* max-width: 500px; */
width: 100%;
}
}

@media (min-width: 768px) {
.container {
max-width: 720px;
}

.customWidthAuto {
max-width: auto;
}
.no_background:hover,
.no_background:focus-within {
box-shadow: none;
}

.swap_main_content {
padding: 24px;
}
}
@media (min-width: 1200px) {
.container {
max-width: 420px;
}
.swap_route {
min-width: 430px;
max-width: 440px;
}
.customWidth_container {
max-width: 640px;
}

.customWidthAuto {
max-width: auto;
}
}

@media only screen and (max-width: 1200px) {
.main_content {
background-color: var(--dark1);
}

.swap_route,
.no_background {
margin: 0 auto;
}
}

@media only screen and (max-width: 600px) {
.main_content {
/* overflow-y: scroll;
min-height: 50svh;
max-height: 80svh; */
padding: 8px !important;
box-shadow: none;
}

.swap_route {
background: transparent;
}

.swap_route,
.no_background {
width: 95%;


/* overflow-y: scroll; */
padding: 8px 16px 16px 16px;
gap: 8px;
}
}
41 changes: 10 additions & 31 deletions src/components/Global/ContentContainer/ContentContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,52 +1,31 @@
import { ReactNode } from 'react';
import { CSSProperties, ReactNode } from 'react';
import styles from './ContentContainer.module.css';

interface ContentContainerPropsIF {
children: ReactNode;
customWidth?: boolean;
customWidthAuto?: boolean;
isOnTradeRoute?: boolean;
noPadding?: boolean;
noStyle?: boolean;
style?: CSSProperties; // Allow custom inline styles
}

export default function ContentContainer(props: ContentContainerPropsIF) {
const {
children,
isOnTradeRoute,
customWidth,
customWidthAuto,
noPadding,
noStyle,
style
} = props;

const customWidthStyle = customWidth ? styles.customWidth_container : null;
const tradeRouteStyle = isOnTradeRoute
? styles.no_background
: styles.swap_bg;
const swapRouteStyle = isOnTradeRoute ? null : styles.swap_route;
const customWidthAutoStyle = customWidthAuto
? styles.customWidthAuto
: styles.container;

if (noStyle) return <>{children}</>;


? styles.trade_route
: styles.swap_route


return (
<section
className={`$ ${customWidthStyle} ${customWidthAutoStyle} ${tradeRouteStyle} ${swapRouteStyle}`}
>
<section className={`${styles.window} ${tradeRouteStyle}`}>
<div
className={`${styles.main_content} ${
!isOnTradeRoute && styles.swap_main_content
}`}
style={{ padding: noPadding ? '' : '8px 16px 16px 16px' }}
>
<section className={tradeRouteStyle} style={style}>
<div className={styles.container} >
<div className={styles.main_content}>
{children}
</div>
</section>
</div>
</section>
);
}
8 changes: 6 additions & 2 deletions src/components/Global/DropdownMenu2/DropdownMenu2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ interface propsIF {
title: string;
children: ReactNode;
marginTop?: string;
marginRight?: string;
marginLeft?: string;
titleWidth?: string;
logo?: string;
left?: string;
Expand All @@ -30,6 +32,8 @@ export default function DropdownMenu2(props: propsIF) {
left,
right,
expandable,
marginRight,
marginLeft
} = props;
const [isMenuOpen, setIsMenuOpen] = useState(false);
const { appHeaderDropdown } = useContext(AppStateContext);
Expand Down Expand Up @@ -67,8 +71,8 @@ export default function DropdownMenu2(props: propsIF) {
exit='hidden'
style={{
top: marginTop ? marginTop : '30px',
left: left,
right: right,
left: marginLeft ?? left,
right: marginRight ?? right,
}}
>
{children}
Expand Down
Loading

0 comments on commit 598898b

Please sign in to comment.