mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 12:24:18 +00:00
🎨 styles: add cart drawer layer
:%s
This commit is contained in:
@@ -4,6 +4,6 @@
|
|||||||
.cartDrawer {
|
.cartDrawer {
|
||||||
@apply flex flex-col h-full;
|
@apply flex flex-col h-full;
|
||||||
.body {
|
.body {
|
||||||
@apply flex flex-col justify-center overflow-y-auto overflow-x-hidden h-full custom-scroll;
|
@apply flex flex-col overflow-y-auto overflow-x-hidden h-full custom-scroll;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,21 +1,36 @@
|
|||||||
@import "../../../styles/utilities";
|
@import "../../../styles/utilities";
|
||||||
|
|
||||||
.drawerCommon {
|
.drawerCommon {
|
||||||
@apply fixed flex justify-end transition-all duration-200;
|
@apply fixed flex justify-end transition-all duration-500;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
top: 0;
|
top: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
width: 90%;
|
width: 100%;
|
||||||
box-shadow: -3px 0 10px rgba(0, 0, 0, 0.15);
|
|
||||||
z-index: 20000;
|
z-index: 20000;
|
||||||
|
transform: translateX(110%);
|
||||||
|
|
||||||
|
&.show {
|
||||||
|
.innerWrap {
|
||||||
|
background: rgba(0, 0, 0, 0.2);
|
||||||
|
animation: animateBackground 0.8s;
|
||||||
|
}
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.innerWrap {
|
||||||
|
@apply w-full;
|
||||||
|
background: none;
|
||||||
|
}
|
||||||
.inner {
|
.inner {
|
||||||
@apply flex flex-col bg-white;
|
@apply flex flex-col bg-white;
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin-right: 0;
|
margin-left: auto;
|
||||||
|
box-shadow: -3px 0 10px rgba(0, 0, 0, 0.15);
|
||||||
|
// transform: none;
|
||||||
|
|
||||||
@screen md {
|
@screen md {
|
||||||
max-width: 52rem;
|
max-width: 52rem;
|
||||||
}
|
}
|
||||||
@@ -39,14 +54,21 @@
|
|||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
&.hide {
|
|
||||||
transform: translateX(110%);
|
|
||||||
}
|
|
||||||
|
|
||||||
@screen md {
|
@screen md {
|
||||||
width: unset;
|
|
||||||
.inner {
|
.inner {
|
||||||
min-width: 48rem;
|
min-width: 48rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes animateBackground {
|
||||||
|
0%,
|
||||||
|
50% {
|
||||||
|
background: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
background: rgba(0, 0, 0, 0.2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -11,12 +11,21 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const DrawerCommon = ({ title, visible, children, onClose }: Props) => {
|
const DrawerCommon = ({ title, visible, children, onClose }: Props) => {
|
||||||
|
const refInner = useRef<HTMLDivElement>(null)
|
||||||
|
|
||||||
|
const handleClickOut = (e: any) => {
|
||||||
|
if (e.target.contains(refInner.current)) {
|
||||||
|
onClose()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames({
|
<div className={classNames({
|
||||||
[s.drawerCommon]: true,
|
[s.drawerCommon]: true,
|
||||||
[s.hide]: !visible
|
[s.show]: visible
|
||||||
})}>
|
})}>
|
||||||
<div className={s.inner}>
|
<div className={s.innerWrap} onClick={handleClickOut}>
|
||||||
|
<div className={s.inner} ref={refInner}>
|
||||||
<div className={s.top}>
|
<div className={s.top}>
|
||||||
<h4 className={s.heading}>
|
<h4 className={s.heading}>
|
||||||
{title}
|
{title}
|
||||||
@@ -30,6 +39,7 @@ const DrawerCommon = ({ title, visible, children, onClose }: Props) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user