-
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
1 parent
c25d287
commit 0ef9781
Showing
10 changed files
with
215 additions
and
6 deletions.
There are no files selected for viewing
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
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
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
156 changes: 156 additions & 0 deletions
156
packages/frontend/src/mobile-components/feed/GasCard.tsx
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,156 @@ | ||
import { FC } from "react"; | ||
import { Arrow, twMerge } from "@alphaday/ui-kit"; | ||
import { TSuperfeedItem } from "src/api/types"; | ||
import GasPriceBox from "src/components/gas/GasPriceBox"; | ||
import { computeDuration } from "src/utils/dateUtils"; | ||
import { imgOnError } from "src/utils/errorHandling"; | ||
import { | ||
ActionButtons, | ||
CardTitle, | ||
FeedItemDisclosure, | ||
FeedItemDisclosureButton, | ||
FeedItemDisclosureButtonImage, | ||
FeedItemDisclosurePanel, | ||
TagButtons, | ||
getFeedItemIcon, | ||
} from "./FeedElements"; | ||
|
||
export const GasCard: FC<{ | ||
item: TSuperfeedItem; | ||
isAuthenticated: boolean; | ||
onLike: () => MaybeAsync<void>; | ||
onShare: () => MaybeAsync<void>; | ||
}> = ({ item, onLike, onShare, isAuthenticated }) => { | ||
const { | ||
tags, | ||
likes, | ||
comments, | ||
title, | ||
type, | ||
date, | ||
sourceIcon, | ||
data: gasData, | ||
} = item; | ||
|
||
const isDown = gasData?.gasPercentChange && gasData.gasPercentChange < 0; | ||
|
||
return ( | ||
<FeedItemDisclosure> | ||
{({ open }) => ( | ||
<> | ||
<FeedItemDisclosureButton> | ||
<div className="flex flex-col w-full"> | ||
<div className="flex justify-between"> | ||
<div className="flex flex-col"> | ||
<div className="flex items-center"> | ||
<FeedItemDisclosureButtonImage | ||
icon={getFeedItemIcon(type)} | ||
/> | ||
<p className="text-primaryVariant100 fontGroup-mini leading-[18px] flex flex-wrap whitespace-nowrap"> | ||
{computeDuration(date)} | ||
<span className="mx-1 my-0 self-center"> | ||
• | ||
</span>{" "} | ||
<span> | ||
<img | ||
src={sourceIcon} | ||
alt="" | ||
className="w-3.5 h-3.5 mr-[5px] rounded-full inline-flex ml-1.5" | ||
onError={imgOnError} | ||
/> | ||
</span> | ||
</p> | ||
</div> | ||
<CardTitle title={title || ""} /> | ||
<p className="mt-4"> | ||
Gas Fees are {isDown ? "down" : "up"}{" "} | ||
{isDown ? ( | ||
<Arrow | ||
className="h-2.5" | ||
direction="down" | ||
/> | ||
) : ( | ||
<Arrow | ||
className="h-2.5" | ||
direction="up" | ||
/> | ||
)}{" "} | ||
{gasData?.gasPercentChange}% | ||
</p> | ||
</div> | ||
<div className="flex-col min-w-max mr-9"> | ||
<div | ||
className={twMerge( | ||
"w-full flex justify-end items-start", | ||
open && "hidden" | ||
)} | ||
/> | ||
</div> | ||
</div> | ||
<div className="flex justify-between"> | ||
<div className="flex-col"> | ||
{!open && ( | ||
<TagButtons | ||
truncated | ||
tags={tags} | ||
onClick={() => {}} | ||
/> | ||
)} | ||
</div> | ||
<div className="flex-col min-w-max ml-2"> | ||
{!open && ( | ||
<ActionButtons | ||
onLike={onLike} | ||
onCommentClick={onLike} | ||
onShare={onShare} | ||
likes={likes} | ||
comments={comments} | ||
isAuthenticated={isAuthenticated} | ||
isLiked={item.isLiked} | ||
/> | ||
)} | ||
</div> | ||
</div> | ||
</div> | ||
</FeedItemDisclosureButton> | ||
<FeedItemDisclosurePanel> | ||
<div className="my-2 flex justify-between max-w-sm mx-auto"> | ||
<GasPriceBox | ||
type="slow" | ||
gweiPrice={gasData?.gasSlow} | ||
usdPrice={undefined} | ||
isCard | ||
/> | ||
<GasPriceBox | ||
type="standard" | ||
gweiPrice={gasData?.gasStandard} | ||
usdPrice={undefined} | ||
isCard | ||
/> | ||
<GasPriceBox | ||
type="fast" | ||
gweiPrice={gasData?.gasFast} | ||
usdPrice={undefined} | ||
isCard | ||
/> | ||
</div> | ||
<div className="my-2 flex justify-between"> | ||
<TagButtons tags={tags} onClick={() => {}} /> | ||
<div className="min-w-max ml-2 mt-0.5"> | ||
<ActionButtons | ||
onLike={onLike} | ||
onCommentClick={onLike} | ||
onShare={onShare} | ||
likes={likes} | ||
comments={comments} | ||
isAuthenticated={isAuthenticated} | ||
isLiked={item.isLiked} | ||
/> | ||
</div> | ||
</div> | ||
</FeedItemDisclosurePanel> | ||
</> | ||
)} | ||
</FeedItemDisclosure> | ||
); | ||
}; |
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
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