Skip to content
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

Sky Upgrade page banner update #4033

Merged
merged 3 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 61 additions & 34 deletions components/ActionBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ interface ActionBannerWithImage {
icon?: never
image?: string
}
type CtaType = {
label: string
onClick?: () => void
targetBlank?: boolean
url?: string
}
marcinciarka marked this conversation as resolved.
Show resolved Hide resolved

export type ActionBannerType = {
closingSaveKey?: string
cta?: {
label: string
onClick?: () => void
targetBlank?: boolean
url?: string
}
cta?: CtaType | CtaType[]
sx?: ThemeUIStyleObject
title: string
withClose?: boolean
Expand All @@ -38,6 +39,59 @@ function getSessionStorageKey(suffix: string): string {
return `action-banner-${kebabCase(suffix)}`
}

const CtaComponent = ({
cta,
customCtaVariant,
lightText,
}: {
cta: ActionBannerProps['cta']
customCtaVariant: ActionBannerProps['customCtaVariant']
lightText: ActionBannerProps['lightText']
}) => {
if (Array.isArray(cta)) {
return (
<>
{cta.map((ctaItem, index) => (
<CtaComponent
key={`CtaItem_${ctaItem.label}_${ctaItem.url}_${index}`}
cta={ctaItem}
lightText={lightText}
customCtaVariant={customCtaVariant}
/>
))}
</>
)
}
return cta ? (
<Box sx={{ flexShrink: 0, ml: 'auto' }}>
{cta.url ? (
<AppLink
href={cta.url}
internalInNewTab={cta.targetBlank}
{...(cta.onClick && { onClick: cta.onClick })}
>
<Button
variant={customCtaVariant ?? 'action'}
sx={{ color: lightText ? 'neutral10' : undefined }}
>
{cta.label}
</Button>
</AppLink>
) : (
cta.onClick && (
<Button
variant={customCtaVariant ?? 'action'}
sx={{ color: lightText ? 'neutral10' : undefined }}
onClick={cta.onClick}
>
{cta.label}
</Button>
)
marcinciarka marked this conversation as resolved.
Show resolved Hide resolved
)}
</Box>
) : null
}

export function ActionBanner({
closingSaveKey,
children,
Expand Down Expand Up @@ -87,34 +141,7 @@ export function ActionBanner({
</Text>
)}
</Flex>
{cta && (
<Box sx={{ flexShrink: 0, ml: 'auto' }}>
{cta.url ? (
<AppLink
href={cta.url}
internalInNewTab={cta.targetBlank}
{...(cta.onClick && { onClick: cta.onClick })}
>
<Button
variant={customCtaVariant ?? 'action'}
sx={{ color: lightText ? 'neutral10' : undefined }}
>
{cta.label}
</Button>
</AppLink>
) : (
cta.onClick && (
<Button
variant={customCtaVariant ?? 'action'}
sx={{ color: lightText ? 'neutral10' : undefined }}
onClick={cta.onClick}
>
{cta.label}
</Button>
)
)}
</Box>
)}
{cta && <CtaComponent cta={cta} lightText={lightText} customCtaVariant={customCtaVariant} />}
{withClose && (
<Button
variant="unStyled"
Expand Down
19 changes: 13 additions & 6 deletions pages/[networkOrProduct]/sky/upgrade.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,19 @@ function SkySwapWrapper() {
<>
{balancesData?.[0] && balancesData[0].isGreaterThan(zero) && (
<ActionBanner
title={`You have ${formatAsShorthandNumbers(balancesData[0])} USDS ready to be staked`}
title={`You have ${formatAsShorthandNumbers(balancesData[0])} USDS that can earn SKY or Chronicle Points`}
lightText
customCtaVariant="outlineSmall"
cta={{
label: 'Stake now',
url: `/earn/srr/${wallet?.accounts[0].address}`,
}}
cta={[
{
label: 'Get SKY Rewards',
url: `/earn/srr/${wallet?.accounts[0].address}`,
},
{
label: 'Earn Chronicle Points',
url: `/earn/cle/${wallet?.accounts[0].address}`,
},
]}
sx={{
backgroundImage: `url(${staticFilesRuntimeUrl('/static/img/sky-banner-background.png')})`,
backgroundSize: 'cover',
Expand All @@ -92,7 +98,8 @@ function SkySwapWrapper() {
my: 4,
}}
>
Stake your USDS in the Sky Ecosystem to earn SKY rewards.
Deposit you USDS in the SKY Ecosystem to earn Chronicle Points or SKY Rewards. Withdraw
anytime.
</ActionBanner>
)}
<Grid gap={3} columns={[1, 3]} mt={[1, 3]}>
Expand Down
Loading