Skip to content

Commit

Permalink
feat: muted prop for card to give light gray background (#1455)
Browse files Browse the repository at this point in the history
  • Loading branch information
Inferato committed Jul 29, 2022
1 parent c442bb0 commit 5f1645d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Card/Card.scss
Expand Up @@ -4,6 +4,10 @@
.pgn__card,
.pgn__card-body {
width: 100%;

&.is-muted {
background-color: $light-200;
}
}

.pgn__card-grid {
Expand Down
27 changes: 27 additions & 0 deletions src/Card/README.md
Expand Up @@ -50,6 +50,33 @@ This component uses a `Card` from react-bootstrap as a base component and extend
)}
```

## With muted styling

Use `muted` prop to show `Card` in inactive state.

```jsx live
() => {
const isExtraSmall = useMediaQuery({ maxWidth: breakpoints.extraSmall.maxWidth });

return (
<Card style={{ width: isExtraSmall ? "100%" : "18rem" }} muted>
<Card.ImageCap
src="https://source.unsplash.com/360x200/?nature,flower"
srcAlt="Card image"
/>
<Card.Header
title="Card Title"
/>
<Card.Section>
This is a card section. It can contain anything but usually text, a list, or list of links. Multiple sections have a card divider between them.
</Card.Section>
<Card.Footer>
<Button>Action 1</Button>
</Card.Footer>
</Card>
)}
```

## Clickable variant

You use `isClickable` prop to add additional `hover` and `focus` styling to the `Card`.
Expand Down
5 changes: 5 additions & 0 deletions src/Card/index.jsx
Expand Up @@ -15,6 +15,7 @@ const Card = React.forwardRef(({
isLoading,
className,
isClickable,
muted,
...props
}, ref) => (
<CardContextProvider orientation={orientation} isLoading={isLoading}>
Expand All @@ -23,6 +24,7 @@ const Card = React.forwardRef(({
className={classNames(className, 'pgn__card', {
horizontal: orientation === 'horizontal',
clickable: isClickable,
'is-muted': muted,
})}
ref={ref}
tabIndex={isClickable ? '0' : '-1'}
Expand All @@ -46,13 +48,16 @@ Card.propTypes = {
isClickable: PropTypes.bool,
/** Specifies loading state. */
isLoading: PropTypes.bool,
/** Specifies whether to display `Card` in muted styling. */
muted: PropTypes.bool,
};

Card.defaultProps = {
...BaseCard.defaultProps,
className: undefined,
orientation: 'vertical',
isClickable: false,
muted: false,
isLoading: false,
};

Expand Down

0 comments on commit 5f1645d

Please sign in to comment.