-
Notifications
You must be signed in to change notification settings - Fork 2
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(home): products section #10
Merged
Merged
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
88d3a77
feat: partners carousel
dohaki b280395
fixup
dohaki d13627d
feat(home): hero section
dohaki e105d81
refactor: cleaner file structure
dohaki 8492292
fix: formatting
dohaki 17dcd1e
fixup
dohaki 16830da
fixup
dohaki d8398a9
feat: add reusable text component
dohaki f0793ad
rename carousel to ticker
dohaki 6ff0e0e
fix: format
dohaki 92d93d0
Merge remote-tracking branch 'origin/partners-carousel' into home-her…
dohaki 009be47
feat(home): technology section
dohaki 737c41d
fixup
dohaki 37f4e3d
fixup
dohaki 0ff6237
feat(home): stats section
dohaki 5526fde
fixup
dohaki 353c9ae
fixup
dohaki a18c51b
fix: hero image size
dohaki 4d77e3c
Merge branch 'master' into home-stats-section
dohaki b3e352b
refine revalidation of stats
dohaki 64b9baa
remove catch
dohaki 7eb18ed
fixup
dohaki 15c2f9c
feat(home): products section
dohaki c810cd6
Merge branch 'master' into home-products-section
dohaki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
import { twMerge } from "tailwind-merge"; | ||
import Link from "next/link"; | ||
|
||
import { | ||
BridgeIcon, | ||
PlusIcon, | ||
CheckmarkSimpleIcon, | ||
ArrowUpRightIcon, | ||
} from "../../_components/icons"; | ||
import { Text } from "../../_components/text"; | ||
import { PRODUCT_LINKS } from "../../_constants/links"; | ||
|
||
const products = [ | ||
{ | ||
...PRODUCT_LINKS.bridge, | ||
Icon: BridgeIcon, | ||
iconClassName: "group-hover:drop-shadow-aqua h-6 w-6", | ||
iconContainerClassName: "bg-aqua-100/[.05]", | ||
arrowIconClassName: "stroke-aqua-100", | ||
containerClassName: [ | ||
"bg-gradient-to-r from-aqua-100/[.05] to-transparent", | ||
"md:group-hover:bg-gradient-to-r md:group-hover:from-aqua-100/[.05] md:group-hover:to-transparent", | ||
], | ||
}, | ||
{ | ||
...PRODUCT_LINKS.plus, | ||
Icon: PlusIcon, | ||
iconClassName: "group-hover:drop-shadow-teal h-7 w-7", | ||
iconContainerClassName: "bg-teal-100/[.05]", | ||
arrowIconClassName: "stroke-teal-100", | ||
containerClassName: [ | ||
"bg-gradient-to-r from-teal-100/[.05] to-transparent", | ||
"md:group-hover:bg-gradient-to-r md:group-hover:from-teal-100/[.05] md:group-hover:to-transparent", | ||
], | ||
}, | ||
{ | ||
...PRODUCT_LINKS.settlement, | ||
Icon: CheckmarkSimpleIcon, | ||
iconClassName: "group-hover:drop-shadow-purple h-6 w-7", | ||
iconContainerClassName: "bg-purple-100/[.05]", | ||
arrowIconClassName: "stroke-purple-100", | ||
containerClassName: [ | ||
"bg-gradient-to-r from-purple-100/[.05] to-transparent", | ||
"md:group-hover:bg-gradient-to-r md:group-hover:from-purple-100/[.05] md:group-hover:to-transparent", | ||
], | ||
}, | ||
]; | ||
|
||
export function ProductsSection() { | ||
return ( | ||
<section className="container mx-auto mb-12 flex flex-col gap-16 px-4 sm:gap-24 md:mb-24"> | ||
<div className="flex flex-col gap-3 sm:gap-4"> | ||
<Text variant="cap-case" className="text-teal-100"> | ||
Solutions | ||
</Text> | ||
<Text variant="heading-2" className="capitalize text-light-200"> | ||
Across Products | ||
</Text> | ||
<Text variant="body-nums"> | ||
Fastest and lowest-cost bridging for end-users. | ||
<br /> | ||
Streamlined interoperability for developers. | ||
</Text> | ||
</div> | ||
<div className="flex flex-col gap-4 md:flex-row"> | ||
{products.map((product) => ( | ||
<Link key={product.label} href={product.href} className="group flex-1"> | ||
<div | ||
className={twMerge( | ||
"flex flex-col rounded-2xl border border-light-100/[.02] p-5 transition md:h-[336px] md:items-center md:bg-none md:px-6 md:pb-16", | ||
product.containerClassName, | ||
)} | ||
> | ||
<div className="flex w-full flex-row items-center justify-between md:flex-col-reverse"> | ||
<div | ||
className={twMerge( | ||
"flex h-16 w-16 items-center justify-center rounded-lg shadow-sm", | ||
product.iconContainerClassName, | ||
)} | ||
> | ||
<product.Icon className={product.iconClassName} /> | ||
</div> | ||
<div className="md:flex md:h-12 md:w-full md:justify-end"> | ||
<div | ||
className={twMerge( | ||
"flex h-12 w-12 items-center justify-center rounded-lg shadow-sm md:hidden md:self-end md:group-hover:flex", | ||
product.iconContainerClassName, | ||
)} | ||
> | ||
<ArrowUpRightIcon | ||
className={twMerge("", product.arrowIconClassName)} | ||
/> | ||
</div> | ||
</div> | ||
</div> | ||
<Text | ||
variant="heading-4" | ||
className="mb-1 mt-4 text-light-200 md:mb-4 md:mt-8" | ||
> | ||
{product.label} | ||
</Text> | ||
<Text className="text-light-300 md:text-center">{product.description}</Text> | ||
</div> | ||
</Link> | ||
))} | ||
</div> | ||
</section> | ||
); | ||
} |
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,73 @@ | ||
import { Text } from "../../_components/text"; | ||
import { StatBox } from "../../_components/stat-box"; | ||
|
||
import { getProtocolStats } from "../../_lib/scraper"; | ||
import { humanReadableNumber } from "../../_lib/format"; | ||
|
||
async function getFormattedStatsData() { | ||
const protocolStats = await getProtocolStats({ | ||
revalidate: 24 * 60 * 60, // Update once a day | ||
}); | ||
|
||
return { | ||
totalVolumeUsd: `$${humanReadableNumber(protocolStats.totalVolumeUsd)}`, | ||
totalDeposits: `${humanReadableNumber(protocolStats.totalDeposits)}`, | ||
avgFillTimeInMinutes: `${protocolStats.avgFillTimeInMinutes < 1 ? "<" : ""} ${Math.max( | ||
protocolStats.avgFillTimeInMinutes, | ||
1, | ||
)}m`, | ||
bridgeFee: "<$1", | ||
}; | ||
} | ||
|
||
export async function StatsSection() { | ||
const formattedStatsData = await getFormattedStatsData(); | ||
return ( | ||
<section className="container mx-auto flex flex-col gap-10 px-4 sm:gap-16"> | ||
<div className="flex flex-col items-center gap-4"> | ||
<Text variant="cap-case" className="text-aqua-100 md:text-center"> | ||
power in originality | ||
</Text> | ||
<Text variant="heading-2" className="text-center capitalize text-light-200"> | ||
Production ready <br /> | ||
Empirically Proven | ||
</Text> | ||
<Text className="max-w-xl text-center"> | ||
Across is the only cross-chain intents protocol in production today, enabling | ||
the fastest and lowest-cost interoperability solution without security | ||
tradeoffs. | ||
</Text> | ||
</div> | ||
<div className="grid grid-cols-2 gap-3 sm:grid-cols-4"> | ||
<StatBox | ||
title="volume" | ||
value={formattedStatsData.totalVolumeUsd} | ||
titleClassName="text-teal-100" | ||
className="group-hover:border-teal-100" | ||
dividerClassName="group-hover:bg-teal-100/[.5]" | ||
/> | ||
<StatBox | ||
title="transaction" | ||
value={formattedStatsData.totalDeposits} | ||
titleClassName="text-orange-100" | ||
className="group-hover:border-orange-100" | ||
dividerClassName="group-hover:bg-orange-100/[.5]" | ||
/> | ||
<StatBox | ||
title="avg. fill time" | ||
value={formattedStatsData.avgFillTimeInMinutes} | ||
titleClassName="text-purple-100" | ||
className="group-hover:border-purple-100" | ||
dividerClassName="group-hover:bg-purple-100/[.5]" | ||
/> | ||
<StatBox | ||
title="bridge 1 eth" | ||
value={formattedStatsData.bridgeFee} | ||
titleClassName="text-aqua-100" | ||
className="group-hover:border-aqua-100" | ||
dividerClassName="group-hover:bg-aqua-100/[.5]" | ||
/> | ||
</div> | ||
</section> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { SVGProps } from "react"; | ||
|
||
export function ArrowUpRightIcon(props: SVGProps<SVGSVGElement>) { | ||
return ( | ||
<svg | ||
width="40" | ||
height="41" | ||
viewBox="0 0 40 41" | ||
fill="none" | ||
xmlns="http://www.w3.org/2000/svg" | ||
{...props} | ||
> | ||
<path | ||
d="M14.168 26.7048L25.8346 15.0382" | ||
strokeWidth="1.5" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
/> | ||
<path | ||
d="M14.168 15.0349H25.8346V26.7016" | ||
strokeWidth="1.5" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
/> | ||
</svg> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { ComponentProps } from "react"; | ||
import { twMerge } from "tailwind-merge"; | ||
|
||
import { Text } from "./text"; | ||
|
||
type Props = ComponentProps<"div"> & { | ||
title: string; | ||
titleClassName: string; | ||
value: string; | ||
dividerClassName?: string; | ||
}; | ||
|
||
export function StatBox({ | ||
className, | ||
title, | ||
titleClassName, | ||
value, | ||
dividerClassName, | ||
...props | ||
}: Props) { | ||
return ( | ||
<div className="group"> | ||
<div | ||
className={twMerge( | ||
"group flex flex-col rounded-2xl border border-light-100/[.02] px-4 pb-6 transition sm:pb-10", | ||
className, | ||
)} | ||
{...props} | ||
> | ||
<div | ||
className={twMerge( | ||
"mb-6 h-1 w-11 self-center rounded-b-[12px] rounded-t-none bg-grey-600 sm:mb-10", | ||
dividerClassName, | ||
)} | ||
/> | ||
<Text variant="cap-case" className={twMerge("mb-2 text-center", titleClassName)}> | ||
{title} | ||
</Text> | ||
<Text variant="heading-3" className="text-center"> | ||
{value} | ||
</Text> | ||
</div> | ||
</div> | ||
); | ||
} |
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,15 @@ | ||
import numeral from "numeral"; | ||
|
||
/** | ||
* Formats a number into a human readable format | ||
* @param num The number to format | ||
* @returns A human readable format. I.e. 1000 -> 1K, 1001 -> 1K+ | ||
*/ | ||
export function humanReadableNumber(num: number, decimals = 0): string { | ||
if (num <= 0) return "0"; | ||
return ( | ||
numeral(num) | ||
.format(decimals <= 0 ? "0a" : `0.${"0".repeat(decimals)}a`) | ||
.toUpperCase() + "+" | ||
); | ||
} |
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,31 @@ | ||
type ProtocolStatsResponse = { | ||
totalDeposits: number; | ||
avgFillTime: number; | ||
totalVolumeUsd: number; | ||
}; | ||
|
||
type ProtocolStatsFormatted = ProtocolStatsResponse & { | ||
avgFillTimeInMinutes: number; | ||
}; | ||
|
||
export async function getProtocolStats( | ||
nextFetchRequestConfig?: NextFetchRequestConfig, | ||
): Promise<ProtocolStatsFormatted> { | ||
const response = await fetch(`https://public.api.across.to/deposits/stats`, { | ||
next: nextFetchRequestConfig, | ||
}); | ||
if (!response.ok) { | ||
throw new Error( | ||
`Failed to fetch protocol stats: ${response.status} ${response.statusText}`, | ||
); | ||
} | ||
const data = await response.json(); | ||
return formatResult(data); | ||
} | ||
|
||
function formatResult(data: ProtocolStatsResponse) { | ||
return { | ||
...data, | ||
avgFillTimeInMinutes: Math.floor(data.avgFillTime / 60), | ||
}; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should we add this to our theme?
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.
Yea would make sense 🤔 In Figma, we don't have a name for this though. So using this opacity syntax might actually be better than coming up with some theme variable name. wdyt?