fix(BOOK-146): Synced default Sidepeek and SelfControlled Sidepeek in regards of functionality and looks

Approved-by: Bianca Widstam
This commit is contained in:
Erik Tiekstra
2025-12-03 07:45:43 +00:00
parent c976079df1
commit a6b3904b2a
6 changed files with 45 additions and 121 deletions

View File

@@ -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
}

View File

@@ -5,15 +5,15 @@ import { Dialog, Modal, ModalOverlay } from 'react-aria-components'
import { useIntl } from 'react-intl' import { useIntl } from 'react-intl'
import usePopStateHandler from '@scandic-hotels/common/hooks/usePopStateHandler' import usePopStateHandler from '@scandic-hotels/common/hooks/usePopStateHandler'
import useSetOverflowVisibleOnRA from '@scandic-hotels/common/hooks/useSetOverflowVisibleOnRA'
import { IconButton } from '../../IconButton' import { IconButton } from '../IconButton'
import { MaterialIcon } from '../../Icons/MaterialIcon' import { MaterialIcon } from '../Icons/MaterialIcon'
import { Typography } from '../../Typography' 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 { interface SidePeekSelfControlledProps extends React.PropsWithChildren {
title: string title: string
@@ -56,28 +56,30 @@ export default function SidePeekSelfControlled({
> >
<Modal className={styles.modal}> <Modal className={styles.modal}>
<Dialog className={styles.dialog} aria-label={title}> <Dialog className={styles.dialog} aria-label={title}>
<aside className={styles.sidePeek}> <aside className={styles.aside}>
<header className={styles.header}> <header className={styles.header}>
{title ? ( <div className={styles.headerContent}>
<Typography variant="Title/md" className={styles.heading}> {title ? (
<h2>{title}</h2> <Typography variant="Title/md" className={styles.heading}>
</Typography> <h2>{title}</h2>
) : null} </Typography>
<IconButton ) : null}
theme="Black" <IconButton
style="Muted" theme="Black"
onPress={() => handleClose(true)} style="Muted"
aria-label={intl.formatMessage({ onPress={() => handleClose(true)}
id: 'common.close', aria-label={intl.formatMessage({
defaultMessage: 'Close', id: 'common.close',
})} defaultMessage: 'Close',
> })}
<MaterialIcon >
icon="close" <MaterialIcon
size={24} icon="close"
color="Icon/Interactive/Default" size={24}
/> color="Icon/Interactive/Default"
</IconButton> />
</IconButton>
</div>
</header> </header>
<div className={styles.sidePeekContent}>{children}</div> <div className={styles.sidePeekContent}>{children}</div>
<KeepBodyVisible /> <KeepBodyVisible />
@@ -90,12 +92,3 @@ export default function SidePeekSelfControlled({
</> </>
) )
} }
function KeepBodyVisible() {
const toggle = useSetOverflowVisibleOnRA()
useEffect(() => {
toggle(true)
return () => toggle(false)
}, [toggle])
return null
}

View File

@@ -1,3 +0,0 @@
export interface SidePeekSelfControlledProps {
title: string
}

View File

@@ -1,81 +0,0 @@
.modal {
--sidepeek-desktop-width: 560px;
}
@keyframes slide-in {
from {
right: calc(-1 * var(--sidepeek-desktop-width));
}
to {
right: 0;
}
}
.modal[data-entering] {
animation: slide-in 250ms;
}
.modal[data-exiting] {
animation: slide-in 250ms reverse;
}
.overlay {
position: fixed;
inset: 0;
z-index: var(--sidepeek-z-index);
background-color: var(--UI-Opacity-Almost-Black-30);
}
.modal {
position: fixed;
top: 0;
right: auto;
bottom: 0;
width: 100%;
height: 100vh;
background-color: var(--Background-Primary);
z-index: var(--sidepeek-z-index);
outline: none;
}
.dialog {
height: 100%;
outline: none;
}
.sidePeek {
display: grid;
grid-template-rows: min-content auto;
height: 100%;
}
.header {
display: flex;
justify-content: flex-end;
border-bottom: 1px solid var(--Base-Border-Subtle);
align-items: center;
padding: var(--Space-x4);
}
.header:has(> h2) {
justify-content: space-between;
}
.heading {
color: var(--Text-Heading);
}
.sidePeekContent {
padding: var(--Space-x4);
overflow-y: auto;
}
@media screen and (min-width: 1367px) {
.modal {
top: 0;
right: 0px;
width: var(--sidepeek-desktop-width);
height: 100vh;
}
}

View File

@@ -11,6 +11,7 @@ import { SidePeekContext } from './SidePeekContext'
import SidePeekSEO from './SidePeekSEO' import SidePeekSEO from './SidePeekSEO'
import { debounce } from '@scandic-hotels/common/utils/debounce' import { debounce } from '@scandic-hotels/common/utils/debounce'
import { KeepBodyVisible } from './KeepBodyVisible'
import styles from './sidePeek.module.css' import styles from './sidePeek.module.css'
interface SidePeekProps { interface SidePeekProps {
@@ -112,6 +113,7 @@ export default function SidePeek({
</div> </div>
</header> </header>
<div className={styles.sidePeekContent}>{children}</div> <div className={styles.sidePeekContent}>{children}</div>
<KeepBodyVisible />
</aside> </aside>
</Dialog> </Dialog>
</Modal> </Modal>

View File

@@ -173,7 +173,7 @@
"./Select": "./lib/components/Select/index.tsx", "./Select": "./lib/components/Select/index.tsx",
"./SidePeek": "./lib/components/SidePeek/index.tsx", "./SidePeek": "./lib/components/SidePeek/index.tsx",
"./SidePeek/SidePeekProvider": "./lib/components/SidePeek/SidePeekContext/SidePeekProvider.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", "./SkeletonShimmer": "./lib/components/SkeletonShimmer/index.tsx",
"./StaticMap": "./lib/components/StaticMap/index.tsx", "./StaticMap": "./lib/components/StaticMap/index.tsx",
"./Subtitle": "./lib/components/Subtitle/index.tsx", "./Subtitle": "./lib/components/Subtitle/index.tsx",