-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lld): 🧩 add new portfolio content card component (#8387)
* feat(lld): allow creating button icons with new icons * feat(lld): add the PortfolioContentCard component * feat(lld): add the PortfolioContentCard stories * feat(lld): add a carousel portfolio content cards story * chore(lld): make `PortfolioContentCardProps.image` explicitly optional * chore(lld): rename shortDescription to description As it's a default field on all content cards * chore(lld): export PortfolioContentCard on `@ledgerhq/react-ui` * feat(lld): add an `onChange` prop to the Carousel to track diplayed slides * fix(lld): keep the height of the carousel slides constant * fix(lld): account for the DS being broken on LLD * fix(lld): show pointer cursor everywhere on the cards * feat(lld): force dark close button * chore: update change log * feat(lld): make card description optional * chore(lld): simplify the Carousel stories
- Loading branch information
Showing
8 changed files
with
236 additions
and
25 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,5 @@ | ||
--- | ||
"@ledgerhq/react-ui": minor | ||
--- | ||
|
||
Add new portfolio content card component |
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
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
47 changes: 47 additions & 0 deletions
47
...t/src/components/layout/ContentCard/PortfolioContentCard/PortfolioContentCard.stories.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,47 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import PortfolioContentCard, { PortfolioContentCardProps } from "."; | ||
|
||
export default { | ||
title: "Layout/ContentCard/PortfolioContentCard", | ||
component: PortfolioContentCard, | ||
argTypes: { | ||
title: { | ||
description: "Title of the card.", | ||
}, | ||
cta: { | ||
description: "Call to action text.", | ||
}, | ||
description: { | ||
description: "Description of the card.", | ||
}, | ||
tag: { | ||
description: "Tag to be displayed on top of the card.", | ||
}, | ||
image: { | ||
description: "Image to be displayed on the right of the card.", | ||
}, | ||
onClick: { | ||
description: "Function to be called when the card is clicked.", | ||
}, | ||
onClose: { | ||
description: "Function to be called when the close button is clicked.", | ||
}, | ||
}, | ||
args: { | ||
title: "Ledger Recover", | ||
description: "Get peace of mind and start your free trial.", | ||
cta: "Start my free trial", | ||
image: | ||
"data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='450' height='526' viewBox='0 0 450 526'><defs><linearGradient id='g' x0='0' y0='0' x1='1' y1='1'><stop stop-color='%23000' offset='0%' /><stop stop-color='%23FFF' offset='100%' /></linearGradient></defs><path d='M0,0 H450 V526 Q0,526 0,0 z' fill='url(%23g)' /></svg>", | ||
}, | ||
} satisfies Meta<PortfolioContentCardProps>; | ||
|
||
export const WithCta: StoryObj<PortfolioContentCardProps> = {}; | ||
|
||
export const WithoutCta: StoryObj<PortfolioContentCardProps> = { | ||
args: { cta: undefined }, | ||
}; | ||
|
||
export const WithTag: StoryObj<PortfolioContentCardProps> = { | ||
args: { tag: "New" }, | ||
}; |
106 changes: 106 additions & 0 deletions
106
libs/ui/packages/react/src/components/layout/ContentCard/PortfolioContentCard/index.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,106 @@ | ||
import React, { type ReactEventHandler } from "react"; | ||
import styled from "styled-components"; | ||
|
||
import { StyleProvider } from "../../../../styles"; | ||
import { Icons } from "../../../../assets"; | ||
import { Text } from "../../../asorted"; | ||
import { Button } from "../../../cta"; | ||
import Tag from "../../../Tag"; | ||
|
||
export type PortfolioContentCardProps = { | ||
title: string; | ||
cta?: string; | ||
description?: string; | ||
tag?: string; | ||
image?: string; | ||
|
||
onClick: ReactEventHandler; | ||
onClose: ReactEventHandler; | ||
}; | ||
|
||
export default function PortfolioContentCard({ | ||
title, | ||
cta, | ||
description, | ||
tag, | ||
image, | ||
onClick, | ||
onClose, | ||
}: PortfolioContentCardProps) { | ||
const handleClose: ReactEventHandler = event => { | ||
event.stopPropagation(); | ||
onClose(event); | ||
}; | ||
|
||
return ( | ||
<Wrapper image={image} tag={tag} onClick={onClick}> | ||
{tag && <StyledTag>{tag}</StyledTag>} | ||
<Title>{title}</Title> | ||
{description && <Desc>{description}</Desc>} | ||
{cta && ( | ||
<Button variant="main" outline={false} onClick={onClick}> | ||
{cta} | ||
</Button> | ||
)} | ||
<StyleProvider selectedPalette="dark"> | ||
<CloseButton onClick={handleClose} /> | ||
</StyleProvider> | ||
</Wrapper> | ||
); | ||
} | ||
|
||
const StyledTag = styled(Tag).attrs({ size: "medium", type: "plain", active: true })` | ||
font-size: 11px; | ||
background-color: ${p => p.theme.colors.primary.c80}; | ||
`; | ||
|
||
const Title = styled(Text).attrs({ variant: "h4Inter" })` | ||
font-family: Inter; | ||
font-size: 24px; | ||
font-weight: 600; | ||
`; | ||
|
||
const Desc = styled(Text).attrs({ variant: "small", color: "neutral.c70" })` | ||
font-family: Inter; | ||
font-size: 13px; | ||
font-style: normal; | ||
font-weight: 500; | ||
padding-bottom: 8px; | ||
`; | ||
|
||
const Wrapper = styled.div<Pick<PortfolioContentCardProps, "image" | "tag" | "onClick">>` | ||
background-color: ${p => p.theme.colors.background.card}; | ||
background-image: ${p => (p.image ? `url("${p.image}")` : "none")}; | ||
background-position: right center; | ||
background-repeat: no-repeat; | ||
background-size: 50% auto; | ||
cursor: pointer; | ||
padding: 16px; | ||
padding-top: ${p => (p.tag ? "16px" : "24px")}; | ||
padding-right: 50%; | ||
position: relative; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: flex-end; | ||
align-items: flex-start; | ||
gap: 4px; | ||
`; | ||
|
||
const CloseButton = styled(Button).attrs({ | ||
Icon: <Icons.Close size="XS" />, | ||
iconButton: true, | ||
outline: true, | ||
})` | ||
background-color: ${p => p.theme.colors.neutral.c30}; | ||
position: absolute; | ||
top: 10px; | ||
right: 10px; | ||
width: 24px; | ||
height: 24px; | ||
svg { | ||
width: 12px; | ||
height: 12px; | ||
} | ||
`; |
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