New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat/timeline-chart #7
Conversation
…oin. Added formating for XAxis on chart based on selected timeline. Added diferent colors for charts
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
src/app/components/CoinChart.tsx
Outdated
const formatDateGraphs = (tick: string): string => { | ||
const date = new Date(tick); | ||
let formattedDate: string; | ||
|
||
if (days === "1") { | ||
formattedDate = date.toLocaleTimeString(undefined, { | ||
hour: "2-digit", | ||
minute: "2-digit", | ||
hour12: false, | ||
}); | ||
} else if (["7", "14", "30"].includes(days)) { | ||
formattedDate = date.toLocaleDateString(undefined, { | ||
day: "numeric", | ||
month: "short", | ||
}); | ||
} else if (["90", "180", "365", "max"].includes(days)) { | ||
formattedDate = date.toLocaleDateString(undefined, { | ||
day: "numeric", | ||
month: "short", | ||
year: "numeric", | ||
}); | ||
} else { | ||
formattedDate = date.toLocaleDateString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be moved to a utility file from where you can export formatDateGraphs function because it does not depend on a state, it is a pure JS function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good one. It makes sense to move it to utility folder as separate function. It makes code so much cleaner. Doing it right now.
src/app/page.tsx
Outdated
<div className="mt-10 max-w-[1440px] mx-auto xl:px-[72px] lg:px-[36px] md:px-[24px]"> | ||
<Timeline /> | ||
</div> | ||
<div className="mt-10"></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have this empty div?
src/app/components/CoinChart.tsx
Outdated
|
||
setCurrentValue(`${lastValue.toFixed(2)}`); | ||
setCurrentDate(lastDate); | ||
} | ||
}, [selectedCoins, chartType, currencyCode]); | ||
|
||
if (loading === "pending") { | ||
/* if (loading === "pending") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this commented out code?
src/app/components/Timeline.tsx
Outdated
<button | ||
className={`w-14 p-1 ${ | ||
t.active | ||
? "bg-[rgb(120,120,250,0.7)] border border-[#7878FA] shadow-md rounded-md" | ||
: "" | ||
}`} | ||
onClick={() => dispatch(activeTimeline(t.id))} | ||
key={t.id} | ||
> | ||
<span className="dark:text-[#E4E4F0] text-[#181825] text-sm"> | ||
{t.display} | ||
</span> | ||
</button> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be moved into it's own separate component. What will you name this component?
Based on the selected timeline display chart for price and volume.