New Updates.

This commit is contained in:
Bel Curcio 2022-03-10 12:50:13 +01:00
parent f80ace2c6c
commit b140fef036
14 changed files with 161 additions and 170 deletions

View File

@ -4,11 +4,9 @@
--secondary: #000000; --secondary: #000000;
--secondary-2: #111; --secondary-2: #111;
--selection: var(--cyan); --selection: var(--cyan);
--text-base: #000000; --text-base: #000000;
--text-primary: #000000; --text-primary: #000000;
--text-secondary: white; --text-secondary: white;
--hover: rgba(0, 0, 0, 0.075); --hover: rgba(0, 0, 0, 0.075);
--hover-1: rgba(0, 0, 0, 0.15); --hover-1: rgba(0, 0, 0, 0.15);
--hover-2: rgba(0, 0, 0, 0.25); --hover-2: rgba(0, 0, 0, 0.25);
@ -17,15 +15,11 @@
--red: #da3c3c; --red: #da3c3c;
--purple: #f81ce5; --purple: #f81ce5;
--blue: #0070f3; --blue: #0070f3;
--pink: #ff0080; --pink: #ff0080;
--pink-light: #ff379c; --pink-light: #ff379c;
--magenta: #eb367f; --magenta: #eb367f;
--violet: #7928ca; --violet: #7928ca;
--violet-dark: #4c2889; --violet-dark: #4c2889;
--accent-0: #fff; --accent-0: #fff;
--accent-1: #fafafa; --accent-1: #fafafa;
--accent-2: #eaeaea; --accent-2: #eaeaea;
@ -36,7 +30,6 @@
--accent-7: #333333; --accent-7: #333333;
--accent-8: #111111; --accent-8: #111111;
--accent-9: #000; --accent-9: #000;
--font-sans: -apple-system, system-ui, BlinkMacSystemFont, 'Helvetica Neue', --font-sans: -apple-system, system-ui, BlinkMacSystemFont, 'Helvetica Neue',
'Helvetica', sans-serif; 'Helvetica', sans-serif;
} }
@ -50,11 +43,9 @@
--hover-1: rgba(255, 255, 255, 0.15); --hover-1: rgba(255, 255, 255, 0.15);
--hover-2: rgba(255, 255, 255, 0.25); --hover-2: rgba(255, 255, 255, 0.25);
--selection: var(--purple); --selection: var(--purple);
--text-base: white; --text-base: white;
--text-primary: white; --text-primary: white;
--text-secondary: black; --text-secondary: black;
--accent-9: #fff; --accent-9: #fff;
--accent-8: #fafafa; --accent-8: #fafafa;
--accent-7: #eaeaea; --accent-7: #eaeaea;
@ -73,17 +64,11 @@
box-sizing: inherit; box-sizing: inherit;
} }
html { html,
body {
height: 100%; height: 100%;
box-sizing: border-box; box-sizing: border-box;
touch-action: manipulation; touch-action: manipulation;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
html,
body {
font-family: var(--font-sans); font-family: var(--font-sans);
text-rendering: optimizeLegibility; text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
@ -104,15 +89,15 @@ a {
} }
.animated { .animated {
-webkit-animation-duration: 1s;
animation-duration: 1s; animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both; animation-fill-mode: both;
-webkit-animation-duration: 1s;
-webkit-animation-fill-mode: both;
} }
.fadeIn { .fadeIn {
-webkit-animation-name: fadeIn;
animation-name: fadeIn; animation-name: fadeIn;
-webkit-animation-name: fadeIn;
} }
@-webkit-keyframes fadeIn { @-webkit-keyframes fadeIn {

View File

@ -1,5 +1,5 @@
import cn from 'clsx' import cn from 'clsx'
import React, { FC } from 'react' import React from 'react'
import dynamic from 'next/dynamic' import dynamic from 'next/dynamic'
import { useRouter } from 'next/router' import { useRouter } from 'next/router'
import { CommerceProvider } from '@framework' import { CommerceProvider } from '@framework'
@ -14,7 +14,9 @@ import { Sidebar, Button, LoadingDots } from '@components/ui'
import PaymentMethodView from '@components/checkout/PaymentMethodView' import PaymentMethodView from '@components/checkout/PaymentMethodView'
import CheckoutSidebarView from '@components/checkout/CheckoutSidebarView' import CheckoutSidebarView from '@components/checkout/CheckoutSidebarView'
import { CheckoutProvider } from '@components/checkout/context' import { CheckoutProvider } from '@components/checkout/context'
import MenuSidebarView, { Link } from '../UserNav/MenuSidebarView' import MenuSidebarView from '../UserNav/MenuSidebarView'
import type { Link as LinkProps } from '../UserNav/MenuSidebarView'
import LoginView from '@components/auth/LoginView' import LoginView from '@components/auth/LoginView'
import s from './Layout.module.css' import s from './Layout.module.css'
@ -29,35 +31,26 @@ const dynamicProps = {
loading: Loading, loading: Loading,
} }
const SignUpView = dynamic( const SignUpView = dynamic(() => import('@components/auth/SignUpView'), {
() => import('@components/auth/SignUpView'), ...dynamicProps,
{ })
...dynamicProps
}
)
const ForgotPassword = dynamic( const ForgotPassword = dynamic(
() => import('@components/auth/ForgotPassword'), () => import('@components/auth/ForgotPassword'),
{
...dynamicProps
}
)
const FeatureBar = dynamic(
() => import('@components/common/FeatureBar'),
{
...dynamicProps
}
)
const Modal = dynamic(
() => import('@components/ui/Modal'),
{ {
...dynamicProps, ...dynamicProps,
ssr: false
} }
) )
const FeatureBar = dynamic(() => import('@components/common/FeatureBar'), {
...dynamicProps,
})
const Modal = dynamic(() => import('@components/ui/Modal'), {
...dynamicProps,
ssr: false,
})
interface Props { interface Props {
pageProps: { pageProps: {
pages?: Page[] pages?: Page[]
@ -65,7 +58,7 @@ interface Props {
} }
} }
const ModalView: FC<{ modalView: string; closeModal(): any }> = ({ const ModalView: React.FC<{ modalView: string; closeModal(): any }> = ({
modalView, modalView,
closeModal, closeModal,
}) => { }) => {
@ -78,30 +71,31 @@ const ModalView: FC<{ modalView: string; closeModal(): any }> = ({
) )
} }
const ModalUI: FC = () => { const ModalUI: React.FC = () => {
const { displayModal, closeModal, modalView } = useUI() const { displayModal, closeModal, modalView } = useUI()
return displayModal ? ( return displayModal ? (
<ModalView modalView={modalView} closeModal={closeModal} /> <ModalView modalView={modalView} closeModal={closeModal} />
) : null ) : null
} }
const SidebarView: FC<{ const SidebarView: React.FC<{
sidebarView: string sidebarView: string
closeSidebar(): any closeSidebar(): any
links: Link[] links: LinkProps[]
}> = ({ sidebarView, closeSidebar, links }) => { }> = ({ sidebarView, closeSidebar, links }) => {
return ( return (
<Sidebar onClose={closeSidebar}> <Sidebar onClose={closeSidebar}>
{sidebarView === 'MOBILEMENU_VIEW' && <MenuSidebarView links={links} />}
{sidebarView === 'CART_VIEW' && <CartSidebarView />} {sidebarView === 'CART_VIEW' && <CartSidebarView />}
{sidebarView === 'CHECKOUT_VIEW' && <CheckoutSidebarView />} {sidebarView === 'CHECKOUT_VIEW' && <CheckoutSidebarView />}
{sidebarView === 'PAYMENT_VIEW' && <PaymentMethodView />} {sidebarView === 'PAYMENT_VIEW' && <PaymentMethodView />}
{sidebarView === 'SHIPPING_VIEW' && <ShippingView />} {sidebarView === 'SHIPPING_VIEW' && <ShippingView />}
{sidebarView === 'MOBILE_CUSTOMERMENU_VIEW' && <MenuSidebarView />}
{sidebarView === 'MOBILE_MENU_VIEW' && <MenuSidebarView links={links} />}
</Sidebar> </Sidebar>
) )
} }
const SidebarUI: FC<{ links: any }> = ({ links }) => { const SidebarUI: React.FC<{ links: LinkProps[] }> = ({ links }) => {
const { displaySidebar, closeSidebar, sidebarView } = useUI() const { displaySidebar, closeSidebar, sidebarView } = useUI()
return displaySidebar ? ( return displaySidebar ? (
<SidebarView <SidebarView
@ -112,7 +106,7 @@ const SidebarUI: FC<{ links: any }> = ({ links }) => {
) : null ) : null
} }
const Layout: FC<Props> = ({ const Layout: React.FC<Props> = ({
children, children,
pageProps: { categories = [], ...pageProps }, pageProps: { categories = [], ...pageProps },
}) => { }) => {

View File

@ -12,3 +12,13 @@
.link.active { .link.active {
@apply font-bold bg-accent-2; @apply font-bold bg-accent-2;
} }
.root {
display: hidden;
}
@media (min-width: 767px) {
.root {
display: block;
}
}

View File

@ -3,19 +3,10 @@ import cn from 'clsx'
import Link from 'next/link' import Link from 'next/link'
import { useTheme } from 'next-themes' import { useTheme } from 'next-themes'
import { Moon, Sun } from '@components/icons' import { Moon, Sun } from '@components/icons'
import { useUI } from '@components/ui/context'
import useLogout from '@framework/auth/use-logout' import useLogout from '@framework/auth/use-logout'
import { Avatar } from '@components/common'
import { useRouter } from 'next/router' import { useRouter } from 'next/router'
import { import { DropdownMenuItem } from '@components/ui/Dropdown/Dropdown'
Dropdown,
DropdownContent,
DropdownTrigger,
DropdownMenuItem,
DropdownMenuGroup,
} from '@components/ui/Dropdown/Dropdown'
import { useEffect } from 'react'
const LINKS = [ const LINKS = [
{ {
@ -32,11 +23,10 @@ const LINKS = [
}, },
] ]
const DropdownMenu: React.FC = () => { export default function CustomerMenuContent() {
const logout = useLogout() const logout = useLogout()
const { pathname } = useRouter() const { pathname } = useRouter()
const { theme, setTheme } = useTheme() const { theme, setTheme } = useTheme()
// const { closeSidebarIfPresent } = useUI()
const router = useRouter() const router = useRouter()
const handleClick = ( const handleClick = (
@ -47,14 +37,7 @@ const DropdownMenu: React.FC = () => {
} }
return ( return (
<Dropdown> <div>
<DropdownTrigger asChild>
<button className="inline-flex justify-center rounded-full">
<Avatar />
</button>
</DropdownTrigger>
<DropdownContent sideOffset={8} asChild>
<>
{LINKS.map(({ name, href }) => ( {LINKS.map(({ name, href }) => (
<DropdownMenuItem key={href}> <DropdownMenuItem key={href}>
<a <a
@ -81,7 +64,7 @@ const DropdownMenu: React.FC = () => {
{theme == 'dark' ? ( {theme == 'dark' ? (
<Moon width={20} height={20} /> <Moon width={20} height={20} />
) : ( ) : (
<Sun width="20" height={20} /> <Sun width={20} height={20} />
)} )}
</div> </div>
</a> </a>
@ -94,10 +77,6 @@ const DropdownMenu: React.FC = () => {
Logout Logout
</a> </a>
</DropdownMenuItem> </DropdownMenuItem>
</> </div>
</DropdownContent>
</Dropdown>
) )
} }
export default DropdownMenu

View File

@ -3,5 +3,5 @@
} }
.item { .item {
@apply text-2xl font-bold; @apply text-xl font-bold py-2;
} }

View File

@ -1,31 +1,32 @@
import Link from 'next/link' import Link from 'next/link'
import s from './MenuSidebarView.module.css' import s from './MenuSidebarView.module.css'
import { FC } from 'react'
import { useUI } from '@components/ui/context' import { useUI } from '@components/ui/context'
import SidebarLayout from '@components/common/SidebarLayout' import SidebarLayout from '@components/common/SidebarLayout'
import { Link as LinkProps} from '.' import type { Link as LinkProps } from './index'
export default function MenuSidebarView({
interface MenuProps { links = [],
}: {
links?: LinkProps[] links?: LinkProps[]
} }) {
const MenuSidebarView: FC<MenuProps> = (props) => {
const { closeSidebar } = useUI() const { closeSidebar } = useUI()
const handleClose = () => closeSidebar()
return ( return (
<SidebarLayout handleClose={handleClose}> <SidebarLayout handleClose={() => closeSidebar()}>
<div className={s.root}> <div className={s.root}>
<nav> <nav>
<ul> <ul>
<li className={s.item}> <li className={s.item} onClick={() => closeSidebar()}>
<Link href="/search"> <Link href="/search">
<a>All</a> <a>All</a>
</Link> </Link>
</li> </li>
{props.links?.map((l: any) => ( {links.map((l: any) => (
<li key={l.href} className={s.item}> <li
key={l.href}
className={s.item}
onClick={() => closeSidebar()}
>
<Link href={l.href}> <Link href={l.href}>
<a>{l.label}</a> <a>{l.label}</a>
</Link> </Link>
@ -38,4 +39,4 @@ const MenuSidebarView: FC<MenuProps> = (props) => {
) )
} }
export default MenuSidebarView MenuSidebarView

View File

@ -1,5 +1,4 @@
export { default } from './MenuSidebarView' export { default } from './MenuSidebarView'
export interface Link { export interface Link {
href: string href: string
label: string label: string

View File

@ -37,7 +37,7 @@
} }
.mobileMenu { .mobileMenu {
@apply flex lg:hidden ml-6; @apply flex lg:hidden ml-6 text-white;
} }
.avatarButton:focus, .avatarButton:focus,

View File

@ -4,10 +4,17 @@ import s from './UserNav.module.css'
import useCart from '@framework/cart/use-cart' import useCart from '@framework/cart/use-cart'
import DropdownCustomerAuth from './DropdownCustomerAuth' import DropdownCustomerAuth from './DropdownCustomerAuth'
import Button from '@components/ui/Button' import Button from '@components/ui/Button'
import { Avatar } from '@components/common' import { Heart, Bag, Menu } from '@components/icons'
import { useUI } from '@components/ui/context'
import { Heart, Bag } from '@components/icons'
import useCustomer from '@framework/customer/use-customer' import useCustomer from '@framework/customer/use-customer'
import {
Dropdown,
DropdownContent,
DropdownTrigger,
DropdownMenuItem,
} from '@components/ui/Dropdown/Dropdown'
import { useUI } from '@components/ui/context'
import { Avatar } from '@components/common'
import type { LineItem } from '@commerce/types/cart' import type { LineItem } from '@commerce/types/cart'
@ -55,7 +62,21 @@ const UserNav: React.FC<{
{process.env.COMMERCE_CUSTOMERAUTH_ENABLED && ( {process.env.COMMERCE_CUSTOMERAUTH_ENABLED && (
<li className={s.item}> <li className={s.item}>
{isCustomerLoggedIn ? ( {isCustomerLoggedIn ? (
<div className={s.root}>
<Dropdown>
<DropdownTrigger asChild>
<button className="inline-flex justify-center rounded-full">
<Avatar />
</button>
</DropdownTrigger>
<DropdownContent
className={s.dropdownContent}
id="DropdownCustomerAuth"
>
<DropdownCustomerAuth /> <DropdownCustomerAuth />
</DropdownContent>
</Dropdown>
</div>
) : ( ) : (
<button <button
className={s.avatarButton} className={s.avatarButton}
@ -67,19 +88,19 @@ const UserNav: React.FC<{
)} )}
</li> </li>
)} )}
{/* <li className={s.mobileMenu}> <li className={s.mobileMenu}>
<Button <Button
className={s.item} className={s.item}
aria-label="Menu"
variant="naked" variant="naked"
onClick={() => { onClick={() => {
setSidebarView('MOBILEMENU_VIEW') setSidebarView('MOBILE_MENU_VIEW')
toggleSidebar() toggleSidebar()
}} }}
aria-label="Menu"
> >
<Menu /> <Menu />
</Button> </Button>
</li> */} </li>
</ul> </ul>
</nav> </nav>
) )

View File

@ -1,17 +1,18 @@
export { default as Bag } from './Bag' export { default as Bag } from './Bag'
export { default as Sun } from './Sun'
export { default as Moon } from './Moon'
export { default as Menu } from './Menu'
export { default as Info } from './Info'
export { default as Star } from './Star'
export { default as Plus } from './Plus'
export { default as Heart } from './Heart' export { default as Heart } from './Heart'
export { default as Trash } from './Trash' export { default as Trash } from './Trash'
export { default as Cross } from './Cross' export { default as Cross } from './Cross'
export { default as Plus } from './Plus'
export { default as Minus } from './Minus' export { default as Minus } from './Minus'
export { default as Check } from './Check' export { default as Check } from './Check'
export { default as Sun } from './Sun'
export { default as Moon } from './Moon'
export { default as Github } from './Github' export { default as Github } from './Github'
export { default as Info } from './Info'
export { default as Vercel } from './Vercel' export { default as Vercel } from './Vercel'
export { default as MapPin } from './MapPin' export { default as MapPin } from './MapPin'
export { default as Star } from './Star'
export { default as ArrowLeft } from './ArrowLeft' export { default as ArrowLeft } from './ArrowLeft'
export { default as ArrowRight } from './ArrowRight' export { default as ArrowRight } from './ArrowRight'
export { default as CreditCard } from './CreditCard' export { default as CreditCard } from './CreditCard'

View File

@ -1,7 +1,23 @@
.root { .root {
@apply w-56 bg-accent-0; @apply bg-accent-0;
animation: none; animation: none;
transition: none; transition: none;
min-width: 100%;
}
@media screen(md) {
.root {
@apply shadow-lg bg-accent-0;
box-shadow: hsl(206 22% 7% / 45%) 0px 10px 38px -10px,
hsl(206 22% 7% / 20%) 0px 10px 20px -15px;
min-width: 14rem;
will-change: transform, opacity;
animation-duration: 600ms;
animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
animation-fill-mode: forwards;
transform-origin: var(--radix-dropdown-menu-content-transform-origin);
animation-name: slideIn;
}
} }
@keyframes slideIn { @keyframes slideIn {
@ -14,17 +30,3 @@
transform: translateY(0px); transform: translateY(0px);
} }
} }
@media screen(md) {
.root {
@apply shadow-lg;
box-shadow: hsl(206 22% 7% / 45%) 0px 10px 38px -10px,
hsl(206 22% 7% / 20%) 0px 10px 20px -15px;
will-change: transform, opacity;
animation-duration: 600ms;
animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
animation-fill-mode: forwards;
transform-origin: var(--radix-dropdown-menu-content-transform-origin);
animation-name: slideIn;
}
}

View File

@ -4,19 +4,19 @@ import s from './Dropdown.module.css'
import * as DropdownMenu from '@radix-ui/react-dropdown-menu' import * as DropdownMenu from '@radix-ui/react-dropdown-menu'
export const Dropdown = DropdownMenu.Root export const Dropdown = DropdownMenu.Root
export const DropdownMenuItem = DropdownMenu.Item
export const DropdownTrigger = DropdownMenu.Trigger export const DropdownTrigger = DropdownMenu.Trigger
export const DropdownMenuLabel = DropdownMenu.Label export const DropdownMenuLabel = DropdownMenu.Label
export const DropdownMenuItem = DropdownMenu.Item
export const DropdownMenuGroup = DropdownMenu.Group export const DropdownMenuGroup = DropdownMenu.Group
export const DropdownContent = React.forwardRef< export const DropdownContent = React.forwardRef<
HTMLDivElement, HTMLDivElement,
{ children: React.ReactNode } & DropdownMenu.DropdownMenuContentProps & { children: React.ReactNode } & DropdownMenu.DropdownMenuContentProps &
React.RefAttributes<HTMLDivElement> React.RefAttributes<HTMLDivElement>
>(function DropdownContent({ children, ...props }, forwardedRef) { >(function DropdownContent({ children, className, ...props }, forwardedRef) {
return ( return (
<DropdownMenu.Content ref={forwardedRef} asChild {...props}> <DropdownMenu.Content ref={forwardedRef} sideOffset={8} {...props}>
<div className={s.root}>{children}</div> <div className={cn(s.root, className)}>{children}</div>
</DropdownMenu.Content> </DropdownMenu.Content>
) )
}) })

View File

@ -1,14 +1,13 @@
import { FC, useEffect, useRef } from 'react'
import s from './Sidebar.module.css'
import cn from 'clsx' import cn from 'clsx'
import s from './Sidebar.module.css'
import { useEffect, useRef } from 'react'
import { disableBodyScroll, clearAllBodyScrollLocks } from 'body-scroll-lock' import { disableBodyScroll, clearAllBodyScrollLocks } from 'body-scroll-lock'
interface SidebarProps { interface SidebarProps {
children: any children: any
onClose: () => void onClose: () => void
} }
const Sidebar: FC<SidebarProps> = ({ children, onClose }) => { const Sidebar: React.FC<SidebarProps> = ({ children, onClose }) => {
const sidebarRef = useRef() as React.MutableRefObject<HTMLDivElement> const sidebarRef = useRef() as React.MutableRefObject<HTMLDivElement>
const contentRef = useRef() as React.MutableRefObject<HTMLDivElement> const contentRef = useRef() as React.MutableRefObject<HTMLDivElement>

View File

@ -23,8 +23,8 @@
"@components/*": ["components/*"], "@components/*": ["components/*"],
"@commerce": ["../packages/commerce/src"], "@commerce": ["../packages/commerce/src"],
"@commerce/*": ["../packages/commerce/src/*"], "@commerce/*": ["../packages/commerce/src/*"],
"@framework": ["../packages/local/src"], "@framework": ["../packages/bigcommerce/src"],
"@framework/*": ["../packages/local/src/*"] "@framework/*": ["../packages/bigcommerce/src/*"]
} }
}, },
"include": ["next-env.d.ts", "**/*.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"], "include": ["next-env.d.ts", "**/*.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],