diff options
| author | Armand Philippot <git@armandphilippot.com> | 2022-04-29 12:13:34 +0200 | 
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2022-04-29 18:30:05 +0200 | 
| commit | 7e16f500cb7bc0cfd8bafbf6bb1555704f771231 (patch) | |
| tree | bfc2b4a475cb06a787e2c4bdf284165644e82952 /src/components/Toolbar | |
| parent | 5324664e87bedfaa01ba62c0c847ef5b861e69b3 (diff) | |
chore: remove old pages, components, helpers and types
Since I'm using new components, I will also rewrite the GraphQL queries
so it is easier to start from scratch.
Diffstat (limited to 'src/components/Toolbar')
| -rw-r--r-- | src/components/Toolbar/Toolbar.module.scss | 114 | ||||
| -rw-r--r-- | src/components/Toolbar/Toolbar.tsx | 162 | 
2 files changed, 0 insertions, 276 deletions
| diff --git a/src/components/Toolbar/Toolbar.module.scss b/src/components/Toolbar/Toolbar.module.scss deleted file mode 100644 index debb3b7..0000000 --- a/src/components/Toolbar/Toolbar.module.scss +++ /dev/null @@ -1,114 +0,0 @@ -@use "@styles/abstracts/functions" as fun; -@use "@styles/abstracts/mixins" as mix; - -.wrapper { -  --btn-size: #{fun.convert-px(60)}; - -  display: flex; -  flex-flow: row wrap; -  align-items: center; -  justify-content: space-around; -  width: 100%; -  height: var(--toolbar-size); -  position: fixed; -  bottom: 0; -  left: 0; -  z-index: 5; -  background: var(--color-bg); -  border-top: fun.convert-px(4) solid; -  border-image: radial-gradient( -      ellipse at top, -      var(--color-primary-lighter) 20%, -      var(--color-primary) 100% -    ) -    1; -  box-shadow: 0 fun.convert-px(-2) fun.convert-px(3) fun.convert-px(-1) -    var(--color-shadow-dark); - -  :global { -    animation: slide-in-from-bottom 0.8s ease-in-out 0s 1; -  } - -  @include mix.media("screen") { -    @include mix.dimensions("sm") { -      --toolbar-size: auto; - -      justify-content: flex-end; -      gap: var(--spacing-sm); -      width: auto; -      background: inherit; -      border: none; -      box-shadow: none; -      position: relative; -      left: unset; -      margin-right: unset; -      transform: unset; - -      :global { -        animation: slide-in-from-top 1s ease-in-out 0s 1; -      } -    } -  } -} - -.menu { -  padding: var(--spacing-md); -  position: absolute; -  bottom: 100%; -  left: 0; -  right: 0; -  background: var(--color-bg-secondary); -  border-top: fun.convert-px(4) solid; -  border-bottom: fun.convert-px(4) solid; -  border-image: radial-gradient( -      ellipse at top, -      var(--color-primary-lighter) 20%, -      var(--color-primary) 100% -    ) -    1; -  box-shadow: fun.convert-px(2) fun.convert-px(-2) fun.convert-px(3) -    fun.convert-px(-1) var(--color-shadow-dark); -  transition: all 0.7s ease-in-out 0s; - -  &--closed { -    transform: translateX(-100%); -    visibility: hidden; -  } - -  &--opened { -    transform: translateX(0); -    visibility: visible; -  } - -  @include mix.media("screen") { -    @include mix.dimensions("sm") { -      width: fun.convert-px(500); -      left: unset; -      right: unset; -      top: 120%; -      bottom: unset; -      border: fun.convert-px(4) solid; -      border-image: radial-gradient( -          ellipse at top, -          var(--color-primary-lighter) 20%, -          var(--color-primary) 100% -        ) -        1; -      box-shadow: fun.convert-px(2) fun.convert-px(2) fun.convert-px(3) -        fun.convert-px(1) var(--color-shadow-dark); -      transform-origin: 50% -200%; -      transition: all 0.8s ease-in-out 0s; - -      &--closed { -        opacity: 0; -        transform: perspective(20rem) translate3d(0, 100%, -20rem); -        visibility: hidden; -      } - -      &--opened { -        opacity: 1; -        transform: none; -      } -    } -  } -} diff --git a/src/components/Toolbar/Toolbar.tsx b/src/components/Toolbar/Toolbar.tsx deleted file mode 100644 index 17f9ef9..0000000 --- a/src/components/Toolbar/Toolbar.tsx +++ /dev/null @@ -1,162 +0,0 @@ -import { ButtonToolbar } from '@components/Buttons'; -import MainNav from '@components/MainNav/MainNav'; -import Spinner from '@components/Spinner/Spinner'; -import dynamic from 'next/dynamic'; -import { RefObject, useCallback, useEffect, useRef, useState } from 'react'; -import styles from './Toolbar.module.scss'; - -const DynamicSearchForm = dynamic( -  () => import('@components/SearchForm/SearchForm'), -  { -    loading: () => <Spinner />, -  } -); - -const DynamicSettings = dynamic(() => import('@components/Settings/Settings'), { -  loading: () => <Spinner />, -}); - -const Toolbar = () => { -  const [isNavOpened, setIsNavOpened] = useState<boolean>(false); -  const [isSearchOpened, setIsSearchOpened] = useState<boolean>(false); -  const [isSettingsOpened, setIsSettingsOpened] = useState<boolean>(false); -  const mainNavRef = useRef<HTMLDivElement>(null); -  const searchBtnRef = useRef<HTMLButtonElement>(null); -  const searchModalRef = useRef<HTMLDivElement>(null); -  const settingsBtnRef = useRef<HTMLButtonElement>(null); -  const settingsModalRef = useRef<HTMLDivElement>(null); - -  useEffect(() => { -    if (isNavOpened) { -      setIsSearchOpened(false); -      setIsSettingsOpened(false); -    } -  }, [isNavOpened]); - -  useEffect(() => { -    if (isSearchOpened) { -      setIsNavOpened(false); -      setIsSettingsOpened(false); -    } -  }, [isSearchOpened]); - -  useEffect(() => { -    if (isSettingsOpened) { -      setIsNavOpened(false); -      setIsSearchOpened(false); -    } -  }, [isSettingsOpened]); - -  const isClickOutside = ( -    ref: RefObject<HTMLDivElement>, -    target: EventTarget -  ) => { -    return ref.current && !ref.current.contains(target as Node); -  }; - -  const isToggleBtn = (ref: RefObject<HTMLDivElement>, target: EventTarget) => { -    return ( -      ref.current && -      ref.current.previousElementSibling && -      ref.current.previousElementSibling.contains(target as Node) -    ); -  }; - -  const isSearchBtn = useCallback((target: HTMLElement) => { -    return ( -      target === searchBtnRef.current || searchBtnRef.current?.contains(target) -    ); -  }, []); - -  const isSettingsBtn = useCallback((target: HTMLElement) => { -    return ( -      target === settingsBtnRef.current || -      settingsBtnRef.current?.contains(target) -    ); -  }, []); - -  const handleVisibility = useCallback( -    (e: MouseEvent | FocusEvent) => { -      let ref: RefObject<HTMLDivElement> | null = null; -      if (isNavOpened) ref = mainNavRef; -      if (isSearchOpened) ref = searchModalRef; -      if (isSettingsOpened) ref = settingsModalRef; - -      if (!ref || !ref.current || !ref.current.id) return; -      if (!isClickOutside(ref, e.target as Node)) return; -      if (isToggleBtn(ref, e.target as Node)) return; - -      if ( -        ref.current.id === 'main-nav' && -        !isSettingsBtn(e.target as HTMLElement) && -        !isSearchBtn(e.target as HTMLElement) -      ) { -        setIsNavOpened(false); -      } - -      if ( -        ref.current.id === 'search-modal' && -        !isSettingsBtn(e.target as HTMLElement) -      ) -        setIsSearchOpened(false); -      if ( -        ref.current.id === 'settings-modal' && -        !isSearchBtn(e.target as HTMLElement) -      ) -        setIsSettingsOpened(false); -    }, -    [isNavOpened, isSearchOpened, isSettingsOpened, isSearchBtn, isSettingsBtn] -  ); - -  useEffect(() => { -    document.addEventListener('mousedown', handleVisibility); -    document.addEventListener('focusin', handleVisibility); - -    return () => { -      document.removeEventListener('mousedown', handleVisibility); -      document.removeEventListener('focusin', handleVisibility); -    }; -  }, [handleVisibility]); - -  const searchClasses = `${styles.menu} ${ -    isSearchOpened ? styles['menu--opened'] : styles['menu--closed'] -  }`; - -  const settingsClasses = `${styles.menu} ${ -    isSettingsOpened ? styles['menu--opened'] : styles['menu--closed'] -  }`; - -  return ( -    <div className={styles.wrapper}> -      <MainNav -        ref={mainNavRef} -        isOpened={isNavOpened} -        setIsOpened={setIsNavOpened} -      /> -      <ButtonToolbar -        ref={searchBtnRef} -        type="search" -        isActivated={isSearchOpened} -        setIsActivated={setIsSearchOpened} -      /> -      <div id="search-modal" className={searchClasses} ref={searchModalRef}> -        <DynamicSearchForm isOpened={isSearchOpened} /> -      </div> -      <ButtonToolbar -        ref={settingsBtnRef} -        type="settings" -        isActivated={isSettingsOpened} -        setIsActivated={setIsSettingsOpened} -      /> -      <div -        id="settings-modal" -        className={settingsClasses} -        ref={settingsModalRef} -      > -        <DynamicSettings /> -      </div> -    </div> -  ); -}; - -export default Toolbar; | 
