fix(BOOK-146): Added scrolling possibility on Sidepeek dialog instead of content to support keyboard scrolling
Approved-by: Bianca Widstam
This commit is contained in:
@@ -16,10 +16,11 @@
|
||||
&[data-pending] {
|
||||
cursor: progress;
|
||||
}
|
||||
}
|
||||
.button:focus-visible {
|
||||
outline: 2px auto -webkit-focus-ring-color; /*color should probably be cutomized for each variant later on*/
|
||||
outline-offset: 1px;
|
||||
|
||||
&:focus-visible {
|
||||
outline: 2px auto -webkit-focus-ring-color;
|
||||
outline-offset: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
.size-large {
|
||||
@@ -179,6 +180,7 @@
|
||||
.variant-text.no-wrapping {
|
||||
padding: var(--Space-x025) 0;
|
||||
border-width: 0;
|
||||
border-radius: 0;
|
||||
}
|
||||
|
||||
.variant-text.color-inverted {
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: var(--Space-x05);
|
||||
}
|
||||
|
||||
.buttonLink:focus-visible {
|
||||
outline: 2px auto -webkit-focus-ring-color;
|
||||
outline-offset: 1px;
|
||||
&:focus-visible {
|
||||
outline: 2px auto -webkit-focus-ring-color;
|
||||
outline-offset: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import { useContext, useRef } from 'react'
|
||||
import { useCallback, useContext, useRef } from 'react'
|
||||
import { Dialog, Modal, ModalOverlay } from 'react-aria-components'
|
||||
import { IconButton } from '../IconButton'
|
||||
import { MaterialIcon } from '../Icons/MaterialIcon'
|
||||
@@ -10,6 +10,7 @@ import { SidePeekContext } from './SidePeekContext'
|
||||
|
||||
import SidePeekSEO from './SidePeekSEO'
|
||||
|
||||
import { debounce } from '@scandic-hotels/common/utils/debounce'
|
||||
import styles from './sidePeek.module.css'
|
||||
|
||||
interface SidePeekProps {
|
||||
@@ -31,8 +32,33 @@ export default function SidePeek({
|
||||
closeLabel,
|
||||
}: React.PropsWithChildren<SidePeekProps>) {
|
||||
const rootDiv = useRef<HTMLDivElement>(null)
|
||||
const headerRef = useRef<HTMLElement>(null)
|
||||
const dialogRef = useRef<HTMLDivElement>(null)
|
||||
|
||||
const context = useContext(SidePeekContext)
|
||||
|
||||
const updateHeightRefCallback = useCallback((node: HTMLElement | null) => {
|
||||
if (node) {
|
||||
const debouncedUpdate = debounce(([entry]: ResizeObserverEntry[]) => {
|
||||
const height = entry.contentRect.height
|
||||
|
||||
dialogRef.current?.style.setProperty(
|
||||
'--sidepeek-header-height',
|
||||
`${height}px`
|
||||
)
|
||||
}, 100)
|
||||
|
||||
const observer = new ResizeObserver(debouncedUpdate)
|
||||
observer.observe(node)
|
||||
|
||||
return () => {
|
||||
observer.unobserve(node)
|
||||
observer.disconnect()
|
||||
dialogRef.current?.style.removeProperty('--sidepeek-header-height')
|
||||
}
|
||||
}
|
||||
}, [])
|
||||
|
||||
function onClose() {
|
||||
const closeHandler = handleClose || context?.handleClose
|
||||
closeHandler?.(false)
|
||||
@@ -51,25 +77,37 @@ export default function SidePeek({
|
||||
isDismissable
|
||||
>
|
||||
<Modal className={styles.modal}>
|
||||
<Dialog className={styles.dialog} aria-label={title}>
|
||||
<Dialog
|
||||
ref={dialogRef}
|
||||
className={styles.dialog}
|
||||
aria-label={title}
|
||||
>
|
||||
<aside className={styles.aside}>
|
||||
<header className={styles.header}>
|
||||
{title ? (
|
||||
<Typography variant="Title/md">
|
||||
<h2 className={styles.heading}>{title}</h2>
|
||||
</Typography>
|
||||
) : null}
|
||||
<IconButton
|
||||
theme="Black"
|
||||
style="Muted"
|
||||
aria-label={closeLabel}
|
||||
onPress={onClose}
|
||||
>
|
||||
<MaterialIcon
|
||||
icon="close"
|
||||
color="Icon/Interactive/Default"
|
||||
/>
|
||||
</IconButton>
|
||||
<header
|
||||
ref={(node) => {
|
||||
headerRef.current = node
|
||||
return updateHeightRefCallback(node)
|
||||
}}
|
||||
className={styles.header}
|
||||
>
|
||||
<div className={styles.headerContent}>
|
||||
{title ? (
|
||||
<Typography variant="Title/md">
|
||||
<h2 className={styles.heading}>{title}</h2>
|
||||
</Typography>
|
||||
) : null}
|
||||
<IconButton
|
||||
theme="Black"
|
||||
style="Muted"
|
||||
aria-label={closeLabel}
|
||||
onPress={onClose}
|
||||
>
|
||||
<MaterialIcon
|
||||
icon="close"
|
||||
color="Icon/Interactive/Default"
|
||||
/>
|
||||
</IconButton>
|
||||
</div>
|
||||
</header>
|
||||
<div className={styles.sidePeekContent}>{children}</div>
|
||||
</aside>
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
.overlay {
|
||||
--sidepeek-desktop-width: 560px;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
inset: 0;
|
||||
z-index: var(--sidepeek-z-index);
|
||||
background-color: var(--UI-Opacity-Almost-Black-30);
|
||||
}
|
||||
@@ -17,40 +14,47 @@
|
||||
width: 100%;
|
||||
height: 100vh;
|
||||
background-color: var(--Background-Primary);
|
||||
z-index: var(--sidepeek-z-index);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.modal[data-entering] {
|
||||
animation: slide-in 250ms;
|
||||
}
|
||||
&[data-entering] {
|
||||
animation: slide-in 250ms;
|
||||
}
|
||||
|
||||
.modal[data-exiting] {
|
||||
animation: slide-in 250ms reverse;
|
||||
&[data-exiting] {
|
||||
animation: slide-in 250ms reverse;
|
||||
}
|
||||
}
|
||||
|
||||
.dialog {
|
||||
height: 100%;
|
||||
outline: none;
|
||||
overflow: auto;
|
||||
--sidepeek-header-height: auto;
|
||||
}
|
||||
|
||||
.aside {
|
||||
position: relative;
|
||||
display: grid;
|
||||
grid-template-rows: min-content auto;
|
||||
height: 100dvh;
|
||||
min-height: 100dvh;
|
||||
}
|
||||
|
||||
.header {
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 2;
|
||||
background-color: var(--Background-Primary);
|
||||
}
|
||||
|
||||
.headerContent {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
border-bottom: 1px solid var(--Base-Border-Subtle);
|
||||
align-items: flex-start;
|
||||
padding: var(--Space-x4);
|
||||
}
|
||||
|
||||
.header:has(.heading) {
|
||||
justify-content: space-between;
|
||||
&:has(.heading) {
|
||||
justify-content: space-between;
|
||||
}
|
||||
}
|
||||
|
||||
.heading {
|
||||
@@ -61,15 +65,12 @@
|
||||
|
||||
.sidePeekContent {
|
||||
padding: var(--Space-x4);
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1367px) {
|
||||
.modal {
|
||||
top: 0;
|
||||
right: 0px;
|
||||
right: 0;
|
||||
width: var(--sidepeek-desktop-width);
|
||||
height: 100vh;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user