-
Notifications
You must be signed in to change notification settings - Fork 324
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add onView on ContentCard + add VariantB and VariantA functionnality …
…for Portfolio ContentCards
- Loading branch information
Showing
5 changed files
with
75 additions
and
40 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
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
77 changes: 51 additions & 26 deletions
77
apps/ledger-live-desktop/src/renderer/screens/dashboard/PortfolioContentCards.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 |
---|---|---|
@@ -1,50 +1,75 @@ | ||
import { useFeature } from "@ledgerhq/live-common/featureFlags/index"; | ||
import { Carousel } from "@ledgerhq/react-ui"; | ||
import { ABTestingVariants } from "@ledgerhq/types-live"; | ||
import React from "react"; | ||
import React, { PropsWithChildren } from "react"; | ||
import { useSelector } from "react-redux"; | ||
import { useTheme } from "styled-components"; | ||
import styled from "styled-components"; | ||
import { useRefreshAccountsOrderingEffect } from "~/renderer/actions/general"; | ||
import { Card } from "~/renderer/components/Box"; | ||
import usePortfolioCards from "~/renderer/hooks/usePortfolioCards"; | ||
import { accountsSelector } from "~/renderer/reducers/accounts"; | ||
import { hasInstalledAppsSelector } from "~/renderer/reducers/settings"; | ||
|
||
const PortfolioContentCards = () => { | ||
const theme = useTheme(); | ||
const PortfolioVariantA = styled.div` | ||
background-color: ${p => p.theme.colors.opacityPurple.c10}; | ||
`; | ||
|
||
const PortfolioVariantBContainer = styled.div` | ||
position: relative; | ||
margin-left: 24px; | ||
margin-right: 24px; | ||
`; | ||
|
||
const PortfolioVariantBC = styled.div` | ||
position: absolute; | ||
width: 100%; | ||
bottom: 30px; | ||
zindex: 10000; | ||
backdrop-filter: blur(15px); | ||
border-radius: 8px; | ||
background-color: ${p => p.theme.colors.opacityPurple.c10}; | ||
`; | ||
|
||
const PortfolioVariantB = ({ children }: PropsWithChildren) => ( | ||
<PortfolioVariantBContainer> | ||
<PortfolioVariantBC>{children}</PortfolioVariantBC> | ||
</PortfolioVariantBContainer> | ||
); | ||
|
||
const PortfolioContentCards = ({ variant }: { variant: ABTestingVariants }) => { | ||
const slides = usePortfolioCards(); | ||
const lldPortfolioCarousel = useFeature("lldPortfolioCarousel"); | ||
const accounts = useSelector(accountsSelector); | ||
const hasInstalledApps = useSelector(hasInstalledAppsSelector); | ||
const totalAccounts = accounts.length; | ||
|
||
const showCarousel = hasInstalledApps && totalAccounts >= 0; | ||
const showCarousel = lldPortfolioCarousel?.enabled && hasInstalledApps && totalAccounts >= 0; | ||
useRefreshAccountsOrderingEffect({ | ||
onMount: true, | ||
}); | ||
|
||
return showCarousel && lldPortfolioCarousel?.enabled ? ( | ||
lldPortfolioCarousel?.params?.variant === ABTestingVariants.variantA ? ( | ||
<Card style={{ backgroundColor: theme.colors.opacityPurple.c10 }}> | ||
if (!showCarousel) return null; | ||
|
||
if ( | ||
lldPortfolioCarousel?.params?.variant === ABTestingVariants.variantA && | ||
variant === ABTestingVariants.variantA | ||
) | ||
return ( | ||
<PortfolioVariantA> | ||
<Carousel variant="content-card" children={slides} /> | ||
Check failure on line 58 in apps/ledger-live-desktop/src/renderer/screens/dashboard/PortfolioContentCards.tsx live-github-bot / @Desktop • Test Appreact/no-children-prop
|
||
</Card> | ||
) : ( | ||
<div | ||
style={{ | ||
position: "fixed", | ||
bottom: "30px", | ||
left: "20px", | ||
width: "97.5%", | ||
zIndex: 10000, | ||
backdropFilter: "blur(15px)", | ||
borderRadius: "8px", | ||
backgroundColor: theme.colors.opacityPurple.c10, | ||
}} | ||
> | ||
</PortfolioVariantA> | ||
); | ||
|
||
if ( | ||
lldPortfolioCarousel?.params?.variant === ABTestingVariants.variantB && | ||
variant === ABTestingVariants.variantB | ||
) | ||
return ( | ||
<PortfolioVariantB> | ||
<Carousel variant="content-card" children={slides} /> | ||
Check failure on line 68 in apps/ledger-live-desktop/src/renderer/screens/dashboard/PortfolioContentCards.tsx live-github-bot / @Desktop • Test Appreact/no-children-prop
|
||
</div> | ||
) | ||
) : null; | ||
</PortfolioVariantB> | ||
); | ||
|
||
return null; | ||
}; | ||
|
||
export default PortfolioContentCards; |
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