Skip to content

Instantly share code, notes, and snippets.

View rollendxavier's full-sized avatar

Rollend Xavier rollendxavier

View GitHub Profile
@rollendxavier
rollendxavier / renderomponent.js
Last active March 11, 2024 03:27
Price Tracker - Rendering the Component
return (
<div className="App">
<header className="App-header">
<NewsTicker />
<h1>Crypto Dashboard</h1>
{loading ? (
<p>Loading...</p>
) : (
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center', width: '100%', height: '100vh' }}>
<div style={{ display: 'flex', flexDirection: 'row', justifyContent: 'space-between', width: '100%', height: '100%' }}>
@rollendxavier
rollendxavier / app.css
Last active March 11, 2024 03:27
Price Tracker - app.css
body {
font-family: Arial, sans-serif;
}
.App {
text-align: center;
}
.App-header {
background-color: #ffffff;
@rollendxavier
rollendxavier / News.js
Last active September 7, 2025 02:50
Price Tracker - News.js
import React, { useEffect, useState } from 'react';
import axios from 'axios';
import Marquee from 'react-marquee-slider';
function NewsTicker() {
const [news, setNews] = useState([]);
const [isLoading, setIsLoading] = useState(true);
const [error, setError] = useState(null);
useEffect(() => {
@rollendxavier
rollendxavier / handleCoinSelect.js
Last active March 11, 2024 03:27
Price Tracker - Handling Coin Selection
const handleCoinSelect = (id) => {
setLoading(true);
const selected = coins.find(coin => coin.id === id);
setSelectedCoin(selected);
// Fetch historical data for the selected date range
const promises = [];
const date = new Date(startDate);
while (date <= endDate) {
const formattedDate = `${date.getDate()}-${date.getMonth() + 1}-${date.getFullYear()}`;
@rollendxavier
rollendxavier / fetchingthecoindata.js
Last active March 11, 2024 03:26
Price Tracker Fetching the Coin Data
const COLORS = ['#0088FE', '#00C49F', '#FFBB28', '#FF8042']; // add more colors if you have more coins
useEffect(() => {
axios.get(`https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=${holdings.map(holding => holding.id).join(',')}`, {
headers: {
'X-CoinAPI-Key': api_key
}
})
.then(response => {
const updatedHoldings = holdings.map(holding => {
@rollendxavier
rollendxavier / Appconstanst.js
Last active March 11, 2024 03:26
Price Tracker Appconstanst.js
function App() {
const [coins, setCoins] = useState([]);
const [selectedCoin, setSelectedCoin] = useState(null);
const [history, setHistory] = useState([]);
const [loading, setLoading] = useState(true);
const [startDate, setStartDate] = useState(new Date());
const [endDate, setEndDate] = useState(new Date());
const api_key = 'YOUR_API_KEY'; // replace this with your own API key
const holdings = useMemo(() => holdingsData, []);
@rollendxavier
rollendxavier / CoinDetails.js
Last active March 11, 2024 03:26
Price Tracker CoinDetails,js
function CoinDetails({ coin, history }) {
// Prepare the data for the line chart
const chartData = history.map(dataPoint => ({ date: new Date(dataPoint[0]).toDateString(), price: dataPoint[1] }));
const priceChangeColor = coin.price_change_24h < 0 ? 'red' : 'green';
return (
<div className="coin-details">
<h2>{coin.name} ({coin.symbol.toUpperCase()})</h2>
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-start', width: '100%' }}>
<span style={{ color: priceChangeColor, fontSize: '0.8em' }}>
@rollendxavier
rollendxavier / import.js
Last active March 11, 2024 03:26
Price Tracker import.js
import React, { useState, useEffect, useMemo } from 'react';
import axios from 'axios';
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, PieChart, Pie, Cell, ResponsiveContainer } from 'recharts';
import DatePicker from 'react-datepicker';
import NewsTicker from './components/News'; // Import the News components
import 'react-datepicker/dist/react-datepicker.css';
import './App.css'; // Import the CSS
@rollendxavier
rollendxavier / App.css
Last active March 11, 2024 03:19
Price Tracker css
body {
font-family: Arial, sans-serif;
}
.App {
text-align: center;
}
.App-header {
background-color: #ffffff;
@rollendxavier
rollendxavier / App.js
Last active March 7, 2024 14:44
Crypto Porfilio Tracker | CoinGecko | React
import React, { useState, useEffect, useMemo } from 'react';
import axios from 'axios';
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, PieChart, Pie, Cell, ResponsiveContainer } from 'recharts';
import DatePicker from 'react-datepicker';
import 'react-datepicker/dist/react-datepicker.css';
import './App.css'; // Import the CSS
import NewsTicker from './components/News'; // Import the News components
function CoinDetails({ coin, history }) {
// Prepare the data for the line chart