Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(yoga): fix style from PlanCard.ListItem when it is clickable #695

Merged
merged 1 commit into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion packages/doc/content/components/components/card/plancard-web.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,42 @@ Display an extra content before the divider.
</PlanCard.ListItem>
<PlanCard.ListItem
icon={Dumbbell}
text="This content should be truncated"
text="List item with a long text that should be truncated"
/>
<PlanCard.ListItem icon={User} text="4x/month 1-on-1 sessions" />
</PlanCard.List>
</PlanCard.Content>
</PlanCard>
```

#### List item with a clickable content

```javascript
<PlanCard>
<PlanCard.Content
title="Gold"
currency="$"
price="99.90"
period="/mo"
badgeColor="energy"
>
<PlanCard.List>
<PlanCard.ListItem
icon={Dumbbell}
text="List item with a long text that should not be truncated"
truncate={false}
onClick={() => alert('List item clicked!')}
/>
<PlanCard.ListItem
icon={Dumbbell}
text="List item with a long text that should be truncated"
onClick={() => alert('List item clicked!')}
/>
</PlanCard.List>
</PlanCard.Content>
</PlanCard>
```

### Props

#### PlanCard
Expand Down
5 changes: 3 additions & 2 deletions packages/yoga/src/Card/web/PlanCard/List.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const Item = styled.li`
const Wrapper = styled(Box)`
display: flex;
flex-direction: column;
min-width: 0;
width: 100%;

${props =>
props.as === 'button' &&
Expand All @@ -46,6 +46,7 @@ const Wrapper = styled(Box)`
padding: 0;
background: transparent;
cursor: pointer;
text-align: start;
`}

svg {
Expand Down Expand Up @@ -103,7 +104,7 @@ const ListItem = withTheme(props => {
return (
<Item>
<Wrapper {...wrapperProps}>
<Box display="flex" alignItems="flex-start">
<Box display="flex" alignItems="flex-start" width="100%">
{Icon && (
<IconWrapper>
{isValidElement(Icon) ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

exports[`<PlanCard /> Snapshots should match snapshot with default PlanCard 1`] = `
.c15 {
width: 100%;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
Expand Down Expand Up @@ -283,7 +284,7 @@ exports[`<PlanCard /> Snapshots should match snapshot with default PlanCard 1`]
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
min-width: 0;
width: 100%;
}

.c14 svg {
Expand Down Expand Up @@ -398,6 +399,7 @@ exports[`<PlanCard /> Snapshots should match snapshot with default PlanCard 1`]
<div
class="c15"
display="flex"
width="100%"
>
<div
class="c16"
Expand Down Expand Up @@ -427,6 +429,7 @@ exports[`<PlanCard /> Snapshots should match snapshot with default PlanCard 1`]
<div
class="c15"
display="flex"
width="100%"
>
<div
class="c16"
Expand Down Expand Up @@ -788,6 +791,7 @@ exports[`<PlanCard /> Snapshots should match snapshot with variant 1`] = `

exports[`<PlanCard /> Snapshots should render list item content as button 1`] = `
.c15 {
width: 100%;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
Expand Down Expand Up @@ -1069,11 +1073,12 @@ exports[`<PlanCard /> Snapshots should render list item content as button 1`] =
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
min-width: 0;
width: 100%;
border: none;
padding: 0;
background: transparent;
cursor: pointer;
text-align: start;
}

.c14 svg {
Expand Down Expand Up @@ -1189,6 +1194,7 @@ exports[`<PlanCard /> Snapshots should render list item content as button 1`] =
<div
class="c15"
display="flex"
width="100%"
>
<div
class="c16"
Expand Down Expand Up @@ -1219,6 +1225,7 @@ exports[`<PlanCard /> Snapshots should render list item content as button 1`] =
<div
class="c15"
display="flex"
width="100%"
>
<div
class="c16"
Expand Down