Skip to content

Commit 6caf4e0

Browse files
committed
feat(Card): fix image class
1 parent daa9e90 commit 6caf4e0

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

docs/lib/examples/CardContentTypes.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const Example = (props) => {
1010
<CardTitle>Card title</CardTitle>
1111
<CardSubtitle>Card subtitle</CardSubtitle>
1212
</CardBlock>
13-
<CardImg top width="100%" src="https://placeholdit.imgix.net/~text?txtsize=33&txt=318%C3%97180&w=318&h=180" alt="Card image cap" />
13+
<img width="100%" src="https://placeholdit.imgix.net/~text?txtsize=33&txt=318%C3%97180&w=318&h=180" alt="Card image cap" />
1414
<CardBlock>
1515
<CardText>Some quick example text to build on the card title and make up the bulk of the card's content.</CardText>
1616
<CardLink href="#">Card Link</CardLink>

src/CardImg.jsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,18 @@ const CardImg = (props) => {
2020
tag: Tag,
2121
...attributes
2222
} = props;
23+
24+
let cardImgClassName = 'card-img';
25+
if (top) {
26+
cardImgClassName = 'card-img-top';
27+
}
28+
if (bottom) {
29+
cardImgClassName = 'card-img-bottom';
30+
}
31+
2332
const classes = classNames(
2433
className,
25-
'card-img',
26-
top ? 'card-img-top' : false,
27-
bottom ? 'card-img-bottom' : false
34+
cardImgClassName
2835
);
2936

3037
return (

0 commit comments

Comments
 (0)