-
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.
- Loading branch information
Showing
23 changed files
with
31,610 additions
and
17,162 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -1,38 +1,13 @@ | ||
.App { | ||
text-align: center; | ||
} | ||
|
||
.App-logo { | ||
height: 40vmin; | ||
pointer-events: none; | ||
} | ||
|
||
@media (prefers-reduced-motion: no-preference) { | ||
.App-logo { | ||
animation: App-logo-spin infinite 20s linear; | ||
} | ||
} | ||
|
||
.App-header { | ||
background-color: #282c34; | ||
min-height: 100vh; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: calc(10px + 2vmin); | ||
color: white; | ||
} | ||
@import url("https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;800&display=swap"); | ||
|
||
.App-link { | ||
color: #61dafb; | ||
* { | ||
margin: 0; | ||
padding: 0; | ||
box-sizing: border-box; | ||
scroll-behavior: smooth; | ||
} | ||
|
||
@keyframes App-logo-spin { | ||
from { | ||
transform: rotate(0deg); | ||
} | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
a { | ||
text-decoration: none; | ||
color: gold; | ||
} |
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 was deleted.
Oops, something went wrong.
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,25 @@ | ||
import React, { createContext, useContext, useEffect, useState } from "react"; | ||
|
||
const Crypto = createContext(); | ||
|
||
const CryptoContext = ({ children }) => { | ||
const [currency, setCurrency] = useState("INR"); | ||
const [symbol, setSymbol] = useState("₹"); | ||
|
||
useEffect(() => { | ||
if (currency === "INR") setSymbol("₹"); | ||
else if (currency === "USD") setSymbol("$"); | ||
}, [currency]); | ||
|
||
return ( | ||
<Crypto.Provider value={{ currency, setCurrency, symbol }}> | ||
{children} | ||
</Crypto.Provider> | ||
); | ||
}; | ||
|
||
export default CryptoContext; | ||
|
||
export const CryptoState = () => { | ||
return useContext(Crypto); | ||
}; |
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,158 @@ | ||
import { LinearProgress, makeStyles, Typography } from "@material-ui/core"; | ||
import axios from "axios"; | ||
import { useEffect, useState } from "react"; | ||
import { useParams } from "react-router-dom"; | ||
import ReactHtmlParser from "react-html-parser"; | ||
import CoinInfo from "../components/CoinInfo"; | ||
import { SingleCoin } from "../config/api"; | ||
import { numberWithCommas } from "../components/CoinsTable"; | ||
import { CryptoState } from "../CryptoContext"; | ||
|
||
const CoinPage = () => { | ||
const { id } = useParams(); | ||
const [coin, setCoin] = useState(); | ||
|
||
const { currency, symbol } = CryptoState(); | ||
|
||
const fetchCoin = async () => { | ||
const { data } = await axios.get(SingleCoin(id)); | ||
|
||
setCoin(data); | ||
}; | ||
|
||
useEffect(() => { | ||
fetchCoin(); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
container: { | ||
display: "flex", | ||
[theme.breakpoints.down("md")]: { | ||
flexDirection: "column", | ||
alignItems: "center", | ||
}, | ||
}, | ||
sidebar: { | ||
width: "30%", | ||
[theme.breakpoints.down("md")]: { | ||
width: "100%", | ||
}, | ||
display: "flex", | ||
flexDirection: "column", | ||
alignItems: "center", | ||
marginTop: 25, | ||
borderRight: "2px solid grey", | ||
}, | ||
heading: { | ||
fontWeight: "bold", | ||
marginBottom: 20, | ||
fontFamily: "Montserrat", | ||
}, | ||
description: { | ||
width: "100%", | ||
fontFamily: "Montserrat", | ||
padding: 25, | ||
paddingBottom: 15, | ||
paddingTop: 0, | ||
textAlign: "justify", | ||
}, | ||
marketData: { | ||
alignSelf: "start", | ||
padding: 25, | ||
paddingTop: 10, | ||
width: "100%", | ||
[theme.breakpoints.down("md")]: { | ||
display: "flex", | ||
justifyContent: "space-around", | ||
}, | ||
[theme.breakpoints.down("sm")]: { | ||
flexDirection: "column", | ||
alignItems: "center", | ||
}, | ||
[theme.breakpoints.down("xs")]: { | ||
alignItems: "start", | ||
}, | ||
}, | ||
})); | ||
|
||
const classes = useStyles(); | ||
|
||
if (!coin) return <LinearProgress style={{ backgroundColor: "gold" }} />; | ||
|
||
return ( | ||
<div className={classes.container}> | ||
<div className={classes.sidebar}> | ||
<img | ||
src={coin?.image.large} | ||
alt={coin?.name} | ||
height="200" | ||
style={{ marginBottom: 20 }} | ||
/> | ||
<Typography variant="h3" className={classes.heading}> | ||
{coin?.name} | ||
</Typography> | ||
<Typography variant="subtitle1" className={classes.description}> | ||
{ReactHtmlParser(coin?.description.en.split(". ")[0])}. | ||
</Typography> | ||
<div className={classes.marketData}> | ||
<span style={{ display: "flex" }}> | ||
<Typography variant="h5" className={classes.heading}> | ||
Rank: | ||
</Typography> | ||
| ||
<Typography | ||
variant="h5" | ||
style={{ | ||
fontFamily: "Montserrat", | ||
}} | ||
> | ||
{numberWithCommas(coin?.market_cap_rank)} | ||
</Typography> | ||
</span> | ||
|
||
<span style={{ display: "flex" }}> | ||
<Typography variant="h5" className={classes.heading}> | ||
Current Price: | ||
</Typography> | ||
| ||
<Typography | ||
variant="h5" | ||
style={{ | ||
fontFamily: "Montserrat", | ||
}} | ||
> | ||
{symbol}{" "} | ||
{numberWithCommas( | ||
coin?.market_data.current_price[currency.toLowerCase()] | ||
)} | ||
</Typography> | ||
</span> | ||
<span style={{ display: "flex" }}> | ||
<Typography variant="h5" className={classes.heading}> | ||
Market Cap: | ||
</Typography> | ||
| ||
<Typography | ||
variant="h5" | ||
style={{ | ||
fontFamily: "Montserrat", | ||
}} | ||
> | ||
{symbol}{" "} | ||
{numberWithCommas( | ||
coin?.market_data.market_cap[currency.toLowerCase()] | ||
.toString() | ||
.slice(0, -6) | ||
)} | ||
M | ||
</Typography> | ||
</span> | ||
</div> | ||
</div> | ||
<CoinInfo coin={coin} /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CoinPage; |
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,14 @@ | ||
import React from "react"; | ||
import Banner from "../components/Banner/Banner"; | ||
import CoinsTable from "../components/CoinsTable"; | ||
|
||
const Homepage = () => { | ||
return ( | ||
<> | ||
<Banner /> | ||
<CoinsTable /> | ||
</> | ||
); | ||
}; | ||
|
||
export default Homepage; |
Oops, something went wrong.