mirror of
https://github.com/vercel/commerce.git
synced 2025-05-18 07:26:59 +00:00
General UI Improvements
This commit is contained in:
parent
fee79b47cf
commit
f46891991e
@ -1,15 +1,11 @@
|
|||||||
|
.root {
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
.root.empty {
|
.root.empty {
|
||||||
@apply bg-secondary text-secondary;
|
@apply bg-secondary text-secondary;
|
||||||
}
|
}
|
||||||
|
|
||||||
.root.success {
|
|
||||||
@apply bg-green text-white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.root.error {
|
|
||||||
@apply bg-red text-white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.lineItemsList {
|
.lineItemsList {
|
||||||
@apply py-4 space-y-6 sm:py-0 sm:space-y-0 sm:divide-y sm:divide-accent-2 border-accent-2;
|
@apply py-4 space-y-6 sm:py-0 sm:space-y-0 sm:divide-y sm:divide-accent-2 border-accent-2;
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
.root {
|
||||||
|
min-height: calc(100vh - 322px);
|
||||||
|
}
|
||||||
|
|
||||||
.lineItemsList {
|
.lineItemsList {
|
||||||
@apply py-4 space-y-6 sm:py-0 sm:space-y-0 sm:divide-y sm:divide-accent-2 border-accent-2;
|
@apply py-4 space-y-6 sm:py-0 sm:space-y-0 sm:divide-y sm:divide-accent-2 border-accent-2;
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,10 @@ const CheckoutSidebarView: FC = () => {
|
|||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SidebarLayout handleBack={() => setSidebarView('CART_VIEW')}>
|
<SidebarLayout
|
||||||
|
className={s.root}
|
||||||
|
handleBack={() => setSidebarView('CART_VIEW')}
|
||||||
|
>
|
||||||
<div className="px-4 sm:px-6 flex-1">
|
<div className="px-4 sm:px-6 flex-1">
|
||||||
<Link href="/cart">
|
<Link href="/cart">
|
||||||
<Text variant="sectionHeading">Checkout</Text>
|
<Text variant="sectionHeading">Checkout</Text>
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
.root {
|
.root {
|
||||||
@apply relative h-full flex flex-col w-full;
|
@apply relative h-full flex flex-col min-h-full w-full;
|
||||||
min-height: 100vh;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
@apply sticky top-0 pl-4 pr-6 pt-4 pb-4 lg:pt-5
|
@apply sticky top-0 pl-4 py-4 pr-6
|
||||||
flex items-center justify-between space-x-3
|
flex items-center justify-between
|
||||||
bg-accent-0 border-b border-accent-2 z-50;
|
bg-accent-0 box-border w-full;
|
||||||
margin-top: 1px;
|
min-height: 66px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.container,
|
@screen lg {
|
||||||
.container > *:first-child {
|
.header {
|
||||||
min-height: calc(100vh - 70px);
|
min-height: 74px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
@apply flex flex-col flex-1 box-border;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ const SidebarLayout: FC<ComponentProps> = ({
|
|||||||
<span className="ml-2 text-accent-7 text-sm ">Close</span>
|
<span className="ml-2 text-accent-7 text-sm ">Close</span>
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{handleBack && (
|
{handleBack && (
|
||||||
<button
|
<button
|
||||||
onClick={handleBack}
|
onClick={handleBack}
|
||||||
@ -39,7 +38,9 @@ const SidebarLayout: FC<ComponentProps> = ({
|
|||||||
<span className="ml-2 text-accent-7 text-xs">Back</span>
|
<span className="ml-2 text-accent-7 text-xs">Back</span>
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
<span className={s.nav}>
|
||||||
<UserNav />
|
<UserNav />
|
||||||
|
</span>
|
||||||
</header>
|
</header>
|
||||||
<div className={s.container}>{children}</div>
|
<div className={s.container}>{children}</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -24,7 +24,6 @@ const UserNav: FC<Props> = ({ className }) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<nav className={cn(s.root, className)}>
|
<nav className={cn(s.root, className)}>
|
||||||
<div className={s.mainContainer}>
|
|
||||||
<ul className={s.list}>
|
<ul className={s.list}>
|
||||||
<li className={s.item} onClick={toggleSidebar}>
|
<li className={s.item} onClick={toggleSidebar}>
|
||||||
<Bag />
|
<Bag />
|
||||||
@ -53,7 +52,6 @@ const UserNav: FC<Props> = ({ className }) => {
|
|||||||
)}
|
)}
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
|
||||||
</nav>
|
</nav>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,11 @@ import { FC, useRef, useEffect, useCallback } from 'react'
|
|||||||
import s from './Modal.module.css'
|
import s from './Modal.module.css'
|
||||||
import FocusTrap from '@lib/focus-trap'
|
import FocusTrap from '@lib/focus-trap'
|
||||||
import { Cross } from '@components/icons'
|
import { Cross } from '@components/icons'
|
||||||
import { disableBodyScroll, clearAllBodyScrollLocks } from 'body-scroll-lock'
|
import {
|
||||||
|
disableBodyScroll,
|
||||||
|
clearAllBodyScrollLocks,
|
||||||
|
enableBodyScroll,
|
||||||
|
} from 'body-scroll-lock'
|
||||||
interface ModalProps {
|
interface ModalProps {
|
||||||
className?: string
|
className?: string
|
||||||
children?: any
|
children?: any
|
||||||
@ -24,14 +28,17 @@ const Modal: FC<ModalProps> = ({ children, onClose }) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (ref.current) {
|
if (ref.current) {
|
||||||
disableBodyScroll(ref.current)
|
disableBodyScroll(ref.current, { reserveScrollBarGap: true })
|
||||||
window.addEventListener('keydown', handleKey)
|
window.addEventListener('keydown', handleKey)
|
||||||
}
|
}
|
||||||
return () => {
|
return () => {
|
||||||
window.removeEventListener('keydown', handleKey)
|
if (ref && ref.current) {
|
||||||
clearAllBodyScrollLocks()
|
enableBodyScroll(ref.current)
|
||||||
}
|
}
|
||||||
}, [open, handleKey])
|
clearAllBodyScrollLocks()
|
||||||
|
window.removeEventListener('keydown', handleKey)
|
||||||
|
}
|
||||||
|
}, [handleKey])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={s.root}>
|
<div className={s.root}>
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
.root {
|
.root {
|
||||||
@apply fixed inset-0 overflow-hidden h-full z-50;
|
@apply fixed inset-0 overflow-hidden h-full z-50 box-border;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar {
|
.sidebar {
|
||||||
@apply h-full flex flex-col text-base bg-accent-0 shadow-xl overflow-y-auto;
|
@apply h-full flex flex-col text-base bg-accent-0 shadow-xl overflow-y-auto;
|
||||||
min-width: 335px;
|
right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.backdrop {
|
.backdrop {
|
||||||
|
@ -16,11 +16,13 @@ const Sidebar: FC<SidebarProps> = ({ children, onClose }) => {
|
|||||||
const ref = useRef() as React.MutableRefObject<HTMLDivElement>
|
const ref = useRef() as React.MutableRefObject<HTMLDivElement>
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('Sidebar', ref)
|
|
||||||
if (ref.current) {
|
if (ref.current) {
|
||||||
disableBodyScroll(ref.current)
|
disableBodyScroll(ref.current, { reserveScrollBarGap: true })
|
||||||
}
|
}
|
||||||
return () => {
|
return () => {
|
||||||
|
if (ref && ref.current) {
|
||||||
|
enableBodyScroll(ref.current)
|
||||||
|
}
|
||||||
clearAllBodyScrollLocks()
|
clearAllBodyScrollLocks()
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
@ -29,8 +31,8 @@ const Sidebar: FC<SidebarProps> = ({ children, onClose }) => {
|
|||||||
<div className={cn(s.root)} ref={ref}>
|
<div className={cn(s.root)} ref={ref}>
|
||||||
<div className="absolute inset-0 overflow-hidden">
|
<div className="absolute inset-0 overflow-hidden">
|
||||||
<div className={s.backdrop} onClick={onClose} />
|
<div className={s.backdrop} onClick={onClose} />
|
||||||
<section className="absolute inset-y-0 right-0 pl-10 max-w-full flex sm:pl-16 outline-none">
|
<section className="absolute inset-y-0 right-0 max-w-full flex outline-none pl-10">
|
||||||
<div className="h-full md:w-screen md:max-w-md">
|
<div className="h-full w-full md:w-screen md:max-w-md">
|
||||||
<div className={s.sidebar}>{children}</div>
|
<div className={s.sidebar}>{children}</div>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
"@react-spring/web": "^9.2.1",
|
"@react-spring/web": "^9.2.1",
|
||||||
"@vercel/fetch": "^6.1.0",
|
"@vercel/fetch": "^6.1.0",
|
||||||
"autoprefixer": "^10.2.6",
|
"autoprefixer": "^10.2.6",
|
||||||
"body-scroll-lock": "^3.1.5",
|
"body-scroll-lock": "2.6.3",
|
||||||
"bowser": "^2.11.0",
|
"bowser": "^2.11.0",
|
||||||
"classnames": "^2.3.1",
|
"classnames": "^2.3.1",
|
||||||
"cookie": "^0.4.1",
|
"cookie": "^0.4.1",
|
||||||
|
@ -1612,10 +1612,10 @@ bn.js@^5.0.0, bn.js@^5.1.1:
|
|||||||
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.1.3.tgz#beca005408f642ebebea80b042b4d18d2ac0ee6b"
|
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.1.3.tgz#beca005408f642ebebea80b042b4d18d2ac0ee6b"
|
||||||
integrity sha512-GkTiFpjFtUzU9CbMeJ5iazkCzGL3jrhzerzZIuqLABjbwRaFt33I9tUdSNryIptM+RxDet6OKm2WnLXzW51KsQ==
|
integrity sha512-GkTiFpjFtUzU9CbMeJ5iazkCzGL3jrhzerzZIuqLABjbwRaFt33I9tUdSNryIptM+RxDet6OKm2WnLXzW51KsQ==
|
||||||
|
|
||||||
body-scroll-lock@^3.1.5:
|
body-scroll-lock@2.6.3:
|
||||||
version "3.1.5"
|
version "2.6.3"
|
||||||
resolved "https://registry.yarnpkg.com/body-scroll-lock/-/body-scroll-lock-3.1.5.tgz#c1392d9217ed2c3e237fee1e910f6cdd80b7aaec"
|
resolved "https://registry.yarnpkg.com/body-scroll-lock/-/body-scroll-lock-2.6.3.tgz#2b9311ef3120696d8ad5c30503f684803ade1606"
|
||||||
integrity sha512-Yi1Xaml0EvNA0OYWxXiYNqY24AfWkbA6w5vxE7GWxtKfzIbZM+Qw+aSmkgsbWzbHiy/RCSkUZBplVxTA+E4jJg==
|
integrity sha512-yQ2VWJasZSWMawwi4bLJ9akbMRTpnS2tZWDEFuOiihwCdl+qNovuUwisnBKIdMk+99wG9FlqW6uZ9+GjKn8ARA==
|
||||||
|
|
||||||
bowser@^2.11.0:
|
bowser@^2.11.0:
|
||||||
version "2.11.0"
|
version "2.11.0"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user