-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(card): add card-body functional component & card-img fixes (#843)
* feat(card-img): add img-fluid class and img-bottom ability * fix(card-img): reduce repetitive code * fix(card): keep img from rendering when no img * refactor(card): remove difficult ternaries * feat(card): add body tag, remove img slot * feat(card-body): add card-body FC * fix: add card-body to lib export and fix some docs * [meta.json] removed unused slot names * fix(card): update to bg-variant & border-variant * fix(card): doc fixes for new props * chore(docs): better markup formatting * fix(docs): bad syntax + better formatting * fix(docs): card doc fmt * fix(docs): more fmt * fix(docs): blockquote ex on card * Card-body custom class assignment test * fix(test): use helpers and ref on card test
- Loading branch information
1 parent
2ed7470
commit f88ab23
Showing
20 changed files
with
624 additions
and
457 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { mergeData, prefixPropName, copyProps } from "../utils"; | ||
import { assign } from "../utils/object"; | ||
import { cardMixin } from "../mixins"; | ||
|
||
export const props = assign({}, copyProps(cardMixin.props, prefixPropName.bind(null, "body")), { | ||
title: { | ||
type: String, | ||
default: null | ||
}, | ||
titleTag: { | ||
type: String, | ||
default: "h4" | ||
}, | ||
subTitle: { | ||
type: String, | ||
default: null | ||
}, | ||
subTitleTag: { | ||
type: String, | ||
default: "h6" | ||
}, | ||
overlay: { | ||
type: Boolean, | ||
default: false | ||
} | ||
}); | ||
|
||
export default { | ||
functional: true, | ||
props, | ||
render(h, { props, data, slots }) { | ||
let cardBodyChildren = []; | ||
if (props.title) { | ||
cardBodyChildren.push( | ||
h(props.titleTag, { | ||
staticClass: "card-title", | ||
domProps: { innerHTML: props.title } | ||
}) | ||
); | ||
} | ||
if (props.subTitle) { | ||
cardBodyChildren.push( | ||
h(props.subTitleTag, { | ||
staticClass: "card-subtitle mb-2 text-muted", | ||
domProps: { innerHTML: props.subTitle } | ||
}) | ||
); | ||
} | ||
cardBodyChildren.push(slots().default); | ||
|
||
return h( | ||
props.bodyTag, | ||
mergeData(data, { | ||
staticClass: "card-body", | ||
class: { | ||
"card-img-overlay": props.overlay, | ||
[`bg-${props.bodyBgVariant}`]: Boolean(props.bodyBgVariant), | ||
[`border-${props.bodyBorderVariant}`]: Boolean(props.bodyBorderVariant), | ||
[`text-${props.bodyTextVariant}`]: Boolean(props.bodyTextVariant) | ||
} | ||
}), | ||
cardBodyChildren | ||
); | ||
} | ||
}; |
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
Oops, something went wrong.