Skip to content

Commit

Permalink
[PAY-2277][PAY-2272] Fix purchase modaldrawer scroll and safe areas (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
raymondjacobson authored Dec 14, 2023
1 parent fe21499 commit b6a82b9
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 57 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion packages/stems/src/components/Modal/ModalContentPages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { ModalContent } from './ModalContent'
import styles from './ModalContentPages.module.css'
import { ModalContentProps } from './types'

const INNER_HEIGHT_PADDING = 100

const defaultTransitions = {
initial: { opacity: 1, transform: 'translate3d(0%, 0, 0)' },
enter: { opacity: 1, transform: 'translate3d(0%, 0 ,0)' }
Expand Down Expand Up @@ -53,6 +55,14 @@ export const ModalContentPages = ({
polyfill: ResizeObserver
})

// A bit of a hack, but instead of resizing the height to the result from
// useMeasure, clamp it to the window height minus a padding.
// This makes it so that when inside a "Drawer," safe areas are respected.
const computedHeight = Math.min(
height,
window.innerHeight - INNER_HEIGHT_PADDING
)

if (lastPage !== currentPage) {
setTransitions(
getSwipeTransitions(currentPage > lastPage ? 'forward' : 'back')
Expand All @@ -68,7 +78,7 @@ export const ModalContentPages = ({
className={styles.transitionContainer}
style={{
width: width ? `${width}px` : '100%',
height: height ? `${height}px` : '100%'
height: computedHeight ? `${computedHeight}px` : '100%'
}}
>
<Transition
Expand Down
2 changes: 1 addition & 1 deletion packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"array-range": "1.0.1",
"bitski": "0.10.9",
"bn.js": "5.1.0",
"body-scroll-lock": "2.7.1",
"body-scroll-lock": "4.0.0-beta.0",
"canvas-loop": "1.0.7",
"chart.js": "2.9.3",
"clamp": "1.0.1",
Expand Down
3 changes: 1 addition & 2 deletions packages/web/src/components/drawer/Drawer.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
.fullDrawer {
top: 0px;
height: 100vh;
overflow-x: hidden;
overflow-y: scroll;
overflow: hidden;
touch-action: auto;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
PurchaseContentPage
} from '@audius/common'
import { USDC } from '@audius/fixed-decimal'
import { Box, Flex } from '@audius/harmony'
import { Flex } from '@audius/harmony'
import {
IconCart,
ModalContentPages,
Expand Down Expand Up @@ -103,55 +103,53 @@ const RenderForm = ({
const mobile = isMobile()

return (
<ModalForm className={styles.root}>
<Box>
<ModalHeader
className={cn(styles.modalHeader, { [styles.mobile]: mobile })}
onClose={onClose}
showDismissButton={!mobile}
<ModalForm>
<ModalHeader
className={cn(styles.modalHeader, { [styles.mobile]: mobile })}
onClose={onClose}
showDismissButton={!mobile}
>
<Text
variant='label'
color='neutralLight2'
size='xLarge'
strength='strong'
className={styles.title}
>
<Text
variant='label'
color='neutralLight2'
size='xLarge'
strength='strong'
className={styles.title}
>
<Icon size='large' icon={IconCart} />
{messages.completePurchase}
</Text>
</ModalHeader>
<ModalContentPages
contentClassName={styles.content}
className={styles.content}
currentPage={currentPageIndex}
>
<>
{stage !== PurchaseContentStage.FINISH ? (
<AudioMatchSection
amount={USDC(price / 100)
.round()
.toShorthand()}
<Icon size='large' icon={IconCart} />
{messages.completePurchase}
</Text>
</ModalHeader>
<ModalContentPages
contentClassName={styles.content}
className={styles.content}
currentPage={currentPageIndex}
>
<>
{stage !== PurchaseContentStage.FINISH ? (
<AudioMatchSection
amount={USDC(price / 100)
.round()
.toShorthand()}
/>
) : null}
<Flex p={mobile ? 'l' : 'xl'}>
<Flex direction='column' gap='xl' w='100%'>
<LockedTrackDetailsTile
track={track as unknown as Track}
owner={track.user}
/>
<PurchaseContentFormFields
stage={stage}
purchaseSummaryValues={purchaseSummaryValues}
isUnlocking={isUnlocking}
price={price}
/>
) : null}
<Flex p={mobile ? 'l' : 'xl'}>
<Flex direction='column' gap='xl' w='100%'>
<LockedTrackDetailsTile
track={track as unknown as Track}
owner={track.user}
/>
<PurchaseContentFormFields
stage={stage}
purchaseSummaryValues={purchaseSummaryValues}
isUnlocking={isUnlocking}
price={price}
/>
</Flex>
</Flex>
</>
<USDCManualTransfer onClose={handleClose} amountInCents={price} />
</ModalContentPages>
</Box>
</Flex>
</>
<USDCManualTransfer onClose={handleClose} amountInCents={price} />
</ModalContentPages>
<ModalFooter className={styles.footer}>
{page === PurchaseContentPage.PURCHASE ? (
<PurchaseContentFormFooter
Expand Down

0 comments on commit b6a82b9

Please sign in to comment.