Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
frontend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
frontend
Commits
bb9842bc
Commit
bb9842bc
authored
Feb 26, 2025
by
tom
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
search results page
parent
e52386b8
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
161 additions
and
162 deletions
+161
-162
search-results.tsx
pages/search-results.tsx
+2
-2
SearchResults.tsx
ui/pages/SearchResults.tsx
+22
-22
SearchResultListItem.tsx
ui/searchResults/SearchResultListItem.tsx
+38
-40
SearchResultTableItem.tsx
ui/searchResults/SearchResultTableItem.tsx
+85
-86
SearchResultsInput.tsx
ui/searchResults/SearchResultsInput.tsx
+14
-12
No files found.
pages/search-results.tsx
View file @
bb9842bc
...
...
@@ -8,12 +8,12 @@ import PageNextJs from 'nextjs/PageNextJs';
import
LayoutSearchResults
from
'
ui/shared/layout/LayoutSearchResults
'
;
//
const SearchResults = dynamic(() => import('ui/pages/SearchResults'), { ssr: false });
const
SearchResults
=
dynamic
(()
=>
import
(
'
ui/pages/SearchResults
'
),
{
ssr
:
false
});
const
Page
:
NextPageWithLayout
<
Props
>
=
(
props
:
Props
)
=>
{
return
(
<
PageNextJs
pathname=
"/search-results"
query=
{
props
.
query
}
>
{
/* <SearchResults/> */
}
<
SearchResults
/>
</
PageNextJs
>
);
};
...
...
ui/pages/SearchResults.tsx
View file @
bb9842bc
import
{
Box
,
chakra
,
Table
,
Tbody
,
Tr
,
Th
,
Show
,
Hide
}
from
'
@chakra-ui/react
'
;
import
{
Box
,
chakra
}
from
'
@chakra-ui/react
'
;
import
{
useRouter
}
from
'
next/router
'
;
import
type
{
FormEvent
}
from
'
react
'
;
import
React
from
'
react
'
;
...
...
@@ -11,20 +11,20 @@ import { useSettingsContext } from 'lib/contexts/settings';
import
*
as
regexp
from
'
lib/regexp
'
;
import
getQueryParamString
from
'
lib/router/getQueryParamString
'
;
import
removeQueryParam
from
'
lib/router/removeQueryParam
'
;
import
{
Skeleton
}
from
'
toolkit/chakra/skeleton
'
;
import
{
TableBody
,
TableColumnHeader
,
TableHeaderSticky
,
TableRoot
,
TableRow
}
from
'
toolkit/chakra/table
'
;
import
useMarketplaceApps
from
'
ui/marketplace/useMarketplaceApps
'
;
import
SearchResultListItem
from
'
ui/searchResults/SearchResultListItem
'
;
import
SearchResultsInput
from
'
ui/searchResults/SearchResultsInput
'
;
import
SearchResultTableItem
from
'
ui/searchResults/SearchResultTableItem
'
;
import
ActionBar
,
{
ACTION_BAR_HEIGHT_DESKTOP
}
from
'
ui/shared/ActionBar
'
;
import
AppErrorBoundary
from
'
ui/shared/AppError/AppErrorBoundary
'
;
import
Skeleton
from
'
ui/shared/chakra/Skeleton
'
;
import
ContentLoader
from
'
ui/shared/ContentLoader
'
;
import
DataFetchAlert
from
'
ui/shared/DataFetchAlert
'
;
import
*
as
Layout
from
'
ui/shared/layout/components
'
;
import
PageTitle
from
'
ui/shared/Page/PageTitle
'
;
import
Pagination
from
'
ui/shared/pagination/Pagination
'
;
import
type
{
SearchResultAppItem
}
from
'
ui/shared/search/utils
'
;
import
Thead
from
'
ui/shared/TheadSticky
'
;
import
HeaderAlert
from
'
ui/snippets/header/HeaderAlert
'
;
import
HeaderDesktop
from
'
ui/snippets/header/HeaderDesktop
'
;
import
HeaderMobile
from
'
ui/snippets/header/HeaderMobile
'
;
...
...
@@ -144,7 +144,7 @@ const SearchResultsPageContent = () => {
return
(
<>
<
Show
below=
"lg"
ssr=
{
false
}
>
<
Box
hideFrom=
"lg"
>
{
displayedItems
.
map
((
item
,
index
)
=>
(
<
SearchResultListItem
key=
{
(
isLoading
?
'
placeholder_
'
:
'
actual_
'
)
+
index
}
...
...
@@ -154,18 +154,18 @@ const SearchResultsPageContent = () => {
addressFormat=
{
settingsContext
?.
addressFormat
}
/>
))
}
</
Show
>
<
Hide
below=
"lg"
ssr=
{
false
}
>
<
Table
fontWeight=
{
500
}
>
<
T
head
top=
{
pagination
.
isVisible
?
ACTION_BAR_HEIGHT_DESKTOP
:
0
}
>
<
T
r
>
<
T
h
width=
"30%"
>
Search result
</
Th
>
<
T
h
width=
"35%"
/>
<
T
h
width=
"35%"
pr=
{
10
}
/>
<
T
h
width=
"150px"
>
Category
</
Th
>
</
T
r
>
</
T
head
>
<
T
b
ody
>
</
Box
>
<
Box
hideBelow=
"lg"
>
<
Table
Root
fontWeight=
{
500
}
>
<
T
ableHeaderSticky
top=
{
pagination
.
isVisible
?
ACTION_BAR_HEIGHT_DESKTOP
:
0
}
>
<
T
ableRow
>
<
T
ableColumnHeader
width=
"30%"
>
Search result
</
TableColumnHeader
>
<
T
ableColumnHeader
width=
"35%"
/>
<
T
ableColumnHeader
width=
"35%"
pr=
{
10
}
/>
<
T
ableColumnHeader
width=
"150px"
>
Category
</
TableColumnHeader
>
</
T
ableRow
>
</
T
ableHeaderSticky
>
<
T
ableB
ody
>
{
displayedItems
.
map
((
item
,
index
)
=>
(
<
SearchResultTableItem
key=
{
(
isLoading
?
'
placeholder_
'
:
'
actual_
'
)
+
index
}
...
...
@@ -175,9 +175,9 @@ const SearchResultsPageContent = () => {
addressFormat=
{
settingsContext
?.
addressFormat
}
/>
))
}
</
T
b
ody
>
</
Table
>
</
Hide
>
</
T
ableB
ody
>
</
Table
Root
>
</
Box
>
</>
);
})();
...
...
@@ -190,7 +190,7 @@ const SearchResultsPageContent = () => {
const
resultsCount
=
pagination
.
page
===
1
&&
!
data
?.
next_page_params
?
displayedItems
.
length
:
'
50+
'
;
const
text
=
isLoading
&&
pagination
.
page
===
1
?
(
<
Skeleton
h=
{
6
}
w=
"280px"
borderRadius=
"full"
mb=
{
pagination
.
isVisible
?
0
:
6
}
/>
<
Skeleton
loading
h=
{
6
}
w=
"280px"
borderRadius=
"full"
mb=
{
pagination
.
isVisible
?
0
:
6
}
/>
)
:
(
(
<>
...
...
@@ -214,9 +214,9 @@ const SearchResultsPageContent = () => {
return
(
<>
<
Box
display=
{
{
base
:
'
block
'
,
lg
:
'
none
'
}
}
>
{
text
}
</
Box
>
<
Box
hideFrom=
"lg"
>
{
text
}
</
Box
>
<
ActionBar
mt=
{
{
base
:
0
,
lg
:
-
6
}
}
alignItems=
"center"
>
<
Box
display=
{
{
base
:
'
none
'
,
lg
:
'
block
'
}
}
>
{
text
}
</
Box
>
<
Box
hideBelow=
"lg"
>
{
text
}
</
Box
>
<
Pagination
{
...
pagination
}
/>
</
ActionBar
>
</>
...
...
ui/searchResults/SearchResultListItem.tsx
View file @
bb9842bc
This diff is collapsed.
Click to expand it.
ui/searchResults/SearchResultTableItem.tsx
View file @
bb9842bc
This diff is collapsed.
Click to expand it.
ui/searchResults/SearchResultsInput.tsx
View file @
bb9842bc
import
{
PopoverTrigger
,
PopoverContent
,
PopoverBody
,
useDisclosure
}
from
'
@chakra-ui/react
'
;
import
{
debounce
}
from
'
es-toolkit
'
;
import
type
{
FormEvent
,
FocusEvent
}
from
'
react
'
;
import
React
from
'
react
'
;
import
useIsMobile
from
'
lib/hooks/useIsMobile
'
;
import
{
getRecentSearchKeywords
}
from
'
lib/recentSearchKeywords
'
;
import
Popover
from
'
ui/shared/chakra/Popover
'
;
import
{
PopoverBody
,
PopoverContent
,
PopoverRoot
,
PopoverTrigger
}
from
'
toolkit/chakra/popover
'
;
import
{
useDisclosure
}
from
'
toolkit/hooks/useDisclosure
'
;
import
SearchBarBackdrop
from
'
ui/snippets/searchBar/SearchBarBackdrop
'
;
import
SearchBarInput
from
'
ui/snippets/searchBar/SearchBarInput
'
;
import
SearchBarRecentKeywords
from
'
ui/snippets/searchBar/SearchBarRecentKeywords
'
;
...
...
@@ -17,7 +17,7 @@ type Props = {
};
const
SearchResultsInput
=
({
searchTerm
,
handleSubmit
,
handleSearchTermChange
}:
Props
)
=>
{
const
{
isO
pen
,
onClose
,
onOpen
}
=
useDisclosure
();
const
{
o
pen
,
onClose
,
onOpen
}
=
useDisclosure
();
const
inputRef
=
React
.
useRef
<
HTMLFormElement
>
(
null
);
const
menuRef
=
React
.
useRef
<
HTMLDivElement
>
(
null
);
const
menuWidth
=
React
.
useRef
<
number
>
(
0
);
...
...
@@ -25,6 +25,10 @@ const SearchResultsInput = ({ searchTerm, handleSubmit, handleSearchTermChange }
const
recentSearchKeywords
=
getRecentSearchKeywords
();
const
handleOpenChange
=
React
.
useCallback
(({
open
}:
{
open
:
boolean
})
=>
{
open
&&
onOpen
();
},
[
onOpen
]);
const
handleFocus
=
React
.
useCallback
(()
=>
{
onOpen
();
},
[
onOpen
]);
...
...
@@ -47,7 +51,7 @@ const SearchResultsInput = ({ searchTerm, handleSubmit, handleSearchTermChange }
inputRef
.
current
?.
querySelector
(
'
input
'
)?.
focus
();
},
[
handleSearchTermChange
]);
const
menuPaddingX
=
isMobile
?
32
:
0
;
const
menuPaddingX
=
isMobile
?
24
:
0
;
const
calculateMenuWidth
=
React
.
useCallback
(()
=>
{
menuWidth
.
current
=
(
inputRef
.
current
?.
getBoundingClientRect
().
width
||
0
)
-
menuPaddingX
;
},
[
menuPaddingX
]);
...
...
@@ -68,17 +72,15 @@ const SearchResultsInput = ({ searchTerm, handleSubmit, handleSearchTermChange }
};
},
[
calculateMenuWidth
]);
const
isSuggestOpen
=
isO
pen
&&
recentSearchKeywords
.
length
>
0
&&
searchTerm
.
trim
().
length
===
0
;
const
isSuggestOpen
=
o
pen
&&
recentSearchKeywords
.
length
>
0
&&
searchTerm
.
trim
().
length
===
0
;
return
(
<>
<
Popover
isO
pen=
{
isSuggestOpen
}
<
Popover
Root
o
pen=
{
isSuggestOpen
}
autoFocus=
{
false
}
onClose=
{
onClose
}
placement=
"bottom-start"
offset=
{
isMobile
?
[
16
,
-
12
]
:
[
0
,
8
]
}
isLazy
onOpenChange=
{
handleOpenChange
}
positioning=
{
{
offset
:
{
mainAxis
:
isMobile
?
0
:
8
,
crossAxis
:
isMobile
?
12
:
0
}
}
}
>
<
PopoverTrigger
>
<
SearchBarInput
...
...
@@ -98,7 +100,7 @@ const SearchResultsInput = ({ searchTerm, handleSubmit, handleSearchTermChange }
<
SearchBarRecentKeywords
onClick=
{
handleSearchTermChange
}
onClear=
{
onClose
}
/>
</
PopoverBody
>
</
PopoverContent
>
</
Popover
>
</
Popover
Root
>
<
SearchBarBackdrop
isOpen=
{
isSuggestOpen
}
/>
</>
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment