Skip to content

Instantly share code, notes, and snippets.

@samuelayo
Created March 28, 2019 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samuelayo/02eca2363192e4946677ea910d8bd779 to your computer and use it in GitHub Desktop.
Save samuelayo/02eca2363192e4946677ea910d8bd779 to your computer and use it in GitHub Desktop.
// ./components/Total.jsx
import React from 'react'
import 'bootstrap/dist/css/bootstrap.css';
export default class Total extends React.Component {
constructor(props) {
super(props);
}
render() {
let total = this.props.total.toFixed(2);
let tax = (this.props.total * 0.15).toFixed(2);
let totalIncTax = (+total + +tax).toFixed(2);
let mystyle = {
borderTop: "1px solid #ddd",
marginTop: "10px"
};
return (
<div style={{"marginTop": "30px", "backgroundColor":"#F6F6F6","padding": "10px"}}>
<h3 className="row" style={{ fontWeight: 400 }}>
<span className="col-6">total price:</span>
<span className="col-6 text-right">${total}</span>
</h3>
<h3 className="row" style={{ fontWeight: 400 }}>
<span className="col-6">tax (15%):</span>
<span className="col-6 text-right">${tax}</span>
</h3>
<h3 className="row" style={mystyle}>
<span className="col-6">tota inc tax:</span>
<span className="col-6 text-right">${totalIncTax}</span>
</h3>
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment