Skip to content

Commit

Permalink
feat(HTL-109459): multiroom drawer)
Browse files Browse the repository at this point in the history
  • Loading branch information
fareedahmad1 committed Oct 22, 2024
1 parent 9f68dcd commit ca44f4a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "pcln-design-system",
"comment": "update drawer props",
"type": "minor"
}
],
"packageName": "pcln-design-system"
}
2 changes: 1 addition & 1 deletion packages/core/src/Drawer/Drawer.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export const Anchored = (args) => (
)

export const Mobile = (args) => (
<DrawerStory {...args} isMobile isFloating={false} placement='right'>
<DrawerStory {...args} isMobile isFloating={false} placement='right' width='100%'>
Drawer Content
</DrawerStory>
)
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/Drawer/Drawer.styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Flex } from '../Flex/Flex'
import { theme } from '../theme'
import { motion } from 'framer-motion'
import React from 'react'
import { Absolute } from '../Absolute/Absolute'
import { getPaletteColor } from '../utils'
import { Box } from '../Box/Box'
import { IconButton } from '../IconButton/IconButton'
Expand All @@ -13,7 +12,7 @@ const Component = React.forwardRef((props, ref: React.MutableRefObject<HTMLDivEl
<Box {...props} ref={ref} />
))

const AnimatedAbsolute = motion(Component)
const AnimatedComponent = motion(Component)

const getBorderRadiusStyles = (placement, isFloating) => {
const themeRadius = theme.borderRadii['2xl']
Expand All @@ -40,13 +39,14 @@ const positions: Record<PlacementOptions, string> = {
}
const getPlacementStyles = (placement) =>
placement ? `margin-inline:auto; margin-block:auto; ${positions[placement]};` : ``
export const DrawerWrapper = styled(Absolute)`
export const DrawerWrapper = styled(Box)`
position: fixed;
${({ placement }) =>
`
${getPlacementStyles(placement)}
`}
`
export const DrawerRoot = styled(AnimatedAbsolute)`
export const DrawerRoot = styled(AnimatedComponent)`
background-color: ${getPaletteColor('background.lightest')};
${({ theme, placement, isFloating }) =>
`box-shadow: ${theme.shadows['overlay-md']};
Expand Down
9 changes: 6 additions & 3 deletions packages/core/src/Drawer/Drawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ import { MotionVariants } from '../Animate/Animate'
export type PlacementOptions = 'top' | 'bottom' | 'right' | 'left'
export type DrawerProps = SpaceProps &
LayoutProps & {
children?: string | React.ReactNode
heading?: string | React.ReactNode
isCollapsed?: boolean
isFloating?: boolean
isOpen?: boolean
isMobile?: boolean
isOpen?: boolean
isDraggable?: boolean
onClose?: () => void
onCollapse?: () => void
placement?: PlacementOptions
children?: string | React.ReactNode
}

const enterAnimation = {
Expand Down Expand Up @@ -51,6 +52,7 @@ export const Drawer: React.FC<DrawerProps> = ({
isFloating = true,
isMobile = false,
isOpen = false,
isDraggable = true,
onClose,
onCollapse,
placement = 'right',
Expand All @@ -67,6 +69,7 @@ export const Drawer: React.FC<DrawerProps> = ({
maxWidth={isMobile ? '100%' : ['400px', '600px', '800px', '100%']}
width={isMobile ? '100%' : props.width}
height={!isCollapsed && props.height ? props.height : 'fit-content'}
{...props}
>
<DrawerRoot
data-testid='drawer'
Expand All @@ -75,7 +78,7 @@ export const Drawer: React.FC<DrawerProps> = ({
key='drawer'
placement={isMobile ? 'bottom' : placement}
{...enterAnimation[isMobile ? 'bottom' : placement]}
{...dragToDismissAnimation(onCollapse)}
{...(isDraggable ? dragToDismissAnimation(onCollapse) : {})}
height='100%'
width='100%'
overflow='hidden'
Expand Down

0 comments on commit ca44f4a

Please sign in to comment.