Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
connorskorburg committed Jun 30, 2022
1 parent 9cdc6ef commit 87be933
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
25 changes: 12 additions & 13 deletions src/components/News/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,26 @@ const News = (): JSX.Element => {
</a>
))
: articles?.map(
({
headline,
source,
url,
summary,
}: DashboardTypes.ArticleItem) => (
(
{
headline,
source,
url,
summary,
image,
}: DashboardTypes.ArticleItem,
idx
) => (
<a
key={headline}
key={idx}
href={url}
className="hover-bg-light bb-1 flex-between py-2"
>
<div className="body-text">
<h4 className="font-bold">{source}</h4>
<p className="py-2">{summary}</p>
</div>
<img
width="130px"
height="74px"
src="https://via.placeholder.com/150/92c952"
alt={headline}
/>
<img width="130px" height="74px" src={image} alt={headline} />
</a>
)
)}
Expand Down
9 changes: 7 additions & 2 deletions src/components/PopularStocks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useEffect, useState } from "react";
import { useStockContext } from "../../context";

const PopularStocks = (): JSX.Element => {
const { fetchPopularStocks, popularStocks } = useStockContext();
const { fetchPopularStocks, popularStocks, updateTicker } = useStockContext();
const [loading, setLoading] = useState<boolean>(false);

useEffect(() => {
Expand Down Expand Up @@ -36,13 +36,18 @@ const PopularStocks = (): JSX.Element => {
companyName,
open,
close,
symbol,
}: DashboardTypes.Stock,
idx
) => {
const isStockGreen = close > open;
return (
idx < 4 && (
<div key={idx} className="card">
<div
key={idx}
className="card"
onClick={() => updateTicker(symbol, companyName)}
>
<h4 className="font-bold h-60">{companyName}</h4>
<h2 className={`text-${isStockGreen ? "green" : "red"}`}>
${latestPrice.toFixed(2)}
Expand Down

0 comments on commit 87be933

Please sign in to comment.