-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from TrevisfoX/dev
init: modal window; update: project structure
- Loading branch information
Showing
13 changed files
with
976 additions
and
529 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
import React from "react"; | ||
import { Link } from "react-router-dom"; | ||
import { | ||
Card, | ||
CardContent, | ||
Typography, | ||
CardActions, | ||
IconButton, | ||
} from "@mui/material"; | ||
import millify from "millify"; | ||
import AddIcon from "@mui/icons-material/Add"; | ||
import ReadMoreIcon from "@mui/icons-material/ReadMore"; | ||
|
||
const CoinItem = ({ currency }) => { | ||
return ( | ||
<Card | ||
sx={{ | ||
minHeight: 255, | ||
}} | ||
> | ||
<CardContent> | ||
<Typography | ||
gutterBottom | ||
variant="h5" | ||
component="h5" | ||
sx={{ | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContent: "center", | ||
gap: 2, | ||
pb: 2, | ||
mb: 2, | ||
fontWeight: "bold", | ||
borderBottom: 0.5, | ||
borderColor: "silver", | ||
}} | ||
> | ||
<img | ||
src={currency.iconUrl} | ||
alt="Coin icon" | ||
width="50" | ||
height="50" | ||
/> | ||
{currency.name} | ||
</Typography> | ||
<Typography | ||
variant="body2" | ||
color="text.secondary" | ||
sx={{ | ||
fontSize: 16, | ||
color: "grey", | ||
mb: 1, | ||
}} | ||
> | ||
Rank: {currency.rank} | ||
</Typography> | ||
<Typography | ||
variant="body2" | ||
color="text.secondary" | ||
sx={{ | ||
fontSize: 16, | ||
color: "grey", | ||
mb: 1, | ||
}} | ||
> | ||
Price: {millify(currency.price)} $ | ||
</Typography> | ||
<Typography | ||
variant="body2" | ||
color="text.secondary" | ||
sx={{ | ||
fontSize: 16, | ||
color: "grey", | ||
mb: 1, | ||
}} | ||
> | ||
Market Cap: {millify(currency.marketCap)} | ||
</Typography> | ||
<Typography | ||
variant="body2" | ||
color="text.secondary" | ||
sx={{ | ||
fontSize: 16, | ||
color: "grey", | ||
}} | ||
> | ||
Daily Change: {millify(currency.change)}% | ||
</Typography> | ||
</CardContent> | ||
<CardActions | ||
sx={{ | ||
display: "flex", | ||
justifyContent: "flex-end", | ||
bgcolor: "#1976d2", | ||
}} | ||
> | ||
<IconButton | ||
sx={{ | ||
color: "white", | ||
}} | ||
> | ||
<AddIcon /> | ||
</IconButton> | ||
<Link to={`/crypto/${currency.uuid}`}> | ||
<IconButton | ||
sx={{ | ||
color: "white", | ||
}} | ||
> | ||
<ReadMoreIcon /> | ||
</IconButton> | ||
</Link> | ||
</CardActions> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default CoinItem; |
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,52 @@ | ||
import React, { useState, useEffect } from "react"; | ||
import { useGetCryptosQuery } from "../../services/cryptoApi"; | ||
import Loader from "../Loader/Loader"; | ||
import { Grid, TextField, Box } from "@mui/material"; | ||
import CoinItem from "../CoinItem/CoinItem"; | ||
|
||
const CoinList = ({ simplified }) => { | ||
const count = simplified ? 12 : 100; | ||
const { data: cryptosList, isFetching } = useGetCryptosQuery(count); | ||
const [cryptos, setCryptos] = useState([]); | ||
const [searchTerm, setSearchTerm] = useState(""); | ||
|
||
useEffect(() => { | ||
const filteredData = cryptosList?.data?.coins.filter((coin) => | ||
coin.name.toLowerCase().includes(searchTerm.toLowerCase()) | ||
); | ||
setCryptos(filteredData); | ||
}, [cryptosList, searchTerm]); | ||
|
||
if (isFetching) return <Loader />; | ||
|
||
return ( | ||
<> | ||
{!simplified && ( | ||
<Box | ||
component="form" | ||
sx={{ | ||
"& > :not(style)": { my: 3, width: "31%" }, | ||
}} | ||
noValidate | ||
> | ||
<TextField | ||
id="standard-basic" | ||
label="Search coin..." | ||
variant="standard" | ||
onChange={(e) => setSearchTerm(e.target.value)} | ||
/> | ||
</Box> | ||
)} | ||
|
||
<Grid container spacing={5}> | ||
{cryptos?.map((currency, index) => ( | ||
<Grid item md={4} key={index}> | ||
<CoinItem currency={currency} /> | ||
</Grid> | ||
))} | ||
</Grid> | ||
</> | ||
); | ||
}; | ||
|
||
export default CoinList; |
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.