├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public ├── favicon.ico ├── index.html ├── logo192.png ├── logo512.png ├── manifest.json └── robots.txt └── src ├── App.js ├── components ├── CoinItem.js ├── Coins.css ├── Coins.js ├── Navbar.css └── Navbar.js ├── index.css ├── index.js └── routes ├── Coin.css └── Coin.js /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in your browser. 13 | 14 | The page will reload when you make changes.\ 15 | You may also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can't go back!** 35 | 36 | If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own. 39 | 40 | You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | 48 | ### Code Splitting 49 | 50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) 51 | 52 | ### Analyzing the Bundle Size 53 | 54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) 55 | 56 | ### Making a Progressive Web App 57 | 58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) 59 | 60 | ### Advanced Configuration 61 | 62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) 63 | 64 | ### Deployment 65 | 66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 67 | 68 | ### `npm run build` fails to minify 69 | 70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) 71 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "crypto-app-react", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.16.1", 7 | "@testing-library/react": "^12.1.2", 8 | "@testing-library/user-event": "^13.5.0", 9 | "axios": "^0.24.0", 10 | "dompurify": "^2.3.4", 11 | "react": "^17.0.2", 12 | "react-dom": "^17.0.2", 13 | "react-icons": "^4.3.1", 14 | "react-router-dom": "^6.2.1", 15 | "react-scripts": "5.0.0", 16 | "web-vitals": "^2.1.3" 17 | }, 18 | "scripts": { 19 | "start": "react-scripts start", 20 | "build": "react-scripts build", 21 | "test": "react-scripts test", 22 | "eject": "react-scripts eject" 23 | }, 24 | "eslintConfig": { 25 | "extends": [ 26 | "react-app", 27 | "react-app/jest" 28 | ] 29 | }, 30 | "browserslist": { 31 | "production": [ 32 | ">0.2%", 33 | "not dead", 34 | "not op_mini all" 35 | ], 36 | "development": [ 37 | "last 1 chrome version", 38 | "last 1 firefox version", 39 | "last 1 safari version" 40 | ] 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fireclint/crypto-app-react/27176a29a128606f3548d197ba2437628680e896/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fireclint/crypto-app-react/27176a29a128606f3548d197ba2437628680e896/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fireclint/crypto-app-react/27176a29a128606f3548d197ba2437628680e896/public/logo512.png -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import React, { useState, useEffect } from 'react' 2 | import axios from 'axios' 3 | import { Routes, Route } from 'react-router-dom' 4 | import Coins from './components/Coins' 5 | import Coin from './routes/Coin' 6 | import Navbar from './components/Navbar' 7 | 8 | 9 | function App() { 10 | 11 | const [coins, setCoins] = useState([]) 12 | 13 | const url = 'https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=50&page=1&sparkline=false' 14 | 15 | useEffect(() => { 16 | axios.get(url).then((response) => { 17 | setCoins(response.data) 18 | // console.log(response.data[0]) 19 | }).catch((error) => { 20 | console.log(error) 21 | }) 22 | }, []) 23 | 24 | return ( 25 | <> 26 | 27 | 28 | } /> 29 | }> 30 | } /> 31 | 32 | 33 | 34 | 35 | ); 36 | } 37 | 38 | export default App; 39 | -------------------------------------------------------------------------------- /src/components/CoinItem.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | 3 | import './Coins.css' 4 | 5 | const CoinItem = (props) => { 6 | return ( 7 |
8 |

{props.coins.market_cap_rank}

9 |
10 | 11 |

{props.coins.symbol.toUpperCase()}

12 |
13 |

${props.coins.current_price.toLocaleString()}

14 |

{props.coins.price_change_percentage_24h.toFixed(2)}%

15 |

${props.coins.total_volume.toLocaleString()}

16 |

${props.coins.market_cap.toLocaleString()}

17 |
18 | ) 19 | } 20 | 21 | export default CoinItem 22 | -------------------------------------------------------------------------------- /src/components/Coins.css: -------------------------------------------------------------------------------- 1 | .container { 2 | max-width: 1140px; 3 | margin: auto; 4 | } 5 | 6 | .heading { 7 | display: flex; 8 | justify-content: space-between; 9 | align-items: center; 10 | background-color: #26272b; 11 | box-shadow: 0px 0px 12px #18191b; 12 | border-radius: 8px; 13 | margin: 2rem 1rem; 14 | padding: .7rem 1rem; 15 | font-weight: 700; 16 | } 17 | 18 | .coin-name { 19 | margin-left: -4rem; 20 | } 21 | 22 | .coin-row { 23 | display: flex; 24 | justify-content: space-between; 25 | align-items: center; 26 | background-color: #26272b; 27 | box-shadow: 0px 0px 12px #18191b; 28 | border-radius: 8px; 29 | margin: 2rem 1rem; 30 | padding: .7rem 1rem; 31 | } 32 | 33 | .coin-row:hover { 34 | transform: scale(1.04); 35 | transition: .3s ease-in-out; 36 | cursor: pointer; 37 | } 38 | 39 | img { 40 | height: 40px; 41 | margin-right: 8px; 42 | width: auto; 43 | } 44 | 45 | .img-symbol { 46 | display: flex; 47 | align-items: center; 48 | } 49 | 50 | 51 | 52 | @media screen and (max-width: 720px) { 53 | .hide-mobile { 54 | display: none; 55 | } 56 | } -------------------------------------------------------------------------------- /src/components/Coins.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import CoinItem from './CoinItem' 3 | import Coin from '../routes/Coin' 4 | import { Link } from 'react-router-dom' 5 | 6 | import './Coins.css' 7 | 8 | const Coins = (props) => { 9 | return ( 10 |
11 |
12 |
13 |

#

14 |

Coin

15 |

Price

16 |

24h

17 |

Volume

18 |

Mkt Cap

19 |
20 | 21 | {props.coins.map(coins => { 22 | return ( 23 | } key={coins.id}> 24 | 25 | 26 | 27 | ) 28 | })} 29 | 30 |
31 |
32 | ) 33 | } 34 | 35 | export default Coins 36 | -------------------------------------------------------------------------------- /src/components/Navbar.css: -------------------------------------------------------------------------------- 1 | .navbar { 2 | display: flex; 3 | justify-content: center; 4 | align-items: center; 5 | } 6 | 7 | .icon { 8 | font-size: 2rem; 9 | color: #6900ff; 10 | } 11 | 12 | .purple { 13 | color: #6900ff; 14 | } -------------------------------------------------------------------------------- /src/components/Navbar.js: -------------------------------------------------------------------------------- 1 | import React from 'react' 2 | import {FaCoins} from 'react-icons/fa' 3 | import {Link} from 'react-router-dom' 4 | import './Navbar.css' 5 | 6 | const Navbar = () => { 7 | return ( 8 | 9 |
10 | 11 |

Coin Search

12 |
13 | 14 | ) 15 | } 16 | 17 | export default Navbar 18 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=Rubik:wght@400;500;600;700;800;900&display=swap'); 2 | 3 | * { 4 | box-sizing: border-box; 5 | margin: 0; 6 | padding: 0; 7 | } 8 | 9 | body { 10 | margin: 0; 11 | font-family: 'Rubik', 'Segoe UI', 'Roboto', 'Oxygen', 12 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 13 | sans-serif; 14 | -webkit-font-smoothing: antialiased; 15 | -moz-osx-font-smoothing: grayscale; 16 | 17 | background-color: #26272b; 18 | color: #f4f4f4; 19 | } 20 | 21 | a { 22 | color: #f4f4f4; 23 | text-decoration: none; 24 | } 25 | 26 | h1 { 27 | text-align: center; 28 | margin: 1rem; 29 | } 30 | 31 | code { 32 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 33 | monospace; 34 | } 35 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import { BrowserRouter } from 'react-router-dom'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root') 12 | ); 13 | 14 | -------------------------------------------------------------------------------- /src/routes/Coin.css: -------------------------------------------------------------------------------- 1 | .coin-container .content { 2 | max-width: 740px; 3 | margin: 1rem auto; 4 | padding: .7rem 1rem; 5 | display: flex; 6 | flex-direction: column; 7 | background-color: #26272b; 8 | box-shadow: 0px 0px 12px #18191b; 9 | border-radius: 8px; 10 | } 11 | 12 | .rank { 13 | margin: .5 0; 14 | } 15 | 16 | .rank-btn { 17 | border: 1px solid #6900ff; 18 | box-shadow: 0px 0px 8px #6900ff; 19 | background-color: #6900ff; 20 | border-radius: 8px; 21 | padding: .2rem; 22 | } 23 | 24 | .info { 25 | display: grid; 26 | grid-template-columns: repeat(2, 1fr); 27 | } 28 | 29 | .info .coin-heading { 30 | display: flex; 31 | align-items: center; 32 | margin: 1rem 0; 33 | } 34 | 35 | .info .coin-price { 36 | display: flex; 37 | align-items: center; 38 | justify-content: center; 39 | } 40 | 41 | .info p { 42 | padding-right: 1rem; 43 | } 44 | 45 | table { 46 | margin: .5rem 0; 47 | } 48 | 49 | td, th { 50 | padding: 8px; 51 | text-align: center; 52 | } 53 | 54 | th { 55 | background-color: #333; 56 | } 57 | 58 | .stats { 59 | display: grid; 60 | grid-template-columns: repeat(2, 1fr); 61 | grid-gap: 2rem; 62 | width: 100%; 63 | } 64 | 65 | .stats .row { 66 | display: flex; 67 | justify-content: space-between; 68 | border-bottom: 1px solid #808080; 69 | margin: .6rem 0; 70 | padding-bottom: .5rem; 71 | } 72 | 73 | .stats .row p:first-child { 74 | color: #d3d3d3; 75 | } 76 | 77 | .about h3 { 78 | margin: 1rem 0; 79 | } 80 | 81 | @media screen and (max-width: 700px) { 82 | .coin-container .content { 83 | max-width: 100%; 84 | margin: .5rem; 85 | padding: 0 .5rem; 86 | } 87 | 88 | .stats { 89 | grid-template-columns: 1fr; 90 | } 91 | 92 | td,th { 93 | padding: 3px; 94 | } 95 | 96 | .rank { 97 | margin: .5rem; 98 | } 99 | 100 | .rank-btn { 101 | margin: .5rem 0; 102 | } 103 | } 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /src/routes/Coin.js: -------------------------------------------------------------------------------- 1 | import axios from 'axios' 2 | import { useParams } from 'react-router-dom' 3 | import React, { useState, useEffect } from 'react' 4 | import DOMPurify from 'dompurify' 5 | 6 | import './Coin.css' 7 | 8 | const Coin = () => { 9 | 10 | const params = useParams() 11 | const [coin, setCoin] = useState({}) 12 | 13 | const url = `https://api.coingecko.com/api/v3/coins/${params.coinId}` 14 | 15 | 16 | useEffect(() => { 17 | axios.get(url).then((res) => { 18 | setCoin(res.data) 19 | }).catch((error) => { 20 | console.log(error) 21 | }) 22 | }, []) 23 | 24 | return ( 25 |
26 |
27 |
28 |

{coin.name}

29 |
30 |
31 |
32 | Rank # {coin.market_cap_rank} 33 |
34 |
35 |
36 | {coin.image ? : null} 37 |

{coin.name}

38 | {coin.symbol ?

{coin.symbol.toUpperCase()}/USD

: null} 39 | 40 |
41 |
42 | {coin.market_data?.current_price ?

${coin.market_data.current_price.usd.toLocaleString()}

: null} 43 |
44 |
45 |
46 | 47 |
48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 |
1h24h7d14d30d1yr
{coin.market_data?.price_change_percentage_1h_in_currency ?

{coin.market_data.price_change_percentage_1h_in_currency.usd.toFixed(1)}%

: null}
{coin.market_data?.price_change_percentage_24h_in_currency ?

{coin.market_data.price_change_percentage_24h_in_currency.usd.toFixed(1)}%

: null}
{coin.market_data?.price_change_percentage_24h_in_currency ?

{coin.market_data.price_change_percentage_7d_in_currency.usd.toFixed(1)}%

: null}
{coin.market_data?.price_change_percentage_24h_in_currency ?

{coin.market_data.price_change_percentage_14d_in_currency.usd.toFixed(1)}%

: null}
{coin.market_data?.price_change_percentage_24h_in_currency ?

{coin.market_data.price_change_percentage_30d_in_currency.usd.toFixed(1)}%

: null}
{coin.market_data?.price_change_percentage_24h_in_currency ?

{coin.market_data.price_change_percentage_1y_in_currency.usd.toFixed(1)}%

: null}
71 |
72 |
73 |
74 |
75 |
76 |

24 Hour Low

77 | {coin.market_data?.low_24h ?

${coin.market_data.low_24h.usd.toLocaleString()}

: null} 78 |
79 |
80 |

24 Hour High

81 | {coin.market_data?.high_24h ?

${coin.market_data.high_24h.usd.toLocaleString()}

: null}
82 | 83 |
84 |
85 |
86 |

Market Cap

87 | {coin.market_data?.market_cap ?

${coin.market_data.market_cap.usd.toLocaleString()}

: null} 88 |
89 |
90 |

Circulating Supply

91 | {coin.market_data ?

{coin.market_data.circulating_supply}

: null} 92 |
93 | 94 |
95 |
96 |
97 | 98 |
99 |
100 |

About

101 |

104 | 105 |

106 | 107 |
108 |
109 | 110 |
111 |
112 | ) 113 | } 114 | 115 | export default Coin 116 | --------------------------------------------------------------------------------