From b67b87c4fe7d3a2e5e34d5c2e150d65ee24fa461 Mon Sep 17 00:00:00 2001 From: Bel Curcio Date: Tue, 8 Dec 2020 11:10:34 -0300 Subject: [PATCH 1/3] Fixing clickOutside --- components/common/UserNav/DropdownMenu.tsx | 12 +++++++++--- lib/click-outside/click-outside.tsx | 17 +++++------------ public/vercel.svg | 14 +++++++------- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/components/common/UserNav/DropdownMenu.tsx b/components/common/UserNav/DropdownMenu.tsx index fb3ddc7de..0c47158db 100644 --- a/components/common/UserNav/DropdownMenu.tsx +++ b/components/common/UserNav/DropdownMenu.tsx @@ -8,6 +8,7 @@ import { Avatar } from '@components/common' import { Moon, Sun } from '@components/icons' import { useUI } from '@components/ui/context' import ClickOutside from '@lib/click-outside' + import { disableBodyScroll, enableBodyScroll, @@ -15,6 +16,7 @@ import { } from 'body-scroll-lock' import useLogout from '@bigcommerce/storefront-data-hooks/use-logout' + interface DropdownMenuProps { open?: boolean } @@ -75,7 +77,10 @@ const DropdownMenu: FC = ({ open = false }) => { className={cn(s.link, { [s.active]: pathname === href, })} - onClick={closeSidebarIfPresent} + onClick={() => { + setDisplay(false) + closeSidebarIfPresent() + }} > {name} @@ -86,9 +91,10 @@ const DropdownMenu: FC = ({ open = false }) => {
  • + onClick={() => { theme === 'dark' ? setTheme('light') : setTheme('dark') - } + setDisplay(false) + }} >
    Theme: {theme}{' '} diff --git a/lib/click-outside/click-outside.tsx b/lib/click-outside/click-outside.tsx index d3bba953c..268fc13d9 100644 --- a/lib/click-outside/click-outside.tsx +++ b/lib/click-outside/click-outside.tsx @@ -1,4 +1,4 @@ -import React, { forwardRef, useEffect, Ref, MouseEvent } from 'react' +import React, { useRef, useEffect, MouseEvent } from 'react' import hasParent from './has-parent' interface ClickOutsideProps { @@ -7,18 +7,12 @@ interface ClickOutsideProps { children: any } -const ClickOutside = forwardRef( - ( - { active = true, onClick, children }: ClickOutsideProps, - ref: Ref | null | any = {} - ) => { - const innerRef = ref?.current +const ClickOutside = ({ active = true, onClick, children }: ClickOutsideProps) => { + const innerRef = useRef() const handleClick = (event: any) => { - if (!hasParent(event.target, innerRef)) { + if (!hasParent(event.target, innerRef?.current)) { if (typeof onClick === 'function') { - event.preventDefault() - event.stopImmediatePropagation() onClick(event) } } @@ -38,8 +32,7 @@ const ClickOutside = forwardRef( } }) - return React.cloneElement(children, { ref }) + return React.cloneElement(children, { ref: innerRef }) } -) export default ClickOutside diff --git a/public/vercel.svg b/public/vercel.svg index 5f387a32d..c0a8ee464 100644 --- a/public/vercel.svg +++ b/public/vercel.svg @@ -1,9 +1,9 @@ - - - - - - - + + + + + + + From 70030882d4429ab390aea7f42393b18445e8f4f2 Mon Sep 17 00:00:00 2001 From: Bel Curcio Date: Tue, 8 Dec 2020 11:14:48 -0300 Subject: [PATCH 2/3] Logo Changes --- components/common/Footer/Footer.tsx | 12 ++++-------- components/icons/Vercel.tsx | 16 ++++++++++++++++ components/icons/index.ts | 1 + 3 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 components/icons/Vercel.tsx diff --git a/components/common/Footer/Footer.tsx b/components/common/Footer/Footer.tsx index 55ed5289d..c32b1268f 100644 --- a/components/common/Footer/Footer.tsx +++ b/components/common/Footer/Footer.tsx @@ -4,7 +4,7 @@ import Link from 'next/link' import { useRouter } from 'next/router' import type { Page } from '@bigcommerce/storefront-data-hooks/api/operations/get-all-pages' import getSlug from '@lib/get-slug' -import { Github } from '@components/icons' +import { Github, Vercel } from '@components/icons' import { Logo, Container } from '@components/ui' import { I18nWidget } from '@components/common' import s from './Footer.module.css' @@ -99,14 +99,10 @@ const Footer: FC = ({ className, pages }) => {
    © 2020 ACME, Inc. All rights reserved.
    -
    diff --git a/components/icons/Vercel.tsx b/components/icons/Vercel.tsx new file mode 100644 index 000000000..8e8f6457d --- /dev/null +++ b/components/icons/Vercel.tsx @@ -0,0 +1,16 @@ +const Vercel = ({ ...props }) => { + return ( + + + + + + + + + + + ) +} + +export default Vercel diff --git a/components/icons/index.ts b/components/icons/index.ts index e72660e83..6e57ab0e8 100644 --- a/components/icons/index.ts +++ b/components/icons/index.ts @@ -13,3 +13,4 @@ export { default as DoubleChevron } from './DoubleChevron' export { default as RightArrow } from './RightArrow' export { default as Info } from './Info' export { default as ChevronUp } from './ChevronUp' +export { default as Vercel } from './Vercel' From 5699e2b166ca08b0c2603b31fe13e320d2fb5ce5 Mon Sep 17 00:00:00 2001 From: Bel Curcio Date: Tue, 8 Dec 2020 11:16:44 -0300 Subject: [PATCH 3/3] Logo Changes --- components/common/I18nWidget/I18nWidget.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/components/common/I18nWidget/I18nWidget.tsx b/components/common/I18nWidget/I18nWidget.tsx index 92b40322d..995e1faee 100644 --- a/components/common/I18nWidget/I18nWidget.tsx +++ b/components/common/I18nWidget/I18nWidget.tsx @@ -1,6 +1,6 @@ import cn from 'classnames' import Link from 'next/link' -import { useRef, FC, useState } from 'react' +import { FC, useState } from 'react' import { useRouter } from 'next/router' import s from './I18nWidget.module.css' import { Cross, ChevronUp } from '@components/icons' @@ -41,10 +41,9 @@ const I18nWidget: FC = () => { const options = locales?.filter((val) => val !== locale) const currentLocale = locale || defaultLocale - const ref = useRef(null) return ( - setDisplay(false)} ref={ref}> + setDisplay(false)} >