diff --git a/packages/web/components/elements/icons/ToggleCaretDownIcon.tsx b/packages/web/components/elements/icons/ToggleCaretDownIcon.tsx new file mode 100644 index 000000000..946ea3a86 --- /dev/null +++ b/packages/web/components/elements/icons/ToggleCaretDownIcon.tsx @@ -0,0 +1,32 @@ +/* eslint-disable functional/no-class */ +/* eslint-disable functional/no-this-expression */ +import { IconProps } from './IconProps' + +import React from 'react' + +export class ToggleCaretDownIcon extends React.Component { + render() { + const size = (this.props.size || 26).toString() + const color = (this.props.color || '#2A2A2A').toString() + + return ( + + + + + + ) + } +} diff --git a/packages/web/components/elements/icons/ToggleCaretLeftIcon.tsx b/packages/web/components/elements/icons/ToggleCaretLeftIcon.tsx new file mode 100644 index 000000000..85796ecab --- /dev/null +++ b/packages/web/components/elements/icons/ToggleCaretLeftIcon.tsx @@ -0,0 +1,32 @@ +/* eslint-disable functional/no-class */ +/* eslint-disable functional/no-this-expression */ +import { IconProps } from './IconProps' + +import React from 'react' + +export class ToggleCaretLeftIcon extends React.Component { + render() { + const size = (this.props.size || 26).toString() + const color = (this.props.color || '#2A2A2A').toString() + + return ( + + + + + + ) + } +} diff --git a/packages/web/components/templates/homeFeed/LibraryFilterMenu.tsx b/packages/web/components/templates/homeFeed/LibraryFilterMenu.tsx index 79fb71724..986ba3736 100644 --- a/packages/web/components/templates/homeFeed/LibraryFilterMenu.tsx +++ b/packages/web/components/templates/homeFeed/LibraryFilterMenu.tsx @@ -1,9 +1,8 @@ -import { ReactNode, useMemo, useState } from 'react' +import { ReactNode, useMemo } from 'react' import { StyledText } from '../../elements/StyledText' import { Box, HStack, SpanBox, VStack } from '../../elements/LayoutPrimitives' -import { Dropdown, DropdownOption } from '../../elements/DropdownElements' import { Button } from '../../elements/Button' -import { CaretRight, Circle, DotsThree, Plus } from 'phosphor-react' +import { CaretRight, Circle } from 'phosphor-react' import { useGetSubscriptionsQuery } from '../../../lib/networking/queries/useGetSubscriptionsQuery' import { useGetLabelsQuery } from '../../../lib/networking/queries/useGetLabelsQuery' import { Label } from '../../../lib/networking/fragments/labelFragment' @@ -11,6 +10,10 @@ import { theme } from '../../tokens/stitches.config' import { useRegisterActions } from 'kbar' import { LogoBox } from '../../elements/LogoBox' import { usePersistedState } from '../../../lib/hooks/usePersistedState' +import { ToggleCaretDownIcon } from '../../elements/icons/ToggleCaretDownIcon' +import { ToggleCaretLeftIcon } from '../../elements/icons/ToggleCaretLeftIcon' +import Link from 'next/link' +import { ArrowRightIcon } from '../../elements/icons/ArrowRightIcon' export const LIBRARY_LEFT_MENU_WIDTH = '233px' @@ -130,16 +133,26 @@ function SavedSearches(props: LibraryFilterMenuProps): JSX.Element { [] ) + const [collapsed, setCollapsed] = usePersistedState({ + key: `--saved-searches-collapsed`, + initialValue: false, + }) + return ( - - {items.map((item) => ( - - ))} + + {!collapsed && + items.map((item) => ( + + ))} @@ -148,8 +161,8 @@ function SavedSearches(props: LibraryFilterMenuProps): JSX.Element { function Subscriptions(props: LibraryFilterMenuProps): JSX.Element { const { subscriptions } = useGetSubscriptionsQuery() - const [viewAll, setViewAll] = usePersistedState({ - key: `--subscriptions-view-all`, + const [collapsed, setCollapsed] = usePersistedState({ + key: `--subscriptions-collapsed`, initialValue: false, }) @@ -173,15 +186,10 @@ function Subscriptions(props: LibraryFilterMenuProps): JSX.Element { return ( { - window.location.href = '/settings/subscriptions' - }} - viewAll={() => { - setViewAll(true) - }} + collapsed={collapsed} + setCollapsed={setCollapsed} > - {viewAll ? ( + {!collapsed ? ( <> ) })} - + ) : ( @@ -210,8 +221,8 @@ function Subscriptions(props: LibraryFilterMenuProps): JSX.Element { function Labels(props: LibraryFilterMenuProps): JSX.Element { const { labels } = useGetLabelsQuery() - const [viewAll, setViewAll] = usePersistedState({ - key: `--labels-view-all`, + const [collapsed, setCollapsed] = usePersistedState({ + key: `--labels-collapsed`, initialValue: false, }) @@ -224,16 +235,18 @@ function Labels(props: LibraryFilterMenuProps): JSX.Element { return ( { - window.location.href = '/settings/labels' - }} + collapsed={collapsed} + setCollapsed={setCollapsed} > - {sortedLabels.slice(0, viewAll ? undefined : 4).map((item) => { - return - })} - + {!collapsed && ( + <> + {sortedLabels.map((item) => { + return + })} + + + )} ) } @@ -241,10 +254,11 @@ function Labels(props: LibraryFilterMenuProps): JSX.Element { type MenuPanelProps = { title: string children: ReactNode - editFunc?: () => void - editTitle?: string + hideBottomBorder?: boolean - viewAll?: () => void + + collapsed: boolean + setCollapsed: (collapsed: boolean) => void } function MenuPanel(props: MenuPanelProps): JSX.Element { @@ -278,57 +292,32 @@ function MenuPanel(props: MenuPanelProps): JSX.Element { - {props.editTitle && props.editFunc && ( - - - - } - > - {props.viewAll && ( - { - if (props.viewAll) { - props.viewAll() - } - }} - /> - )} - { - if (props.editFunc) { - props.editFunc() - } - }} + {props.children} @@ -492,34 +481,43 @@ function LabelButton(props: LabelButtonProps): JSX.Element { ) } -type ViewAllButtonProps = { - state: boolean - setState: (state: boolean) => void +type EditButtonProps = { + title: string + destination: string } -function ViewAllButton(props: ViewAllButtonProps): JSX.Element { +function EditButton(props: EditButtonProps): JSX.Element { return ( - + + + {props.title} + + ) }