From 7996f4e5a2b6d38c282f66633b9fd86792d62216 Mon Sep 17 00:00:00 2001 From: Laurent Senta Date: Wed, 12 Jan 2022 13:45:41 +0100 Subject: [PATCH] feat: nicer smart filters & folders theme (#795) * fix: color add button and drop * fix: color scrollbars * fix: remove infinite scroll and fix scrollbars * fix: plus icon center * fix: navigation padding, structure simplif and naming * fix: simplify scrollbars * fix: scroll bar simplif + scheme in macos * fix: magic variables to const * refactor: extract panel ref state * refactor: remove dead code, simple macos theme --- app/assets/icons/ic-add.svg | 2 +- app/assets/javascripts/app.ts | 2 - .../javascripts/components/Navigation.tsx | 42 +++++++++------- .../components/Tags/RootTagDropZone.tsx | 2 +- .../components/Tags/SmartTagsListItem.tsx | 7 ++- .../components/Tags/TagsListItem.tsx | 7 ++- .../components/Tags/TagsSection.tsx | 2 +- .../components/Tags/TagsSectionAddButton.tsx | 2 +- .../directives/functional/index.ts | 1 - .../directives/functional/infiniteScroll.ts | 26 ---------- app/assets/stylesheets/_main.scss | 5 -- .../{_tags.scss => _navigation.scss} | 48 +++++++------------ app/assets/stylesheets/_notes.scss | 21 ++------ app/assets/stylesheets/_scrollbar.scss | 9 ++++ app/assets/stylesheets/index.css.scss | 2 +- 15 files changed, 70 insertions(+), 108 deletions(-) delete mode 100644 app/assets/javascripts/directives/functional/infiniteScroll.ts rename app/assets/stylesheets/{_tags.scss => _navigation.scss} (86%) create mode 100644 app/assets/stylesheets/_scrollbar.scss diff --git a/app/assets/icons/ic-add.svg b/app/assets/icons/ic-add.svg index d92c119a2..b785d2267 100644 --- a/app/assets/icons/ic-add.svg +++ b/app/assets/icons/ic-add.svg @@ -1,3 +1,3 @@ - + diff --git a/app/assets/javascripts/app.ts b/app/assets/javascripts/app.ts index d939bba17..49fcb298c 100644 --- a/app/assets/javascripts/app.ts +++ b/app/assets/javascripts/app.ts @@ -58,7 +58,6 @@ import { delayHide, elemReady, fileChange, - infiniteScroll, lowercase, selectOnFocus, snEnter, @@ -150,7 +149,6 @@ const startApplication: StartApplication = async function startApplication( .directive('delayHide', delayHide) .directive('elemReady', elemReady) .directive('fileChange', fileChange) - .directive('infiniteScroll', [infiniteScroll]) .directive('lowercase', lowercase) .directive('selectOnFocus', ['$window', selectOnFocus]) .directive('snEnter', snEnter); diff --git a/app/assets/javascripts/components/Navigation.tsx b/app/assets/javascripts/components/Navigation.tsx index b3e5dcfd4..b3576ac0f 100644 --- a/app/assets/javascripts/components/Navigation.tsx +++ b/app/assets/javascripts/components/Navigation.tsx @@ -12,27 +12,35 @@ import { PANEL_NAME_NAVIGATION } from '@/views/constants'; import { PrefKey } from '@standardnotes/snjs'; import { observer } from 'mobx-react-lite'; import { FunctionComponent } from 'preact'; -import { useCallback, useEffect, useMemo, useState } from 'preact/hooks'; +import { useCallback, useMemo, useState } from 'preact/hooks'; import { PremiumModalProvider } from './Premium'; type Props = { application: WebApplication; }; +const NAVIGATION_SELECTOR = 'navigation'; + +const useNavigationPanelRef = (): [HTMLDivElement | null, () => void] => { + const [panelRef, setPanelRefInternal] = useState(null); + + const setPanelRefPublic = useCallback(() => { + const elem = document.querySelector( + NAVIGATION_SELECTOR + ) as HTMLDivElement | null; + setPanelRefInternal(elem); + }, [setPanelRefInternal]); + + return [panelRef, setPanelRefPublic]; +}; + export const Navigation: FunctionComponent = observer( ({ application }) => { const appState = useMemo(() => application.getAppState(), [application]); const componentViewer = appState.foldersComponentViewer; const enableNativeSmartTagsFeature = appState.features.enableNativeSmartTagsFeature; - const [panelRef, setPanelRef] = useState(null); - - useEffect(() => { - const elem = document.querySelector( - 'navigation' - ) as HTMLDivElement | null; - setPanelRef(elem); - }, [setPanelRef]); + const [panelRef, setPanelRef] = useNavigationPanelRef(); const onCreateNewTag = useCallback(() => { appState.tags.createNewTemplate(); @@ -53,10 +61,10 @@ export const Navigation: FunctionComponent = observer( return (
{componentViewer ? (
@@ -69,8 +77,8 @@ export const Navigation: FunctionComponent = observer(
) : ( -
-
+