Commit 66ab3e21 authored by lynn's avatar lynn Committed by GitHub

fix: dynamic padding based on screen sizes for collections + my nft (#5064)

* init

* my nft pages
parent d4b15a6d
...@@ -7,7 +7,6 @@ import { CrossIcon, TagIcon } from 'nft/components/icons' ...@@ -7,7 +7,6 @@ import { CrossIcon, TagIcon } from 'nft/components/icons'
import { FilterSidebar } from 'nft/components/profile/view/FilterSidebar' import { FilterSidebar } from 'nft/components/profile/view/FilterSidebar'
import { buttonTextMedium, subhead } from 'nft/css/common.css' import { buttonTextMedium, subhead } from 'nft/css/common.css'
import { import {
useBag,
useFiltersExpanded, useFiltersExpanded,
useIsMobile, useIsMobile,
useProfilePageState, useProfilePageState,
...@@ -15,6 +14,7 @@ import { ...@@ -15,6 +14,7 @@ import {
useWalletBalance, useWalletBalance,
useWalletCollections, useWalletCollections,
} from 'nft/hooks' } from 'nft/hooks'
import { ScreenBreakpointsPaddings } from 'nft/pages/collection/index.css'
import { fetchMultipleCollectionStats, fetchWalletAssets, OSCollectionsFetcher } from 'nft/queries' import { fetchMultipleCollectionStats, fetchWalletAssets, OSCollectionsFetcher } from 'nft/queries'
import { ProfilePageStateType, WalletCollection } from 'nft/types' import { ProfilePageStateType, WalletCollection } from 'nft/types'
import { Dispatch, SetStateAction, useEffect, useMemo, useReducer, useState } from 'react' import { Dispatch, SetStateAction, useEffect, useMemo, useReducer, useState } from 'react'
...@@ -47,6 +47,11 @@ const SellModeButton = styled.button<{ active: boolean }>` ...@@ -47,6 +47,11 @@ const SellModeButton = styled.button<{ active: boolean }>`
} }
` `
const ProfilePageColumn = styled(Column)`
overflow-x: hidden !important;
${ScreenBreakpointsPaddings}
`
const FILTER_SIDEBAR_WIDTH = 300 const FILTER_SIDEBAR_WIDTH = 300
const PADDING = 16 const PADDING = 16
...@@ -71,7 +76,6 @@ export const ProfilePage = () => { ...@@ -71,7 +76,6 @@ export const ProfilePage = () => {
const resetSellAssets = useSellAsset((state) => state.reset) const resetSellAssets = useSellAsset((state) => state.reset)
const setSellPageState = useProfilePageState((state) => state.setProfilePageState) const setSellPageState = useProfilePageState((state) => state.setProfilePageState)
const [isFiltersExpanded, setFiltersExpanded] = useFiltersExpanded() const [isFiltersExpanded, setFiltersExpanded] = useFiltersExpanded()
const isBagExpanded = useBag((state) => state.bagExpanded)
const isMobile = useIsMobile() const isMobile = useIsMobile()
const [isSellMode, toggleSellMode] = useReducer((s) => !s, false) const [isSellMode, toggleSellMode] = useReducer((s) => !s, false)
...@@ -164,12 +168,7 @@ export const ProfilePage = () => { ...@@ -164,12 +168,7 @@ export const ProfilePage = () => {
}) })
return ( return (
<Column <ProfilePageColumn width="full" paddingTop={{ sm: `${PADDING}`, md: '40' }}>
width="full"
paddingLeft={{ sm: `${PADDING}`, md: '52' }}
paddingRight={{ sm: `${PADDING}`, md: isBagExpanded ? '0' : '72' }}
paddingTop={{ sm: `${PADDING}`, md: '40' }}
>
{anyQueryIsLoading ? ( {anyQueryIsLoading ? (
<ProfilePageLoadingSkeleton /> <ProfilePageLoadingSkeleton />
) : walletAssets.length === 0 ? ( ) : walletAssets.length === 0 ? (
...@@ -280,7 +279,7 @@ export const ProfilePage = () => { ...@@ -280,7 +279,7 @@ export const ProfilePage = () => {
</Box> </Box>
</Row> </Row>
)} )}
</Column> </ProfilePageColumn>
) )
} }
......
import { style } from '@vanilla-extract/css' import { style } from '@vanilla-extract/css'
import {
MAX_WIDTH_MEDIA_BREAKPOINT,
MOBILE_MEDIA_BREAKPOINT,
SMALL_MEDIA_BREAKPOINT,
} from 'components/Tokens/constants'
import { buttonTextMedium } from 'nft/css/common.css' import { buttonTextMedium } from 'nft/css/common.css'
import { loadingBlock } from 'nft/css/loading.css' import { loadingBlock } from 'nft/css/loading.css'
import { css } from 'styled-components/macro'
import { sprinkles, vars } from '../../css/sprinkles.css' import { sprinkles, vars } from '../../css/sprinkles.css'
...@@ -60,3 +66,25 @@ export const noCollectionAssets = sprinkles({ ...@@ -60,3 +66,25 @@ export const noCollectionAssets = sprinkles({
justifyContent: 'center', justifyContent: 'center',
marginTop: '40', marginTop: '40',
}) })
export const ScreenBreakpointsPaddings = css`
@media screen and (min-width: ${MAX_WIDTH_MEDIA_BREAKPOINT}) {
padding-left: 48px;
padding-right: 48px;
}
@media screen and (max-width: ${MAX_WIDTH_MEDIA_BREAKPOINT}) {
padding-left: 40px;
padding-right: 40px;
}
@media screen and (max-width: ${SMALL_MEDIA_BREAKPOINT}) {
padding-left: 20px;
padding-right: 20px;
}
@media screen and (max-width: ${MOBILE_MEDIA_BREAKPOINT}) {
padding-left: 16px;
padding-right: 16px;
}
`
...@@ -14,12 +14,23 @@ import { Suspense, useEffect } from 'react' ...@@ -14,12 +14,23 @@ import { Suspense, useEffect } from 'react'
import { useQuery } from 'react-query' import { useQuery } from 'react-query'
import { useLocation, useNavigate, useParams } from 'react-router-dom' import { useLocation, useNavigate, useParams } from 'react-router-dom'
import { useSpring } from 'react-spring' import { useSpring } from 'react-spring'
import styled from 'styled-components/macro'
const FILTER_WIDTH = 332 const FILTER_WIDTH = 332
const BAG_WIDTH = 324 const BAG_WIDTH = 324
export const CollectionBannerLoading = () => <Box height="full" width="full" className={styles.loadingBanner} /> export const CollectionBannerLoading = () => <Box height="full" width="full" className={styles.loadingBanner} />
const CollectionDescriptionSection = styled(Column)`
${styles.ScreenBreakpointsPaddings}
`
const CollectionDisplaySection = styled(Row)`
${styles.ScreenBreakpointsPaddings}
align-items: flex-start;
position: relative;
`
const Collection = () => { const Collection = () => {
const { contractAddress } = useParams() const { contractAddress } = useParams()
const setIsCollectionStatsLoading = useIsCollectionLoading((state) => state.setIsCollectionStatsLoading) const setIsCollectionStatsLoading = useIsCollectionLoading((state) => state.setIsCollectionStatsLoading)
...@@ -93,7 +104,7 @@ const Collection = () => { ...@@ -93,7 +104,7 @@ const Collection = () => {
)} )}
</Box> </Box>
</Box> </Box>
<Column paddingX="48"> <CollectionDescriptionSection>
{(isLoading || collectionStats !== undefined) && ( {(isLoading || collectionStats !== undefined) && (
<CollectionStats stats={collectionStats || ({} as GenieCollection)} isMobile={isMobile} /> <CollectionStats stats={collectionStats || ({} as GenieCollection)} isMobile={isMobile} />
)} )}
...@@ -105,8 +116,8 @@ const Collection = () => { ...@@ -105,8 +116,8 @@ const Collection = () => {
toggleActivity() toggleActivity()
}} }}
/> />
</Column> </CollectionDescriptionSection>
<Row alignItems="flex-start" position="relative" paddingX="48"> <CollectionDisplaySection>
<Box position="sticky" top="72" width="0"> <Box position="sticky" top="72" width="0">
{isFiltersExpanded && <Filters traits={collectionStats?.traits ?? []} />} {isFiltersExpanded && <Filters traits={collectionStats?.traits ?? []} />}
</Box> </Box>
...@@ -138,7 +149,7 @@ const Collection = () => { ...@@ -138,7 +149,7 @@ const Collection = () => {
</Suspense> </Suspense>
)} )}
</AnimatedBox> </AnimatedBox>
</Row> </CollectionDisplaySection>
</> </>
) : ( ) : (
// TODO: Put no collection asset page here // TODO: Put no collection asset page here
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment