Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CryptoMetrics_L02_GRP15
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
L02_GRP15
CryptoMetrics_L02_GRP15
Commits
5295a969
Commit
5295a969
authored
3 years ago
by
SaifFGit
Browse files
Options
Downloads
Patches
Plain Diff
Add search functionality
parent
d094ec5a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!7
Merge develop to main
,
!3
Add search functionality
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/cryptometrics/components/inputs/SearchInput.js
+2
-1
2 additions, 1 deletion
src/cryptometrics/components/inputs/SearchInput.js
src/cryptometrics/pages/index.js
+32
-26
32 additions, 26 deletions
src/cryptometrics/pages/index.js
with
34 additions
and
27 deletions
src/cryptometrics/components/inputs/SearchInput.js
+
2
−
1
View file @
5295a969
import
React
from
"
react
"
;
import
{
SearchIcon
}
from
"
@heroicons/react/outline
"
;
function
SearchInput
()
{
function
SearchInput
(
{
onChange
}
)
{
return
(
<
div
className
=
"
relative
"
>
<
input
className
=
"
w-52 h-12 text-base font-semibold outline-none dark:text-white px-3 pr-10 rounded-2xl bg-dark-700
"
placeholder
=
"
Search
"
type
=
"
text
"
onChange
=
{
onChange
}
><
/input
>
<
button
className
=
"
absolute top-0 right-3 bottom-0 w-6
"
>
<
SearchIcon
className
=
"
w-6 h-6 dark:text-white
"
/>
...
...
This diff is collapsed.
Click to expand it.
src/cryptometrics/pages/index.js
+
32
−
26
View file @
5295a969
...
...
@@ -11,34 +11,40 @@ import Wrapper from "../components/content/Wrapper";
import
Sidebar
from
"
../components/sidebar/Sidebar
"
;
import
{
Tabs
,
Tab
}
from
"
../components/tabs/Tab
"
;
import
{
CollectionIcon
,
TableIcon
}
from
"
@heroicons/react/outline
"
;
import
{
useState
}
from
"
react
"
;
export
default
function
Home
()
{
const
[
searchText
,
setSearchText
]
=
useState
(
""
);
const
listOfCoins
=
useCryptoList
(
"
usd
"
,
21
,
false
);
const
filteredCoins
=
listOfCoins
.
data
?.
map
((
coin
)
=>
{
return
(
<
CryptoChartCard
key
=
{
coin
.
symbol
}
currencyId
=
{
coin
.
id
}
currencyName
=
{
coin
.
name
}
symbol
=
{
coin
.
symbol
.
toUpperCase
()}
icon
=
{
coin
.
image
}
info
=
{
"
$
"
+
numeral
(
coin
.
current_price
).
format
(
"
0,0.[0000000]
"
)}
detail
=
{
numeral
(
coin
.
price_change_percentage_24h
).
format
(
"
+0.0[00]
"
)
+
"
%
"
}
detailColor
=
{
coin
.
price_change_percentage_24h
>
0
?
"
text-green-500
"
:
"
text-red-500
"
}
options
=
{
cryptoChartOptions
(
coin
.
price_change_percentage_24h
>
0
?
[
"
#3DBAA2
"
]
:
[
"
#FF7A68
"
],
true
)}
type
=
"
area
"
/>
);
});
const
filteredCoins
=
listOfCoins
.
data
?.
filter
((
coin
)
=>
{
return
coin
.
name
.
toLowerCase
().
includes
(
searchText
.
toLowerCase
());
})
.
map
((
coin
)
=>
{
return
(
<
CryptoChartCard
key
=
{
coin
.
symbol
}
currencyId
=
{
coin
.
id
}
currencyName
=
{
coin
.
name
}
symbol
=
{
coin
.
symbol
.
toUpperCase
()}
icon
=
{
coin
.
image
}
info
=
{
"
$
"
+
numeral
(
coin
.
current_price
).
format
(
"
0,0.[0000000]
"
)}
detail
=
{
numeral
(
coin
.
price_change_percentage_24h
).
format
(
"
+0.0[00]
"
)
+
"
%
"
}
detailColor
=
{
coin
.
price_change_percentage_24h
>
0
?
"
text-green-500
"
:
"
text-red-500
"
}
options
=
{
cryptoChartOptions
(
coin
.
price_change_percentage_24h
>
0
?
[
"
#3DBAA2
"
]
:
[
"
#FF7A68
"
],
true
)}
type
=
"
area
"
/>
);
});
return
(
<
div
>
<
Head
>
...
...
@@ -55,7 +61,7 @@ export default function Home() {
{
/* Main Project Title */
}
<
BoldGradientHeading
>
Home
<
/BoldGradientHeading
>
{
/* Search Field */
}
<
SearchInput
/>
<
SearchInput
onChange
=
{(
e
)
=>
setSearchText
(
e
?.
target
.
value
)}
/
>
<
/div
>
{
/* Main Content */
}
...
...
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