-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented Workspace Search & Discovery
- Loading branch information
1 parent
73526d2
commit b90e850
Showing
21 changed files
with
305 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.spinner { | ||
border: 8px solid #f3f3f3; | ||
border-top: 8px solid lightgray; | ||
border-radius: 50%; | ||
width: 50px; | ||
height: 50px; | ||
animation: spin 2s linear infinite; | ||
margin: auto; | ||
} | ||
|
||
@keyframes spin { | ||
0% { | ||
transform: rotate(0deg); | ||
} | ||
100% { | ||
transform: rotate(360deg); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import './Spinner.scss'; | ||
|
||
function Spinner() { | ||
return <div className="spinner"></div>; | ||
} | ||
|
||
export default Spinner; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { useCallback, useState } from 'react'; | ||
import Spinner from '@ui/components/spinner/Spinner'; | ||
|
||
function useLoading() { | ||
const [loading, setLoading] = useState(false); | ||
|
||
const startLoading = useCallback(() => setLoading(true), []); | ||
const stopLoading = useCallback(() => setLoading(false), []); | ||
|
||
const spinner = <Spinner />; | ||
|
||
return { loading, startLoading, stopLoading, spinner }; | ||
} | ||
|
||
export default useLoading; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
.search { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: space-evenly; | ||
|
||
.pagination { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
gap: 2vh; | ||
margin-top: auto; | ||
margin-bottom: 10vh; | ||
|
||
button { | ||
border-radius: 50%; | ||
background-color: lightgray; | ||
color: black; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { Link } from 'react-router-dom'; | ||
import { WorkspaceMeta } from '@notespace/shared/src/workspace/types/workspace'; | ||
import { useEffect, useState } from 'react'; | ||
import { useQueryParams } from '@/utils/utils'; | ||
import useWorkspaceService from '@services/workspace/useWorkspaceService'; | ||
import './Search.scss'; | ||
import { FaArrowLeft, FaArrowRight } from 'react-icons/fa6'; | ||
|
||
const PAGE_SIZE = 10; | ||
|
||
function Search() { | ||
const [results, setResults] = useState<WorkspaceMeta[]>([]); | ||
const [page, setPage] = useState(0); | ||
const { query } = useQueryParams(); | ||
const service = useWorkspaceService(); | ||
|
||
useEffect(() => { | ||
async function searchWorkspaces() { | ||
const results = await service.searchWorkspaces(query, page * PAGE_SIZE, PAGE_SIZE); | ||
setResults(results); | ||
} | ||
searchWorkspaces(); | ||
}, [page, query, service]); | ||
|
||
return ( | ||
<div className="search"> | ||
<h2>Search results for "{query}"</h2> | ||
{results.map(workspace => ( | ||
<div className="workspace"> | ||
<Link key={workspace.id} to={`/workspace/${workspace.id}`}> | ||
{workspace.name} | ||
</Link> | ||
</div> | ||
))} | ||
<div className="pagination"> | ||
<button onClick={() => setPage(page - 1)} disabled={page === 0}> | ||
<FaArrowLeft /> | ||
</button> | ||
<button onClick={() => setPage(page + 1)} disabled={results.length < PAGE_SIZE}> | ||
<FaArrowRight /> | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default Search; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.