Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NYU-Abu-Dhabi
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
2024 Competition
NYU-Abu-Dhabi
Commits
486584f3
Commit
486584f3
authored
8 months ago
by
swostikpati
Browse files
Options
Downloads
Patches
Plain Diff
style draft 1 search
parent
b0ce9db0
No related branches found
No related tags found
1 merge request
!15
Full text search implementation
Pipeline
#391596
canceled
8 months ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/components/Search.css
+37
-0
37 additions, 0 deletions
src/components/Search.css
src/components/Search.jsx
+33
-10
33 additions, 10 deletions
src/components/Search.jsx
with
70 additions
and
10 deletions
src/components/Search.css
0 → 100644
+
37
−
0
View file @
486584f3
.search
{
min-width
:
320px
;
}
.search
.search-icon
,
.search
.close-icon
{
height
:
25px
;
width
:
25px
;
margin-right
:
30px
;
cursor
:
pointer
;
}
.search
.search-icon
{
margin-left
:
245px
;
}
.search
.search-bar
{
margin-right
:
20px
;
border
:
0
;
background-color
:
rgba
(
0
,
0
,
0
,
0
);
border-bottom
:
1px
solid
var
(
--dark-blue
);
outline
:
0
;
color
:
var
(
--dark-blue
);
font
:
var
(
--primary-font
);
}
.search
.dropdown
{
position
:
absolute
;
min-width
:
250px
;
min-height
:
100px
;
overflow
:
auto
;
box-shadow
:
0
8px
16px
rgba
(
0
,
0
,
0
,
0.2
);
z-index
:
10
;
top
:
90px
;
right
:
67px
;
/* padding: 10px; */
border-radius
:
10px
;
background-color
:
var
(
--light-blue
);
border
:
1px
solid
rgba
(
255
,
255
,
255
,
0.2
);
}
This diff is collapsed.
Click to expand it.
src/components/Search.jsx
+
33
−
10
View file @
486584f3
...
@@ -2,10 +2,12 @@
...
@@ -2,10 +2,12 @@
import
React
,
{
useState
,
useEffect
}
from
"
react
"
;
import
React
,
{
useState
,
useEffect
}
from
"
react
"
;
import
{
useNavigate
}
from
"
react-router-dom
"
;
import
{
useNavigate
}
from
"
react-router-dom
"
;
import
pagesData
from
"
../fullTextSearch
"
;
import
pagesData
from
"
../fullTextSearch
"
;
import
"
./Search.css
"
;
const
Search
=
({
pages
=
pagesData
})
=>
{
const
Search
=
({
pages
=
pagesData
})
=>
{
const
[
query
,
setQuery
]
=
useState
(
""
);
const
[
query
,
setQuery
]
=
useState
(
""
);
const
[
results
,
setResults
]
=
useState
([]);
const
[
results
,
setResults
]
=
useState
([]);
const
[
searchButton
,
setSearchButton
]
=
useState
(
true
);
const
navigate
=
useNavigate
();
const
navigate
=
useNavigate
();
// If required we can later use a fuzzy matching algorithm like Levenshtein distance
// If required we can later use a fuzzy matching algorithm like Levenshtein distance
...
@@ -36,21 +38,42 @@ const Search = ({ pages = pagesData }) => {
...
@@ -36,21 +38,42 @@ const Search = ({ pages = pagesData }) => {
navigate
(
page
);
// This navigates to the specified page using react-router-dom
navigate
(
page
);
// This navigates to the specified page using react-router-dom
};
};
return
(
return
searchButton
?
(
<
div
>
// JSX for when searchButton is true
<
div
className
=
"search"
>
<
img
className
=
"search-icon"
src
=
"https://static.igem.wiki/teams/5125/search.png"
onClick
=
{
()
=>
setSearchButton
(
false
)
}
></
img
>
</
div
>
)
:
(
// JSX for when searchButton is falses
<
div
className
=
"search"
>
<
input
<
input
className
=
"search-bar"
type
=
"text"
type
=
"text"
placeholder
=
"
Search...
"
placeholder
=
"
Ask Coraline :)
"
value
=
{
query
}
value
=
{
query
}
onChange
=
{
(
e
)
=>
setQuery
(
e
.
target
.
value
)
}
onChange
=
{
(
e
)
=>
setQuery
(
e
.
target
.
value
)
}
/>
/>
<
ul
>
{
results
.
map
((
result
,
index
)
=>
(
<
img
<
li
key
=
{
index
}
onClick
=
{
()
=>
handleResultClick
(
result
.
page
)
}
>
className
=
"close-icon"
{
result
.
title
}
src
=
"https://static.igem.wiki/teams/5125/close.png"
</
li
>
onClick
=
{
()
=>
setSearchButton
(
true
)
}
))
}
/>
</
ul
>
<
div
className
=
"dropdown"
>
Check out:
<
ul
>
{
results
.
map
((
result
,
index
)
=>
(
<
li
key
=
{
index
}
onClick
=
{
()
=>
handleResultClick
(
result
.
page
)
}
>
{
result
.
title
}
→
{
/* puts an arrow */
}
</
li
>
))
}
</
ul
>
</
div
>
</
div
>
</
div
>
);
);
};
};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment