diff --git a/src/material/BottomSheet.css b/src/material/BottomSheet.module.css similarity index 66% rename from src/material/BottomSheet.css rename to src/material/BottomSheet.module.css index 1d5a937..0b80c42 100644 --- a/src/material/BottomSheet.css +++ b/src/material/BottomSheet.module.css @@ -1,4 +1,7 @@ -.BottomSheet { +.bottomSheet { + composes: surface from "./material.module.css"; + composes: cardGutSkip from "./cards.module.css"; + composes: cardNoPad from "./cards.module.css"; border: none; position: fixed; left: 50%; @@ -13,17 +16,24 @@ max-height: 100dvh; height: 95%; contain: strict; - contain-intrinsic-size: auto 560px auto 95vh; - + contain-intrinsic-size: 100% 95%; &::backdrop { - background: none; + transition-property: background-color, opacity; + transition-duration: 120ms; + transition-timing-function: var(--tutu-anim-curve-std); + transition-behavior: allow-discrete; + } + + &[open]::backdrop { + background-color: black; + opacity: 0.5; } box-shadow: var(--tutu-shadow-e16); - .MuiToolbar-root { - >.MuiButtonBase-root { + :global(.MuiToolbar-root) { + > :global(.MuiButtonBase-root) { &:first-child { margin-left: -0.5em; @@ -57,6 +67,11 @@ overflow: hidden; will-change: width, height, top, left; + &::backdrop { + opacity: 0; + background-color: transparent; + } + & * { overflow: hidden; } @@ -78,4 +93,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/material/BottomSheet.tsx b/src/material/BottomSheet.tsx index cd38df7..4e00868 100644 --- a/src/material/BottomSheet.tsx +++ b/src/material/BottomSheet.tsx @@ -7,9 +7,8 @@ import { type ParentComponent, type ResolvedChildren, } from "solid-js"; -import "./BottomSheet.css"; +import styles from "./BottomSheet.module.css"; import { useHeroSignal } from "../platform/anim"; -import material from "./material.module.css"; export type BottomSheetProps = { open?: boolean; @@ -98,7 +97,7 @@ const BottomSheet: ParentComponent = (props) => { const srcElement = hero(); const startRect = srcElement?.getBoundingClientRect(); if (!startRect) { - console.debug("no source element"); + console.debug("no source element") } if (startRect) { srcElement!.style.visibility = "hidden"; @@ -114,7 +113,7 @@ const BottomSheet: ParentComponent = (props) => { const animateSlideInFromRight = (element: HTMLElement, reserve?: boolean) => { const rect = element.getBoundingClientRect(); const easing = "cubic-bezier(0.4, 0, 0.2, 1)"; - element.classList.add("animated"); + element.classList.add(styles.animated); const oldOverflow = document.body.style.overflow; document.body.style.overflow = "hidden"; const distance = Math.abs(rect.left - window.innerWidth); @@ -129,7 +128,7 @@ const BottomSheet: ParentComponent = (props) => { { easing, duration }, ); const onAnimationEnd = () => { - element.classList.remove("animated"); + element.classList.remove(styles.animated); document.body.style.overflow = oldOverflow; animation = undefined; }; @@ -144,7 +143,7 @@ const BottomSheet: ParentComponent = (props) => { ) => { const rect = element.getBoundingClientRect(); const easing = "cubic-bezier(0.4, 0, 0.2, 1)"; - element.classList.add("animated"); + element.classList.add(styles.animated); const oldOverflow = document.body.style.overflow; document.body.style.overflow = "hidden"; const distance = Math.abs(rect.top - window.innerHeight); @@ -159,7 +158,7 @@ const BottomSheet: ParentComponent = (props) => { { easing, duration }, ); const onAnimationEnd = () => { - element.classList.remove("animated"); + element.classList.remove(styles.animated); document.body.style.overflow = oldOverflow; animation = undefined; }; @@ -175,7 +174,7 @@ const BottomSheet: ParentComponent = (props) => { reserve?: boolean, ) => { const easing = "cubic-bezier(0.4, 0, 0.2, 1)"; - element.classList.add("animated"); + element.classList.add(styles.animated); const distance = Math.sqrt( Math.pow(Math.abs(startRect.top - endRect.top), 2) + Math.pow(Math.abs(startRect.left - startRect.top), 2), @@ -189,7 +188,7 @@ const BottomSheet: ParentComponent = (props) => { { easing, duration }, ); const onAnimationEnd = () => { - element.classList.remove("animated"); + element.classList.remove(styles.animated); animation = undefined; }; animation.addEventListener("finish", onAnimationEnd); @@ -219,11 +218,9 @@ const BottomSheet: ParentComponent = (props) => { return ( = (props) => { e.stopPropagation(); } }} - class="Menu" style={{ + position: "fixed", left: px(anchorPos().left), top: px(anchorPos().top), + border: "none", + "border-radius": "2px", + padding: 0, + "max-width": "560px", + width: "max-content", /* FIXME: the content may be overflow */ + "box-shadow": "var(--tutu-shadow-e8)", }} >