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:
@@ -5,14 +5,15 @@
|
|||||||
|
|
||||||
.stickyHeading {
|
.stickyHeading {
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: 0;
|
/* Position below the SidePeek header using the CSS variable set by the SidePeek component including some extra spacing */
|
||||||
|
top: calc(var(--sidepeek-header-height, 0px) + var(--Space-x4));
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: var(--Space-x1);
|
gap: var(--Space-x1);
|
||||||
color: var(--Text-Interactive-Default);
|
color: var(--Text-Interactive-Default);
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
|
||||||
/* Hack to make it look like the heading has a background which covers the top of the sidepeek */
|
/* Hack to make it look like the heading has a background which covers the top of the sidepeek */
|
||||||
.stickyHeading::before {
|
&::before {
|
||||||
content: "";
|
content: "";
|
||||||
position: absolute;
|
position: absolute;
|
||||||
margin-top: calc(-1 * var(--Space-x4));
|
margin-top: calc(-1 * var(--Space-x4));
|
||||||
@@ -21,6 +22,7 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
top: 0;
|
top: 0;
|
||||||
bottom: -16px;
|
bottom: -16px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
|
|||||||
@@ -16,10 +16,11 @@
|
|||||||
&[data-pending] {
|
&[data-pending] {
|
||||||
cursor: progress;
|
cursor: progress;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
.button:focus-visible {
|
&:focus-visible {
|
||||||
outline: 2px auto -webkit-focus-ring-color; /*color should probably be cutomized for each variant later on*/
|
outline: 2px auto -webkit-focus-ring-color;
|
||||||
outline-offset: 1px;
|
outline-offset: 4px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.size-large {
|
.size-large {
|
||||||
@@ -179,6 +180,7 @@
|
|||||||
.variant-text.no-wrapping {
|
.variant-text.no-wrapping {
|
||||||
padding: var(--Space-x025) 0;
|
padding: var(--Space-x025) 0;
|
||||||
border-width: 0;
|
border-width: 0;
|
||||||
|
border-radius: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.variant-text.color-inverted {
|
.variant-text.color-inverted {
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
gap: var(--Space-x05);
|
gap: var(--Space-x05);
|
||||||
}
|
|
||||||
|
|
||||||
.buttonLink:focus-visible {
|
&:focus-visible {
|
||||||
outline: 2px auto -webkit-focus-ring-color;
|
outline: 2px auto -webkit-focus-ring-color;
|
||||||
outline-offset: 1px;
|
outline-offset: 4px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { useContext, useRef } from 'react'
|
import { useCallback, useContext, useRef } from 'react'
|
||||||
import { Dialog, Modal, ModalOverlay } from 'react-aria-components'
|
import { Dialog, Modal, ModalOverlay } from 'react-aria-components'
|
||||||
import { IconButton } from '../IconButton'
|
import { IconButton } from '../IconButton'
|
||||||
import { MaterialIcon } from '../Icons/MaterialIcon'
|
import { MaterialIcon } from '../Icons/MaterialIcon'
|
||||||
@@ -10,6 +10,7 @@ import { SidePeekContext } from './SidePeekContext'
|
|||||||
|
|
||||||
import SidePeekSEO from './SidePeekSEO'
|
import SidePeekSEO from './SidePeekSEO'
|
||||||
|
|
||||||
|
import { debounce } from '@scandic-hotels/common/utils/debounce'
|
||||||
import styles from './sidePeek.module.css'
|
import styles from './sidePeek.module.css'
|
||||||
|
|
||||||
interface SidePeekProps {
|
interface SidePeekProps {
|
||||||
@@ -31,8 +32,33 @@ export default function SidePeek({
|
|||||||
closeLabel,
|
closeLabel,
|
||||||
}: React.PropsWithChildren<SidePeekProps>) {
|
}: React.PropsWithChildren<SidePeekProps>) {
|
||||||
const rootDiv = useRef<HTMLDivElement>(null)
|
const rootDiv = useRef<HTMLDivElement>(null)
|
||||||
|
const headerRef = useRef<HTMLElement>(null)
|
||||||
|
const dialogRef = useRef<HTMLDivElement>(null)
|
||||||
|
|
||||||
const context = useContext(SidePeekContext)
|
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() {
|
function onClose() {
|
||||||
const closeHandler = handleClose || context?.handleClose
|
const closeHandler = handleClose || context?.handleClose
|
||||||
closeHandler?.(false)
|
closeHandler?.(false)
|
||||||
@@ -51,9 +77,20 @@ export default function SidePeek({
|
|||||||
isDismissable
|
isDismissable
|
||||||
>
|
>
|
||||||
<Modal className={styles.modal}>
|
<Modal className={styles.modal}>
|
||||||
<Dialog className={styles.dialog} aria-label={title}>
|
<Dialog
|
||||||
|
ref={dialogRef}
|
||||||
|
className={styles.dialog}
|
||||||
|
aria-label={title}
|
||||||
|
>
|
||||||
<aside className={styles.aside}>
|
<aside className={styles.aside}>
|
||||||
<header className={styles.header}>
|
<header
|
||||||
|
ref={(node) => {
|
||||||
|
headerRef.current = node
|
||||||
|
return updateHeightRefCallback(node)
|
||||||
|
}}
|
||||||
|
className={styles.header}
|
||||||
|
>
|
||||||
|
<div className={styles.headerContent}>
|
||||||
{title ? (
|
{title ? (
|
||||||
<Typography variant="Title/md">
|
<Typography variant="Title/md">
|
||||||
<h2 className={styles.heading}>{title}</h2>
|
<h2 className={styles.heading}>{title}</h2>
|
||||||
@@ -70,6 +107,7 @@ export default function SidePeek({
|
|||||||
color="Icon/Interactive/Default"
|
color="Icon/Interactive/Default"
|
||||||
/>
|
/>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<div className={styles.sidePeekContent}>{children}</div>
|
<div className={styles.sidePeekContent}>{children}</div>
|
||||||
</aside>
|
</aside>
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
.overlay {
|
.overlay {
|
||||||
--sidepeek-desktop-width: 560px;
|
--sidepeek-desktop-width: 560px;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
inset: 0;
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
z-index: var(--sidepeek-z-index);
|
z-index: var(--sidepeek-z-index);
|
||||||
background-color: var(--UI-Opacity-Almost-Black-30);
|
background-color: var(--UI-Opacity-Almost-Black-30);
|
||||||
}
|
}
|
||||||
@@ -17,40 +14,47 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
background-color: var(--Background-Primary);
|
background-color: var(--Background-Primary);
|
||||||
z-index: var(--sidepeek-z-index);
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.modal[data-entering] {
|
&[data-entering] {
|
||||||
animation: slide-in 250ms;
|
animation: slide-in 250ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
.modal[data-exiting] {
|
&[data-exiting] {
|
||||||
animation: slide-in 250ms reverse;
|
animation: slide-in 250ms reverse;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.dialog {
|
.dialog {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
outline: none;
|
outline: none;
|
||||||
|
overflow: auto;
|
||||||
|
--sidepeek-header-height: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.aside {
|
.aside {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-rows: min-content auto;
|
grid-template-rows: min-content auto;
|
||||||
height: 100dvh;
|
min-height: 100dvh;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 2;
|
||||||
|
background-color: var(--Background-Primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.headerContent {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
border-bottom: 1px solid var(--Base-Border-Subtle);
|
border-bottom: 1px solid var(--Base-Border-Subtle);
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
padding: var(--Space-x4);
|
padding: var(--Space-x4);
|
||||||
}
|
|
||||||
|
|
||||||
.header:has(.heading) {
|
&:has(.heading) {
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.heading {
|
.heading {
|
||||||
@@ -61,15 +65,12 @@
|
|||||||
|
|
||||||
.sidePeekContent {
|
.sidePeekContent {
|
||||||
padding: var(--Space-x4);
|
padding: var(--Space-x4);
|
||||||
overflow-y: auto;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (min-width: 1367px) {
|
@media screen and (min-width: 1367px) {
|
||||||
.modal {
|
.modal {
|
||||||
top: 0;
|
right: 0;
|
||||||
right: 0px;
|
|
||||||
width: var(--sidepeek-desktop-width);
|
width: var(--sidepeek-desktop-width);
|
||||||
height: 100vh;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user