-
Notifications
You must be signed in to change notification settings - Fork 67
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
Showing
14 changed files
with
430 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { Icon } from 'components/Icon' | ||
import { getGradientColor } from 'helpers/getGradientColor' | ||
import type { FC } from 'react' | ||
import React from 'react' | ||
import { clock_colorful, rays } from 'theme/icons' | ||
import { Flex, Text } from 'theme-ui' | ||
|
||
interface RaysSidebarBannerProps { | ||
title: string | ||
description?: string | ||
list?: string[] | ||
daysLeft?: string | ||
items?: { title: string; action: () => void }[] | ||
} | ||
|
||
export const RaysSidebarBanner: FC<RaysSidebarBannerProps> = ({ | ||
title, | ||
description, | ||
daysLeft, | ||
items, | ||
}) => { | ||
return ( | ||
<Flex sx={{ justifyContent: 'space-between', alignItems: 'center' }}> | ||
<Flex sx={{ flexDirection: 'column', rowGap: 2 }}> | ||
<Text | ||
as="p" | ||
variant="paragraph3" | ||
sx={{ | ||
fontWeight: 'semiBold', | ||
...getGradientColor( | ||
'linear-gradient(270.13deg, #007DA3 0.02%, #E7A77F 56.92%, #E97047 98.44%)', | ||
), | ||
display: 'flex', | ||
alignItems: 'center', | ||
columnGap: 2, | ||
}} | ||
> | ||
<Icon icon={rays} size={24} /> | ||
{title} | ||
</Text> | ||
{description && ( | ||
<Text as="p" variant="paragraph3" color="neutral80" sx={{ mb: 2 }}> | ||
{description} | ||
</Text> | ||
)} | ||
{items && ( | ||
<Flex sx={{ flexWrap: 'wrap', ml: 4, mb: 2 }}> | ||
{items.map((item) => ( | ||
<Text | ||
key={item.title} | ||
as="p" | ||
variant="paragraph3" | ||
onClick={item.action} | ||
sx={{ | ||
fontWeight: 'semiBold', | ||
cursor: 'pointer', | ||
display: 'flex', | ||
width: '50%', | ||
color: 'neutral80', | ||
'&:hover': { | ||
color: 'primary100', | ||
}, | ||
}} | ||
> | ||
{item.title} | ||
</Text> | ||
))} | ||
</Flex> | ||
)} | ||
</Flex> | ||
{daysLeft && ( | ||
<Flex | ||
sx={{ | ||
alignItems: 'center', | ||
backgroundColor: '#F2F3F4', | ||
paddingY: 2, | ||
paddingLeft: 2, | ||
paddingRight: 3, | ||
borderRadius: '100px', | ||
height: 'fit-content', | ||
}} | ||
> | ||
<Text | ||
variant="paragraph3" | ||
sx={{ | ||
fontWeight: 'semiBold', | ||
...getGradientColor( | ||
'linear-gradient(270.13deg, #007DA3 0.02%, #E7A77F 56.92%, #E97047 98.44%)', | ||
), | ||
display: 'flex', | ||
alignItems: 'center', | ||
columnGap: '5px', | ||
}} | ||
> | ||
<Icon icon={clock_colorful} size={21} /> | ||
{daysLeft} days left | ||
</Text> | ||
</Flex> | ||
)} | ||
</Flex> | ||
) | ||
} |
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
8 changes: 8 additions & 0 deletions
8
features/omni-kit/automation/helpers/getNumberOfActiveTriggers.ts
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,8 @@ | ||
import type { AutomationMetadataFlags } from 'features/omni-kit/types' | ||
import { countBooleanValues } from 'helpers/countBooleanValues' | ||
|
||
export const getNumberOfActiveTriggers = ({ flags }: { flags: AutomationMetadataFlags }) => { | ||
const { trueCount } = countBooleanValues(flags) | ||
|
||
return trueCount | ||
} |
38 changes: 38 additions & 0 deletions
38
features/omni-kit/automation/helpers/getOmniAutomationSidebarRaysBanner.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,38 @@ | ||
import { RaysSidebarBanner } from 'components/RaysSidebarBanner' | ||
import { TriggerAction } from 'helpers/lambda/triggers' | ||
import { useTranslation } from 'next-i18next' | ||
import React from 'react' | ||
|
||
export const getOmniAutomationSidebarRaysBanner = ({ | ||
activeTriggersNumber, | ||
action, | ||
}: { | ||
activeTriggersNumber: number | ||
action: TriggerAction | ||
}) => { | ||
const { t } = useTranslation() | ||
|
||
if (activeTriggersNumber === 0) { | ||
return ( | ||
<RaysSidebarBanner | ||
title={t('rays.sidebar.banner.boost.title', { rays: '12345' })} | ||
description={t('rays.sidebar.banner.boost.description')} | ||
/> | ||
) | ||
} | ||
|
||
if ([TriggerAction.Add, TriggerAction.Update].includes(action)) { | ||
return <RaysSidebarBanner title={t('rays.sidebar.banner.auto-ongoing.title')} /> | ||
} | ||
|
||
if (action === TriggerAction.Remove) { | ||
return ( | ||
<RaysSidebarBanner | ||
title={t('rays.sidebar.banner.reduceAuto.title', { rays: '12345' })} | ||
description={t('rays.sidebar.banner.reduceAuto.description')} | ||
/> | ||
) | ||
} | ||
|
||
return null | ||
} |
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,58 @@ | ||
import { RaysSidebarBanner } from 'components/RaysSidebarBanner' | ||
import { VaultViewMode } from 'components/vault/GeneralManageTabBar.types' | ||
import type { OmniSidebarBorrowPanel, OmniSidebarEarnPanel } from 'features/omni-kit/types' | ||
import { OmniMultiplyPanel } from 'features/omni-kit/types' | ||
import { useHash } from 'helpers/useHash' | ||
import { useTranslation } from 'next-i18next' | ||
import React from 'react' | ||
|
||
export const getOmniSidebarRaysBanner = ({ | ||
isOpening, | ||
uiDropdown, | ||
isSupportingOptimization, | ||
isSupportingProtection, | ||
}: { | ||
isOpening: boolean | ||
uiDropdown: OmniMultiplyPanel | OmniSidebarEarnPanel | OmniSidebarBorrowPanel | ||
isSupportingOptimization: boolean | ||
isSupportingProtection: boolean | ||
}) => { | ||
const [, setHash] = useHash<string>() | ||
const { t } = useTranslation() | ||
|
||
if (isOpening) { | ||
return ( | ||
<RaysSidebarBanner | ||
title={t('rays.sidebar.banner.instant.title', { rays: '12345' })} | ||
description={t('rays.sidebar.banner.instant.description', { raysPerYear: '12345' })} | ||
/> | ||
) | ||
} | ||
|
||
// OmniMultiplyPanel.Close and OmniBorrowPanel.Close are the same | ||
if (uiDropdown === OmniMultiplyPanel.Close) { | ||
return ( | ||
<RaysSidebarBanner | ||
title={t('rays.sidebar.banner.closing.title', { rays: '12345' })} | ||
description={t('rays.sidebar.banner.closing.description', { raysPerYear: '12345' })} | ||
daysLeft="2" | ||
/> | ||
) | ||
} | ||
|
||
if (isSupportingOptimization || isSupportingProtection) { | ||
return ( | ||
<RaysSidebarBanner | ||
title={t('rays.sidebar.banner.boost.title', { rays: '12345' })} | ||
items={[ | ||
{ title: 'Stop Loss →', action: () => setHash(VaultViewMode.Protection) }, | ||
{ title: 'Auto Sell →', action: () => setHash(VaultViewMode.Protection) }, | ||
{ title: 'Take Profit →', action: () => setHash(VaultViewMode.Optimization) }, | ||
{ title: 'Auto Buy →', action: () => setHash(VaultViewMode.Optimization) }, | ||
]} | ||
/> | ||
) | ||
} | ||
|
||
return null | ||
} |
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
Oops, something went wrong.