diff --git a/packages/design-system/lib/components/SidePeek/KeepBodyVisible.tsx b/packages/design-system/lib/components/SidePeek/KeepBodyVisible.tsx new file mode 100644 index 000000000..b688bc4be --- /dev/null +++ b/packages/design-system/lib/components/SidePeek/KeepBodyVisible.tsx @@ -0,0 +1,13 @@ +import useSetOverflowVisibleOnRA from '@scandic-hotels/common/hooks/useSetOverflowVisibleOnRA' +import { useEffect } from 'react' + +export function KeepBodyVisible() { + const toggle = useSetOverflowVisibleOnRA() + + useEffect(() => { + toggle(true) + return () => toggle(false) + }, [toggle]) + + return null +} diff --git a/packages/design-system/lib/components/SidePeek/SelfControlled/index.tsx b/packages/design-system/lib/components/SidePeek/SelfControlled.tsx similarity index 53% rename from packages/design-system/lib/components/SidePeek/SelfControlled/index.tsx rename to packages/design-system/lib/components/SidePeek/SelfControlled.tsx index d1c4f4c31..769111524 100644 --- a/packages/design-system/lib/components/SidePeek/SelfControlled/index.tsx +++ b/packages/design-system/lib/components/SidePeek/SelfControlled.tsx @@ -5,15 +5,15 @@ import { Dialog, Modal, ModalOverlay } from 'react-aria-components' import { useIntl } from 'react-intl' import usePopStateHandler from '@scandic-hotels/common/hooks/usePopStateHandler' -import useSetOverflowVisibleOnRA from '@scandic-hotels/common/hooks/useSetOverflowVisibleOnRA' -import { IconButton } from '../../IconButton' -import { MaterialIcon } from '../../Icons/MaterialIcon' -import { Typography } from '../../Typography' +import { IconButton } from '../IconButton' +import { MaterialIcon } from '../Icons/MaterialIcon' +import { Typography } from '../Typography' -import SidePeekSEO from '../SidePeekSEO' +import SidePeekSEO from './SidePeekSEO' -import styles from './sidePeekSelfControlled.module.css' +import { KeepBodyVisible } from './KeepBodyVisible' +import styles from './sidePeek.module.css' interface SidePeekSelfControlledProps extends React.PropsWithChildren { title: string @@ -56,28 +56,30 @@ export default function SidePeekSelfControlled({ > - diff --git a/packages/design-system/package.json b/packages/design-system/package.json index b30743c14..512f7c4ad 100644 --- a/packages/design-system/package.json +++ b/packages/design-system/package.json @@ -173,7 +173,7 @@ "./Select": "./lib/components/Select/index.tsx", "./SidePeek": "./lib/components/SidePeek/index.tsx", "./SidePeek/SidePeekProvider": "./lib/components/SidePeek/SidePeekContext/SidePeekProvider.tsx", - "./SidePeekSelfControlled": "./lib/components/SidePeek/SelfControlled/index.tsx", + "./SidePeekSelfControlled": "./lib/components/SidePeek/SelfControlled.tsx", "./SkeletonShimmer": "./lib/components/SkeletonShimmer/index.tsx", "./StaticMap": "./lib/components/StaticMap/index.tsx", "./Subtitle": "./lib/components/Subtitle/index.tsx",