Skip to content

Commit c1eb865

Browse files
authored
Refactor XpDropClaimBanner (#668)
* Refactor XpDropClaimBanner * Rename XpDropClaimBanner -> XpDropBanner
1 parent 879e855 commit c1eb865

File tree

5 files changed

+66
-76
lines changed

5 files changed

+66
-76
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import React from 'react';
2+
import DropIcon from 'jsx:src/ui/assets/drop.svg';
3+
import { HStack } from 'src/ui/ui-kit/HStack';
4+
import { GradientBorder } from 'src/ui/components/GradientBorder';
5+
import { UIText } from 'src/ui/ui-kit/UIText';
6+
import { Button } from 'src/ui/ui-kit/Button';
7+
import { UnstyledLink } from 'src/ui/ui-kit/UnstyledLink';
8+
import { emitter } from 'src/ui/shared/events';
9+
import { useLocation } from 'react-router-dom';
10+
import { useWalletsMetaByChunks } from 'src/ui/shared/requests/useWalletsMetaByChunks';
11+
import { FEATURE_LOYALTY_FLOW } from 'src/env/config';
12+
13+
const bannerGradient = 'linear-gradient(90deg, #a024ef 0%, #fdbb6c 100%)';
14+
15+
export function XpDropBanner({ address }: { address: string }) {
16+
const { pathname } = useLocation();
17+
const { data: walletsMeta } = useWalletsMetaByChunks({
18+
addresses: [address],
19+
suspense: false,
20+
});
21+
22+
const walletMeta = walletsMeta?.[0];
23+
const isVisible =
24+
FEATURE_LOYALTY_FLOW === 'on' && Boolean(walletMeta?.membership.retro);
25+
26+
return isVisible ? (
27+
<div style={{ paddingInline: 16 }}>
28+
<GradientBorder
29+
borderColor={bannerGradient}
30+
borderWidth={2}
31+
borderRadius={16}
32+
backgroundColor="var(--white)"
33+
>
34+
<HStack gap={8} justifyContent="space-between" style={{ padding: 8 }}>
35+
<HStack gap={8} alignItems="center" justifyContent="center">
36+
<DropIcon style={{ marginLeft: 8 }} />
37+
<UIText kind="small/accent">Claim Your XP & Level</UIText>
38+
</HStack>
39+
<Button
40+
kind="ghost"
41+
size={36}
42+
as={UnstyledLink}
43+
to="/xp-drop/onboarding"
44+
onClick={() => {
45+
emitter.emit('buttonClicked', {
46+
buttonScope: 'Loaylty',
47+
buttonName: 'Claim XP',
48+
pathname,
49+
});
50+
}}
51+
style={{
52+
minWidth: 109,
53+
background: bannerGradient,
54+
color: 'var(--always-white)',
55+
}}
56+
>
57+
Claim
58+
</Button>
59+
</HStack>
60+
</GradientBorder>
61+
</div>
62+
) : null;
63+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { XpDropBanner } from './XpDropBanner';

src/ui/features/xp-drop/components/XpDropClaimBanner/XpDropClaimBanner.tsx

Lines changed: 0 additions & 51 deletions
This file was deleted.

src/ui/features/xp-drop/components/XpDropClaimBanner/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/ui/pages/Overview/Overview.tsx

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,12 @@ import { useEvent } from 'src/ui/shared/useEvent';
6161
import { useWalletPortfolio } from 'src/modules/zerion-api/hooks/useWalletPortfolio';
6262
import { useHttpClientSource } from 'src/modules/zerion-api/hooks/useHttpClientSource';
6363
import { SidepanelOptionsButton } from 'src/shared/sidepanel/SidepanelOptionsButton';
64-
import { XpDropClaimBanner } from 'src/ui/features/xp-drop/components/XpDropClaimBanner';
64+
import { XpDropBanner } from 'src/ui/features/xp-drop/components/XpDropBanner';
6565
import { UnstyledAnchor } from 'src/ui/ui-kit/UnstyledAnchor';
6666
import { useWalletParams } from 'src/ui/shared/requests/useWalletParams';
6767
import { FEATURE_LOYALTY_FLOW } from 'src/env/config';
6868
import { useRemoteConfigValue } from 'src/modules/remote-config/useRemoteConfigValue';
6969
import type { ExternallyOwnedAccount } from 'src/shared/types/ExternallyOwnedAccount';
70-
import { useWalletsMetaByChunks } from 'src/ui/shared/requests/useWalletsMetaByChunks';
7170
import { emitter } from 'src/ui/shared/events';
7271
import { HistoryList } from '../History/History';
7372
import { SettingsLinkIcon } from '../Settings/SettingsLinkIcon';
@@ -364,27 +363,6 @@ function ReadonlyMode() {
364363
);
365364
}
366365

367-
function XpBannerComponent({ address }: { address: string }) {
368-
const { data: walletsMeta } = useWalletsMetaByChunks({
369-
addresses: [address],
370-
suspense: false,
371-
});
372-
373-
const walletMeta = walletsMeta?.[0];
374-
const claimXpBannerVisible =
375-
FEATURE_LOYALTY_FLOW === 'on' && Boolean(walletMeta?.membership.retro);
376-
377-
if (claimXpBannerVisible) {
378-
return (
379-
<div style={{ paddingInline: 16 }}>
380-
<XpDropClaimBanner />
381-
</div>
382-
);
383-
} else {
384-
return null;
385-
}
386-
}
387-
388366
function OverviewComponent() {
389367
useBodyStyle(
390368
useMemo(() => ({ ['--background' as string]: 'var(--z-index-0)' }), [])
@@ -758,7 +736,7 @@ function OverviewComponent() {
758736
>
759737
<VStack gap={20}>
760738
{!isReadonlyGroup && loyaltyEnabled ? (
761-
<XpBannerComponent address={params.address} />
739+
<XpDropBanner address={params.address} />
762740
) : null}
763741
<Positions
764742
dappChain={dappChain || null}

0 commit comments

Comments
 (0)