From 5899450c9d154457f2e3a57f3515df64bba3c4fe Mon Sep 17 00:00:00 2001 From: JimmFly Date: Fri, 9 Dec 2022 19:44:30 +0800 Subject: [PATCH] feat: update quick search ui --- .../components/quick-search/content/index.tsx | 13 ++-- .../quick-search/content/jumpTo.tsx | 26 ++++---- .../quick-search/content/searchResult.tsx | 7 -- .../content/searchResult/NotFound.tsx | 9 +++ .../content/searchResult/index.tsx | 21 ++++++ .../app/src/components/quick-search/index.tsx | 36 +++++----- .../app/src/components/quick-search/input.tsx | 21 +++--- .../app/src/components/quick-search/style.ts | 65 ++++++++++++++----- 8 files changed, 128 insertions(+), 70 deletions(-) delete mode 100644 packages/app/src/components/quick-search/content/searchResult.tsx create mode 100644 packages/app/src/components/quick-search/content/searchResult/NotFound.tsx create mode 100644 packages/app/src/components/quick-search/content/searchResult/index.tsx diff --git a/packages/app/src/components/quick-search/content/index.tsx b/packages/app/src/components/quick-search/content/index.tsx index 1767234cef..610056f3f3 100644 --- a/packages/app/src/components/quick-search/content/index.tsx +++ b/packages/app/src/components/quick-search/content/index.tsx @@ -1,14 +1,11 @@ import React from 'react'; -import { useEditor } from '@/providers/editor-provider'; -import JumpTo from './jumpTo'; - -const Result = () => { - const { editor, mode, setMode } = useEditor(); +import JumpTo from './JumpTo'; +import { Command } from 'cmdk'; +import SearchResult from './searchResult'; +const Result = (props: { search: string }) => { return ( -
- -
+ {props.search ? : } ); }; diff --git a/packages/app/src/components/quick-search/content/jumpTo.tsx b/packages/app/src/components/quick-search/content/jumpTo.tsx index 2d0617cc26..8b11f685a0 100644 --- a/packages/app/src/components/quick-search/content/jumpTo.tsx +++ b/packages/app/src/components/quick-search/content/jumpTo.tsx @@ -4,23 +4,25 @@ import { MiddleTrashIcon, MiddleAllPagesIcon, } from '@blocksuite/icons'; +import Link from 'next/link'; +import { StyledJumpTo } from '../style'; const JumpTo = () => { return ( -
-
Jump to
-
- + + Jump to + + All pages -
-
- + + + Favourites -
-
- + + + Trash -
-
+ + ); }; diff --git a/packages/app/src/components/quick-search/content/searchResult.tsx b/packages/app/src/components/quick-search/content/searchResult.tsx deleted file mode 100644 index bd65f324c7..0000000000 --- a/packages/app/src/components/quick-search/content/searchResult.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import React from 'react'; - -const SearchResult = () => { - return
searchResult
; -}; - -export default SearchResult; diff --git a/packages/app/src/components/quick-search/content/searchResult/NotFound.tsx b/packages/app/src/components/quick-search/content/searchResult/NotFound.tsx new file mode 100644 index 0000000000..98554a3ead --- /dev/null +++ b/packages/app/src/components/quick-search/content/searchResult/NotFound.tsx @@ -0,0 +1,9 @@ +import React from 'react'; +import { Command, useCommandState } from 'cmdk'; + +const noResult = () => { + const search = useCommandState(state => state.search); + return No results found for "{search}".; +}; + +export default noResult; diff --git a/packages/app/src/components/quick-search/content/searchResult/index.tsx b/packages/app/src/components/quick-search/content/searchResult/index.tsx new file mode 100644 index 0000000000..2848bb2142 --- /dev/null +++ b/packages/app/src/components/quick-search/content/searchResult/index.tsx @@ -0,0 +1,21 @@ +import React from 'react'; +import NoResult from './NotFound'; +import { Command } from 'cmdk'; +import Store from '@blocksuite/store'; + +const SearchResult = () => { + return ( + <> + + + a + b + + c + + Apple + + ); +}; + +export default SearchResult; diff --git a/packages/app/src/components/quick-search/index.tsx b/packages/app/src/components/quick-search/index.tsx index 834aa00ca5..455ff88020 100644 --- a/packages/app/src/components/quick-search/index.tsx +++ b/packages/app/src/components/quick-search/index.tsx @@ -1,16 +1,16 @@ import { Modal, ModalWrapper } from '@/ui/modal'; - import { - StyledModalWrapper, StyledContent, StyledModalHeader, StyledModalFooter, StyledModalDivider, StyledShortcut, } from './style'; -import Input from './input'; +import Input from './Input'; import Result from './content'; -import QuickSearchFooter from './footer'; +import QuickSearchFooter from './Footer'; +import { Command } from 'cmdk'; +import { useState } from 'react'; type TransitionsModalProps = { open: boolean; onClose: () => void; @@ -19,8 +19,9 @@ const isMac = () => { return /macintosh|mac os x/i.test(navigator.userAgent); }; export const QuickSearch = ({ open, onClose }: TransitionsModalProps) => { + const [search, setSearch] = useState(''); return ( - + { maxHeight: '720px', minHeight: '350px', borderRadius: '20px', + top: '138px', }} > - - - {isMac() ? '⌘+K' : 'Ctrl+K'} - - - - - + + + + {isMac() ? '⌘+K' : 'Ctrl+K'} + + + + + - - - + + + + ); diff --git a/packages/app/src/components/quick-search/input.tsx b/packages/app/src/components/quick-search/input.tsx index bede221bbe..cba2814260 100644 --- a/packages/app/src/components/quick-search/input.tsx +++ b/packages/app/src/components/quick-search/input.tsx @@ -1,17 +1,20 @@ -import React from 'react'; +import React, { Dispatch, SetStateAction } from 'react'; import { MiddleSearchIcon } from '@blocksuite/icons'; -import { StyledInput, StyledInputContent, StyledLabel } from './style'; - -const Input = () => { +import { StyledInputContent, StyledLabel } from './style'; +import { Command } from 'cmdk'; +const Input = (props: { + search: string; + setSearch: Dispatch>; +}) => { return ( - + - ); diff --git a/packages/app/src/components/quick-search/style.ts b/packages/app/src/components/quick-search/style.ts index 7468625650..d93cba9f80 100644 --- a/packages/app/src/components/quick-search/style.ts +++ b/packages/app/src/components/quick-search/style.ts @@ -1,5 +1,4 @@ import { displayFlex, styled } from '@/styles'; -import { relative } from 'path'; export const StyledModalWrapper = styled('div')(({ theme }) => { return { @@ -20,33 +19,63 @@ export const StyledContent = styled('div')(({ theme }) => { minHeight: '215px', maxHeight: '585px', width: '100%', - padding: '5px 24px', + padding: '0 24px', overflow: 'auto', color: theme.colors.popoverColor, - marginTop: '16px', letterSpacing: '0.06em', }; }); -export const StyledInputContent = styled('div')({ - margin: '13px 0', - ...displayFlex('space-between', 'center'), +export const StyledJumpTo = styled('div')(({ theme }) => { + return { + ...displayFlex('center', 'start'), + flexDirection: 'column', + padding: '10px 10px 10px 0', + fontSize: theme.font.sm, + strong: { + fontWeight: '500', + marginBottom: '10px', + }, + a: { + color: theme.colors.popoverColor, + padding: '5px 5px 5px 0', + ...displayFlex('center', 'center'), + ':visited': { + color: theme.colors.popoverColor, + }, + svg: { + marginBottom: '2px', + }, + span: { + marginLeft: '12px', + + lineHeight: '22px', + }, + }, + }; +}); +export const StyledInputContent = styled('div')(({ theme }) => { + return { + margin: '13px 0', + ...displayFlex('space-between', 'center'), + input: { + width: '492px', + height: '22px', + padding: '0 12px', + fontSize: theme.font.sm, + ...displayFlex('space-between', 'center'), + letterSpacing: '0.06em', + color: theme.colors.popoverColor, + '::placeholder': { + color: theme.colors.placeHolderColor, + }, + }, + }; }); export const StyledShortcut = styled('div')(({ theme }) => { return { color: theme.colors.placeHolderColor, fontSize: theme.font.xs }; }); export const StyledInput = styled('input')(({ theme }) => { - return { - width: '492px', - height: '22px', - padding: '0 12px', - fontSize: theme.font.sm, - ...displayFlex('space-between', 'center'), - letterSpacing: '0.06em', - color: theme.colors.popoverColor, - '::placeholder': { - color: theme.colors.placeHolderColor, - }, - }; + return {}; }); export const StyledLabel = styled('label')(({ theme }) => { return {