Skip to content

Commit

Permalink
feat(earn): add tier banner on lateral sidebar (#1299)
Browse files Browse the repository at this point in the history
* feat(earn): add tier banner on lateral sidebar

* fixup! feat(earn): add tier banner on lateral sidebar
  • Loading branch information
FiboApe authored Jan 27, 2025
1 parent a4851d2 commit 74ca8ac
Show file tree
Hide file tree
Showing 7 changed files with 571 additions and 13 deletions.
2 changes: 2 additions & 0 deletions apps/root/src/frame/components/navigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import { resetForm as resetAggregatorForm } from '@state/aggregator/actions';
import { resetForm as resetTransferForm } from '@state/transfer/actions';
import { resetDcaForm } from '@state/create-position/actions';
import { fullyResetEarnForm } from '@state/earn-management/actions';
import PromotedTierBanner from './promoted-banners/tier-banner';

const helpOptions = [
{
Expand Down Expand Up @@ -455,6 +456,7 @@ const Navigation = ({ children }: React.PropsWithChildren) => {
type: OptionsMenuOptionType.option,
}))}
onClickBrandLogo={onClickBrandLogo}
promotedBanner={<PromotedTierBanner />}
>
{children}
</NavigationUI>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import React from 'react';
import styled from 'styled-components';
import { colors, ContainerBox, Typography, AnimatedArrowRightIcon } from 'ui-library';
import BackgroundGrid from './background';
import { FormattedMessage } from 'react-intl';
import { useThemeMode } from '@state/config/hooks';
import { changeRoute } from '@state/tabs/actions';
import { TIER_VIEW_ROUTE } from '@constants/routes';
import { useAppDispatch } from '@state/hooks';
import usePushToHistory from '@hooks/usePushToHistory';
import useAnalytics from '@hooks/useAnalytics';

const StyledPromotedBanner = styled(ContainerBox).attrs({ flex: 1, gap: 1, flexDirection: 'column' })`
${({
theme: {
palette: { mode, gradient },
spacing,
},
}) => `
// width: 208px;
// height: 122px;
padding: ${spacing(3)};
cursor: pointer;
position: relative;
border-radius: ${spacing(3)};
border: 1px solid ${colors[mode].accent.primary};
background: ${gradient.earnWizard};
/* dropshadow/100 */
box-shadow: ${colors[mode].dropShadow.dropShadow100};
`}
`;

const StyledGridBg = styled.div`
position: absolute;
left: 0;
right: 0;
bottom: 0;
display: flex;
`;

const StyledStarBg = styled.div`
position: absolute;
top: -13px;
right: -6px;
width: 34px;
height: 34px;
`;

const StlyedDarkStar = styled(StyledStarBg)`
background: url('https://ipfs.io/ipfs/bafkreicxqwgktunpqzqsa5y42w4rrkpun3cd7meqsbxnks6yckncgnvmje') 50% / contain
no-repeat;
`;
const StlyedLightStar = styled(StyledStarBg)`
background: url('https://ipfs.io/ipfs/bafkreih4anauqa24gjlakcpx2mq5ltqiuoqmjts7xcfrpi4b7e4monfzeq') 50% / contain
no-repeat;
`;

const StyledTierPillChevronContainer = styled(ContainerBox).attrs({ alignSelf: 'flex-end' })`
${({
theme: {
palette: { mode },
},
}) => `
color: ${colors[mode].accent.primary};
`}
`;

const PromotedTierBanner = () => {
const [hovered, setHovered] = React.useState(false);
const mode = useThemeMode();
const dispatch = useAppDispatch();
const pushToHistory = usePushToHistory();
const { trackEvent } = useAnalytics();

const onClick = () => {
dispatch(changeRoute(TIER_VIEW_ROUTE.key));
pushToHistory(`/${TIER_VIEW_ROUTE.key}`);
trackEvent('Tier Promoted banner - Go to tier view');
};

return (
<StyledPromotedBanner
onMouseEnter={() => setHovered(true)}
onMouseLeave={() => setHovered(false)}
onClick={onClick}
>
<Typography
variant="labelSemiBold"
color={mode === 'light' ? colors[mode].accent.accent600 : colors[mode].typography.white}
>
<FormattedMessage description="navigation.tier-promoted-banner.title" defaultMessage="Refer friends!" />
</Typography>
<Typography
variant="labelRegular"
color={mode === 'light' ? colors[mode].accent.accent600 : colors[mode].typography.white}
>
<FormattedMessage
description="navigation.tier-promoted-banner.description"
defaultMessage="Refer friends and upgrade your tier level"
/>
</Typography>
{mode === 'light' ? <StlyedLightStar /> : <StlyedDarkStar />}
<StyledTierPillChevronContainer>
<AnimatedArrowRightIcon $hovered={hovered} fontSize="large" />
</StyledTierPillChevronContainer>
<StyledGridBg>
<BackgroundGrid />
</StyledGridBg>
</StyledPromotedBanner>
);
};

export default PromotedTierBanner;
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Navigation, SectionType } from '.';
import type { NavigationProps } from '.';
import { ContainerBox } from '..';
import styled from 'styled-components';
import { colors } from '../../theme/colors';

const StyledContainerBox = styled(ContainerBox)`
width: 990px;
Expand All @@ -19,6 +20,26 @@ function StoryNavigation({ children, ...args }: NavigationProps) {
);
}

const StyledPromotedBanner = styled(ContainerBox).attrs({ flex: 1, gap: 1 })`
${({
theme: {
palette: { mode, gradient },
spacing,
},
}) => `
// width: 208px;
// height: 122px;
padding: ${spacing(3)};
position: relative;
border-radius: ${spacing(3)};
border: 1px solid ${colors[mode].accent.primary};
background: ${gradient.earnWizard};
/* dropshadow/100 */
box-shadow: ${colors[mode].dropShadow.dropShadow100};
`}
`;
// More on how to set up stories at: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
const meta: Meta<typeof StoryNavigation> = {
title: 'Components/Navigation',
Expand Down Expand Up @@ -109,6 +130,7 @@ const meta: Meta<typeof StoryNavigation> = {
},
],
selectedSection: 'inbox',
promotedBanner: <StyledPromotedBanner>Promoted banner</StyledPromotedBanner>,
},
};

Expand Down
34 changes: 21 additions & 13 deletions packages/ui-library/src/components/navigation/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type NavigationProps = React.PropsWithChildren<{
extraHeaderTools?: React.ReactElement;
onClickBrandLogo: () => void;
headerContent?: React.ReactNode;
promotedBanner?: React.ReactNode;
}>;

const drawerWidthLg = 240;
Expand Down Expand Up @@ -117,17 +118,14 @@ const StyledDrawerContainer = styled.div`
flex-direction: column;
`;

const StyledDrawerFooterContainer = styled.div`
const StyledDrawerFooterContainer = styled(ContainerBox).attrs({ gap: 12, flexDirection: 'column' })`
${({
theme: {
space,
palette: { mode },
},
}) => `
display: flex;
margin-bottom: ${space.s05};
justify-content: center;
gap: ${space.s05};
margin-top: auto;
color: ${colors[mode].typography.typo3}
`}
Expand All @@ -140,6 +138,12 @@ const AppBarRightContainer = styled(ContainerBox)`
flex: 1;
`;

const StyledPromotedBannerContainer = styled(ContainerBox).attrs({ justifyContent: 'center' })`
${({ theme: { spacing } }) => `
padding: 0 ${spacing(4)};
`}
`;

const BuiltListItem = ({
section,
isSelected,
Expand Down Expand Up @@ -337,6 +341,7 @@ const Navigation = ({
extraHeaderTools,
onClickBrandLogo,
headerContent,
promotedBanner,
}: NavigationProps) => {
const [mobileOpen, setMobileOpen] = useState(false);
const {
Expand Down Expand Up @@ -367,15 +372,18 @@ const Navigation = ({
{headerContent}
<StyledDrawerLinksContainer>{drawerLinks}</StyledDrawerLinksContainer>
<StyledDrawerFooterContainer>
<Link underline="none" target="_blank" href="https://github.com/balmy-protocol">
<GithubIcon sx={{ color: colors[mode].typography.typo3 }} />
</Link>
<Link underline="none" target="_blank" href="https://twitter.com/balmy_xyz">
<TwitterIcon sx={{ color: colors[mode].typography.typo3 }} />
</Link>
<Link underline="none" target="_blank" href="http://discord.balmy.xyz">
<DiscordIcon sx={{ color: colors[mode].typography.typo3 }} />
</Link>
<StyledPromotedBannerContainer>{promotedBanner}</StyledPromotedBannerContainer>
<ContainerBox gap={5} justifyContent="center" alignItems="center">
<Link underline="none" target="_blank" href="https://github.com/balmy-protocol">
<GithubIcon sx={{ color: colors[mode].typography.typo3 }} />
</Link>
<Link underline="none" target="_blank" href="https://twitter.com/balmy_xyz">
<TwitterIcon sx={{ color: colors[mode].typography.typo3 }} />
</Link>
<Link underline="none" target="_blank" href="http://discord.balmy.xyz">
<DiscordIcon sx={{ color: colors[mode].typography.typo3 }} />
</Link>
</ContainerBox>
</StyledDrawerFooterContainer>
</StyledDrawerContainer>
);
Expand Down
18 changes: 18 additions & 0 deletions packages/ui-library/src/icons/animated-arrow-right.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import styled from 'styled-components';
import { ContainerBox } from '../components';
import { SvgIconProps } from '@mui/material';
import { ArrowRightLightIcon } from '.';

const AnimatedArrowRightLight = styled((props: SvgIconProps) => (
<ContainerBox alignItems="center" flex={1} justifyContent="center">
<ArrowRightLightIcon {...props} sx={{ flex: '1' }} />
</ContainerBox>
))<{ $hovered?: boolean }>`
${({ $hovered, theme: { spacing } }) => `
transition: transform 0.15s ease;
transform: translateX(${$hovered ? spacing(1) : 0});
`}
`;

export default AnimatedArrowRightLight;
2 changes: 2 additions & 0 deletions packages/ui-library/src/icons/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ import OutlookIcon from './outlook';
import SuccessTickIcon from './successTick';
import Money4Icon from './money-4';
import AnimatedChevronRightIcon from './animated-chevron-right';
import AnimatedArrowRightIcon from './animated-arrow-right';
import GlobalIcon from './global';
import ShieldSearchIcon from './shieldSearch';
import GraphIcon from './graphIcon';
Expand Down Expand Up @@ -329,4 +330,5 @@ export {
PenAddIcon,
TagUserIcon,
QrCodeIcon,
AnimatedArrowRightIcon,
};

0 comments on commit 74ca8ac

Please sign in to comment.