diff --git a/apps/scandic-web/components/ContentType/HotelPage/SidePeeks/RestaurantBar/RestaurantBarItem/restaurantBarItem.module.css b/apps/scandic-web/components/ContentType/HotelPage/SidePeeks/RestaurantBar/RestaurantBarItem/restaurantBarItem.module.css index 55e197502..6a823e980 100644 --- a/apps/scandic-web/components/ContentType/HotelPage/SidePeeks/RestaurantBar/RestaurantBarItem/restaurantBarItem.module.css +++ b/apps/scandic-web/components/ContentType/HotelPage/SidePeeks/RestaurantBar/RestaurantBarItem/restaurantBarItem.module.css @@ -5,22 +5,24 @@ .stickyHeading { 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; gap: var(--Space-x1); color: var(--Text-Interactive-Default); align-items: center; -} -/* Hack to make it look like the heading has a background which covers the top of the sidepeek */ -.stickyHeading::before { - content: ""; - position: absolute; - margin-top: calc(-1 * var(--Space-x4)); - background-color: var(--Background-Primary); - z-index: -1; - width: 100%; - top: 0; - bottom: -16px; + + /* Hack to make it look like the heading has a background which covers the top of the sidepeek */ + &::before { + content: ""; + position: absolute; + margin-top: calc(-1 * var(--Space-x4)); + background-color: var(--Background-Primary); + z-index: -1; + width: 100%; + top: 0; + bottom: -16px; + } } .content { diff --git a/packages/design-system/lib/components/Button/button.module.css b/packages/design-system/lib/components/Button/button.module.css index df04f153f..1af64c26b 100644 --- a/packages/design-system/lib/components/Button/button.module.css +++ b/packages/design-system/lib/components/Button/button.module.css @@ -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 { diff --git a/packages/design-system/lib/components/ButtonLink/buttonLink.module.css b/packages/design-system/lib/components/ButtonLink/buttonLink.module.css index e5c18148a..78aab83fd 100644 --- a/packages/design-system/lib/components/ButtonLink/buttonLink.module.css +++ b/packages/design-system/lib/components/ButtonLink/buttonLink.module.css @@ -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; + } } diff --git a/packages/design-system/lib/components/SidePeek/index.tsx b/packages/design-system/lib/components/SidePeek/index.tsx index 24f763227..0959f9f13 100644 --- a/packages/design-system/lib/components/SidePeek/index.tsx +++ b/packages/design-system/lib/components/SidePeek/index.tsx @@ -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) { const rootDiv = useRef(null) + const headerRef = useRef(null) + const dialogRef = useRef(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 > - + diff --git a/packages/design-system/lib/components/SidePeek/sidePeek.module.css b/packages/design-system/lib/components/SidePeek/sidePeek.module.css index 98ccfdc54..46ab10d11 100644 --- a/packages/design-system/lib/components/SidePeek/sidePeek.module.css +++ b/packages/design-system/lib/components/SidePeek/sidePeek.module.css @@ -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; } }