refactor: Card component

This commit is contained in:
Francesco Esposito 2019-07-31 15:54:02 +02:00
parent b3166a710e
commit 289f01a359
1 changed files with 39 additions and 47 deletions

View File

@ -1,4 +1,4 @@
import React, { Component } from 'react'; import React from 'react';
import { import {
Card as CardBootstrap, Card as CardBootstrap,
CardTitle, CardTitle,
@ -16,23 +16,16 @@ const styleCardTitle = {
fontWeight: '600' fontWeight: '600'
} }
class Card extends Component { const Card = (props) => {
constructor(props) {
super(props);
this.state = {};
}
render() {
let bodyAlign; let bodyAlign;
let headAlign; let headAlign;
if (this.props.bodyAlign) { if (props.bodyAlign) {
bodyAlign = `text-${this.props.bodyAlign}`; bodyAlign = `text-${props.bodyAlign}`;
} }
if (this.props.headAlign) { if (props.headAlign) {
headAlign = `text-${this.props.headAlign}`; headAlign = `text-${props.headAlign}`;
} }
return ( return (
@ -43,20 +36,20 @@ class Card extends Component {
<CardBody> <CardBody>
<CardTitle className={styleCardTitle}> <CardTitle className={styleCardTitle}>
<h5 style={styleCardTitle} className={headAlign}> <h5 style={styleCardTitle} className={headAlign}>
{this.props.title} {props.title}
</h5> </h5>
</CardTitle> </CardTitle>
<CardText> <CardText>
{this.props.subtitle} {props.subtitle}
</CardText> </CardText>
<div> <div>
{this.props.children} {props.children}
</div> </div>
{ {
this.props.footerLink && ( props.footerLink && (
<div className={`text-${this.props.footerLink.align || 'center'}`}> <div className={`text-${props.footerLink.align || 'center'}`}>
<Link to={this.props.footerLink.path}> <Link to={props.footerLink.path}>
{this.props.footerLink.name} {props.footerLink.name}
</Link> </Link>
</div>) </div>)
} }
@ -64,7 +57,6 @@ class Card extends Component {
</CardBody> </CardBody>
</CardBootstrap> </CardBootstrap>
); );
} };
}
export default Card; export default Card;