From 29a4e7311e3eeecfedf73120718e44c08e59f842 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Thu, 8 Feb 2024 19:03:22 +0800 Subject: [PATCH] Move pinned searches to under the bar --- packages/web/components/elements/Button.tsx | 8 +- .../LibraryCards/LibraryCardStyles.tsx | 2 +- .../components/templates/PrimaryDropdown.tsx | 2 +- .../templates/homeFeed/EmptyHighlights.tsx | 5 +- .../templates/homeFeed/HeaderSpacer.tsx | 38 +++---- .../templates/homeFeed/HighlightsLayout.tsx | 6 +- .../templates/homeFeed/HomeFeedContainer.tsx | 40 +++++++- .../templates/homeFeed/LibraryFilterMenu.tsx | 4 +- .../templates/homeFeed/LibraryHeader.tsx | 19 ++-- .../templates/homeFeed/PinnedButtons.tsx | 98 +++++++++++++------ .../templates/reader/ReaderHeader.tsx | 8 +- .../web/components/tokens/stitches.config.ts | 11 ++- 12 files changed, 156 insertions(+), 85 deletions(-) diff --git a/packages/web/components/elements/Button.tsx b/packages/web/components/elements/Button.tsx index df08e5fbb..6fa11b71d 100644 --- a/packages/web/components/elements/Button.tsx +++ b/packages/web/components/elements/Button.tsx @@ -195,11 +195,11 @@ export const Button = styled('button', { py: '5px', font: '$inter', fontSize: '12px', - fontWeight: '700', + fontWeight: '500', whiteSpace: 'nowrap', color: '$thLibraryMenuPrimary', border: '1px solid $thLeftMenuBackground', - backgroundColor: '$thLeftMenuBackground', + bg: '$thBackgroundActive', '&:hover': { bg: '$thBackgroundActive', border: '1px solid $thBackgroundActive', @@ -210,12 +210,12 @@ export const Button = styled('button', { borderRadius: '15px', px: '12px', py: '5px', + bg: 'transparent', font: '$inter', fontSize: '12px', - fontWeight: 'medium', + fontWeight: '500', whiteSpace: 'nowrap', border: '1px solid $thBackground4', - backgroundColor: '$thBackground4', '&:hover': { bg: '$thBackgroundActive', border: '1px solid $thBackgroundActive', diff --git a/packages/web/components/patterns/LibraryCards/LibraryCardStyles.tsx b/packages/web/components/patterns/LibraryCards/LibraryCardStyles.tsx index e0b6a545f..66a2fa81c 100644 --- a/packages/web/components/patterns/LibraryCards/LibraryCardStyles.tsx +++ b/packages/web/components/patterns/LibraryCards/LibraryCardStyles.tsx @@ -45,7 +45,7 @@ export const TitleStyle = { fontSize: '16px', fontWeight: '700', maxLines: 2, - lineHeight: 1.25, + lineHeight: 1.5, fontFamily: '$display', overflow: 'hidden', textOverflow: 'ellipsis', diff --git a/packages/web/components/templates/PrimaryDropdown.tsx b/packages/web/components/templates/PrimaryDropdown.tsx index 906c44c59..3cbbe1c99 100644 --- a/packages/web/components/templates/PrimaryDropdown.tsx +++ b/packages/web/components/templates/PrimaryDropdown.tsx @@ -56,7 +56,7 @@ const TriggerButton = (props: TriggerButtonProps): JSX.Element => { height: '32px', padding: '5px', '&:hover': { - bg: '#6A6968', + bg: '$thLibraryMenuFooterHover', opacity: '0.7px', }, }} diff --git a/packages/web/components/templates/homeFeed/EmptyHighlights.tsx b/packages/web/components/templates/homeFeed/EmptyHighlights.tsx index 1972ee1be..ef822a3a4 100644 --- a/packages/web/components/templates/homeFeed/EmptyHighlights.tsx +++ b/packages/web/components/templates/homeFeed/EmptyHighlights.tsx @@ -2,10 +2,9 @@ import { Book } from 'phosphor-react' import { VStack } from '../../elements/LayoutPrimitives' import { StyledText } from '../../elements/StyledText' import { theme } from '../../tokens/stitches.config' -import { useGetHeaderHeight } from './HeaderSpacer' +import { DEFAULT_HEADER_HEIGHT } from './HeaderSpacer' export function EmptyHighlights(): JSX.Element { - const headerHeight = useGetHeaderHeight() return ( diff --git a/packages/web/components/templates/homeFeed/HeaderSpacer.tsx b/packages/web/components/templates/homeFeed/HeaderSpacer.tsx index 48342e68b..30f64f3bd 100644 --- a/packages/web/components/templates/homeFeed/HeaderSpacer.tsx +++ b/packages/web/components/templates/homeFeed/HeaderSpacer.tsx @@ -2,32 +2,32 @@ import { usePersistedState } from '../../../lib/hooks/usePersistedState' import { PinnedSearch } from '../../../pages/settings/pinned-searches' import { Box } from '../../elements/LayoutPrimitives' -export const DEFAULT_HEADER_HEIGHT = '98px' +export const DEFAULT_HEADER_HEIGHT = '85px' -export const useGetHeaderHeight = () => { - const [hidePinnedSearches] = usePersistedState({ - key: '--library-hide-pinned-searches', - initialValue: false, - isSessionStorage: false, - }) - const [pinnedSearches] = usePersistedState({ - key: `--library-pinned-searches`, - initialValue: [], - isSessionStorage: false, - }) +// export const useGetHeaderHeight = () => { +// const [hidePinnedSearches] = usePersistedState({ +// key: '--library-hide-pinned-searches', +// initialValue: false, +// isSessionStorage: false, +// }) +// const [pinnedSearches] = usePersistedState({ +// key: `--library-pinned-searches`, +// initialValue: [], +// isSessionStorage: false, +// }) - if (hidePinnedSearches || !pinnedSearches?.length) { - return '98px' - } - return '100px' -} +// if (hidePinnedSearches || !pinnedSearches?.length) { +// return '90px' +// } +// return '90px' +// } export function HeaderSpacer(): JSX.Element { - const headerHeight = useGetHeaderHeight() + // const headerHeight = useGetHeaderHeight() return ( ( undefined ) @@ -106,7 +106,7 @@ export function HighlightItemsLayout( ({ + key: `--library-pinned-searches`, + initialValue: [], + isSessionStorage: false, + }) + return ( <> + + + + {props.isValidating && props.items.length == 0 && }
{ diff --git a/packages/web/components/templates/homeFeed/LibraryFilterMenu.tsx b/packages/web/components/templates/homeFeed/LibraryFilterMenu.tsx index 74cc9b3dc..958b30b73 100644 --- a/packages/web/components/templates/homeFeed/LibraryFilterMenu.tsx +++ b/packages/web/components/templates/homeFeed/LibraryFilterMenu.tsx @@ -620,8 +620,6 @@ const Footer = (props: LibraryFilterMenuProps): JSX.Element => { position: 'fixed', bottom: '0%', alignItems: 'center', - paddingX: '5px', - paddingY: '5px', backgroundColor: '$thBackground2', width: LIBRARY_LEFT_MENU_WIDTH, @@ -639,7 +637,7 @@ const Footer = (props: LibraryFilterMenuProps): JSX.Element => { void } -const controlWidths = ( +export const headerControlWidths = ( layout: LayoutType, multiSelectMode: MultiSelectMode ) => { @@ -87,8 +82,14 @@ export function LibraryHeader(props: LibraryHeaderProps): JSX.Element { const [small, setSmall] = useState(false) useEffect(() => { + const handleScroll = () => { + setSmall(window.scrollY > 40) + } if (typeof window !== 'undefined') { - window.addEventListener('scroll', () => setSmall(window.scrollY > 40)) + window.addEventListener('scroll', handleScroll) + } + return () => { + window.removeEventListener('scroll', handleScroll) } }, []) @@ -144,7 +145,7 @@ function LargeHeaderLayout(props: LibraryHeaderProps): JSX.Element { css={{ gap: '10px', height: '100%', - ...controlWidths(props.layout, props.multiSelectMode), + ...headerControlWidths(props.layout, props.multiSelectMode), }} > {props.multiSelectMode !== 'off' ? ( diff --git a/packages/web/components/templates/homeFeed/PinnedButtons.tsx b/packages/web/components/templates/homeFeed/PinnedButtons.tsx index 5b62ad40c..b68a3ec38 100644 --- a/packages/web/components/templates/homeFeed/PinnedButtons.tsx +++ b/packages/web/components/templates/homeFeed/PinnedButtons.tsx @@ -8,11 +8,16 @@ import { MoreOptionsIcon } from '../../elements/images/MoreOptionsIcon' import { PinnedSearch } from '../../../pages/settings/pinned-searches' import { useRouter } from 'next/router' import { usePersistedState } from '../../../lib/hooks/usePersistedState' +import { LayoutType } from './HomeFeedContainer' +import { MultiSelectMode } from './LibraryHeader' type PinnedButtonsProps = { items: PinnedSearch[] searchTerm: string | undefined applySearchQuery: (searchQuery: string) => void + + multiSelectMode: MultiSelectMode + layout: LayoutType } export const PinnedButtons = (props: PinnedButtonsProps): JSX.Element => { @@ -22,53 +27,82 @@ export const PinnedButtons = (props: PinnedButtonsProps): JSX.Element => { initialValue: false, isSessionStorage: false, }) + const [opacity, setOpacity] = useState(1.0) + + useEffect(() => { + const handleScroll = () => { + const scrollTop = window.scrollY + const opacityValue = 1 - scrollTop / 15 + setOpacity(opacityValue >= 0 ? opacityValue : 0) + } + + window.addEventListener('scroll', handleScroll) + + return () => { + window.removeEventListener('scroll', handleScroll) + } + }, []) if (hidePinnedSearches || !props.items.length) { return <> } return ( - - {props.items.map((item) => { - const style = - item.search == props.searchTerm ? 'ctaPill' : 'ctaPillUnselected' - return ( - - ) - })} + + + {props.items.map((item) => { + const style = + item.search == props.searchTerm ? 'ctaPill' : 'ctaPillUnselected' + return ( + + ) + })} + +