From 5eff1c05bf06e508c1d515f6270f560b66069733 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Fri, 8 Apr 2022 10:27:45 +0800 Subject: [PATCH] add savedAt and publishedAt date range in search query --- .../templates/homeFeed/LibrarySearchBar.tsx | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/packages/web/components/templates/homeFeed/LibrarySearchBar.tsx b/packages/web/components/templates/homeFeed/LibrarySearchBar.tsx index 6e4f84e3b..5d16ec5de 100644 --- a/packages/web/components/templates/homeFeed/LibrarySearchBar.tsx +++ b/packages/web/components/templates/homeFeed/LibrarySearchBar.tsx @@ -1,22 +1,30 @@ -import { ReactNode, useEffect } from 'react' -import { useState, useRef } from 'react' +import { ReactNode, useEffect, useRef, useState } from 'react' import { StyledText } from '../../elements/StyledText' import { Box, HStack, VStack } from '../../elements/LayoutPrimitives' import { SearchIcon } from '../../elements/images/SearchIcon' import { theme } from '../../tokens/stitches.config' -import { DropdownOption, Dropdown } from '../../elements/DropdownElements' +import { Dropdown, DropdownOption } from '../../elements/DropdownElements' import { FormInput } from '../../elements/FormElements' import { searchBarCommands } from '../../../lib/keyboardShortcuts/navigationShortcuts' import { useKeyboardShortcuts } from '../../../lib/keyboardShortcuts/useKeyboardShortcuts' import { Button } from '../../elements/Button' import { X } from 'phosphor-react' +import { DateTime } from 'luxon' type LibrarySearchBarProps = { searchTerm?: string applySearchQuery: (searchQuery: string) => void } -type LibraryFilter = 'in:inbox' | 'in:all' | 'in:archive' | 'type:file' +type LibraryFilter = + | 'in:inbox' + | 'in:all' + | 'in:archive' + | 'type:file' + | 'type:highlights' + | `saved:${string}` + +const recentlySavedStartDate = DateTime.now().minus({ days: 7 }).toISODate() const FOCUSED_BOXSHADOW = '0px 0px 2px 2px rgba(255, 234, 159, 0.56)' @@ -153,6 +161,16 @@ export function DropdownFilterMenu( title="Files" hideSeparator /> + props.onFilterChange('type:highlights')} + title="Highlights" + hideSeparator + /> + props.onFilterChange(`saved:${recentlySavedStartDate}`)} + title="Recently Saved" + hideSeparator + /> ) }