Skip to content

Commit

Permalink
Clean up spacings in CardMedia (#734)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasdalhaug authored and vnys committed Nov 13, 2020
1 parent 2074823 commit ab02609
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions libraries/core-react/src/Card/CardMedia.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { card as tokens } from './Card.tokens'

type Props = {
fullWidth?: boolean
spacing?: typeof tokens.spacings.left
} & React.HTMLAttributes<HTMLDivElement>

const StyledCardMedia = styled.div<Props>`
Expand All @@ -15,17 +14,19 @@ const StyledCardMedia = styled.div<Props>`
margin-bottom: 8px;
/* Last child to have 24px total spacing to bottom */
}
${({ fullWidth, spacing }) =>
${({ fullWidth }) =>
fullWidth
? css`
> * {
width: calc(100% + ${spacing} + ${spacing});
margin-left: -${spacing};
margin-right: -${spacing};
width: calc(
100% + ${tokens.spacings.left} + ${tokens.spacings.right}
);
margin-left: -${tokens.spacings.left};
margin-right: -${tokens.spacings.right};
}
&:first-child {
margin-top: -${spacing};
margin-top: -${tokens.spacings.top};
img {
border-top-right-radius: ${tokens.shape.borderRadius};
border-top-left-radius: ${tokens.shape.borderRadius};
Expand All @@ -49,7 +50,6 @@ export const CardMedia = forwardRef<HTMLDivElement, Props>(
className,
ref,
fullWidth,
spacing: tokens.spacings.left,
}

return <StyledCardMedia {...props}>{children}</StyledCardMedia>
Expand Down

0 comments on commit ab02609

Please sign in to comment.