content logo

React Progress Bars:

React Progress Bar with Modal

Using a different progress bar is capable of increasing the number of your users. In this post, we will represent one of the best bootstraps for this purpose. This is the React Progress Bar with Modal with an attractive theme. If you have an online shop on a website, you probably can use this Progress Bar with Popup since it is designed for products. So, you can add the image of a product and its pricing. With the help of this React Progress Bar Code, you can pay for your needed product.

A preview of this Progress Bar with Modal is located below. This code has a white background and the picture of the product is located at the top of the page. Then, a description of this product is presented with a bold black font. Under this sentence, you can see the cost in a purple color and there is a line under the price. At the bottom of the Simple Progress Bar Code, you can see a purple field with white text. As you click on this button, the upper field moves forward with a purple line. When you put the mouse on this button of the HTML Progress Bar, its color changes to white.

 

#

Progress Bar with Popup

#

React Progress Bar Code

#

Progress Bar with Modal

#

HTML Progress Bar

#

Simple Progress Bar Code

<!-- This script got from frontendfreecode.com -->
<div id="root"></div><a style="font-size: 8pt; text-decoration: none" target="_blank" href="http://frontendfreecode.com">Free Frontend</a>
                                                                            
.container {
  text-align: center;
  max-width: 400px;
  margin: 0;
  padding: 0;
  position: relative;
}
.card {
  width: 200px;
  background-color: #f5f8f9;
  border: 1px solid #dee;
  box-shadow: 0 6px 6px -6px #999;
}
.card .card-header {
  background-color: #fff;
}
.card .card-header .logo {
  min-height: 100px;
  display: flex;
  justify-content: center;
  align-content: center;
}
.card .card-body {
  display: flex;
  justify-content: center;
  align-content: center;
  flex-direction: column;
  font-family: "Karla", sans-serif;
}
.card .card-body .title {
  font-weight: 800;
  margin: 16px 10px;
}
.card .card-body .donation-amount {
  display: flex;
  justify-content: space-around;
}
.card .card-body .donation-amount label {
  font-size: 14px;
}
.card .card-body .donation-amount input {
  cursor: pointer;
}
.card .card-body .thermometer .thermometer-raised {
  color: #774195;
  font-weight: 800;
  font-size: 18px;
}
.card .card-body .thermometer .progress {
  margin: 10px;
}
.card .card-body .thermometer .progress .progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #888;
}
.card .card-body .thermometer .progress .progress-bar {
  width: 100%;
  height: 7px;
  background: #fff;
  border: 1px solid #dee;
}
.card .card-body .thermometer .progress .progress-bar .progress-inner {
  background: #774195;
  height: 100%;
  border-radius: 0 20px 20px 0;
  transition: 0.25s ease;
}
.card .card-body .modal {
  width: 300px;
  left: 70%;
  top: 0;
  opacity: 0;
  border: 3px solid #774195;
  box-shadow: 0 6px 6px -6px #999;
  position: absolute;
  display: flex;
  flex-direction: row;
  align-items: space-around;
  justify-content: center;
  pointer-events: none;
  transition: all 0.35s ease-in-out;
}
.card .card-body .modal[data-status=true] {
  opacity: 1;
  pointer-events: auto;
  top: 50%;
  margin-top: -170px;
}
.card .card-body .modal .modal-header {
  color: #774195;
}
.card .card-body .modal .modal-body {
  font-size: 18px;
  width: 85%;
  margin: 0 auto;
}
.card .card-body .modal .modal-body .donation {
  color: #774195;
  font-size: 24px;
  font-weight: 800;
}
.card .card-body .modal .modal-body .donation-thin {
  color: #774195;
  font-size: 20px;
}
.card .card-body .give-btn {
  background-color: #774195;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -1px;
  padding: 12px;
  margin: 10px;
  border-radius: 5px;
  border: none;
  font-family: "Karla", sans-serif;
  box-shadow: 0 6px 6px -6px #999;
}
.card .card-body .give-btn:hover {
  background-color: #fff;
  color: #774195;
  border: 1px solid #774195;
  outline: none;
  cursor: pointer;
}
.card .card-body .give-btn:focus {
  outline-color: #774195;
}
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } const data =
{
    id: 1,
    logo: 'http://frontendfreecode.com/img/eye-logo.png',
    name: 'The Water Project - Global Water Initiative',
    goal: 1500,
    raised: 500
};
const { render } = ReactDOM;
class Thermometer extends React.Component {
    constructor(...args) {
        super(...args); _defineProperty(this, "state",
            {
                raised: this.props.raised,
                goal: this.props.goal,
                value: 25,
                modal: false
            }); _defineProperty(this, "toggleModal",
                () => {
                    if (!this.state.modal) {
                        this.setState({
                            modal: true
                        });
                    } else {
                        this.setState({
                            modal: false
                        });
                    }
                }); _defineProperty(this, "addGift",
                    () => {
                        this.setState(prevState => {
                            return {
                                raised: prevState.raised + this.state.value
                            };
                        });
                        this.toggleModal();
                    }); _defineProperty(this, "getWidth",
                        (amountRaised, goal) => {
                            if (amountRaised / goal * 100 <= 100) {
                                return (amountRaised / goal * 100).toFixed(1);
                            } else {
                                return 100;
                            }
                        }); _defineProperty(this, "handleChange",
                            e => {
                                this.setState({
                                    value: parseInt(e.target.value)
                                });
                            });
    }
    render() {
        return /*#__PURE__*/(
            React.createElement(React.Fragment, null, /*#__PURE__*/
                React.createElement("div", { className: "thermometer" }, /*#__PURE__*/
                    React.createElement("div", { className: "thermometer-raised" }, "$",
                        this.state.raised.toFixed(2)), /*#__PURE__*/
                    React.createElement("div", { className: "progress" }, /*#__PURE__*/
                        React.createElement("div", { className: "progress-labels" }, /*#__PURE__*/
                            React.createElement("div", null, "0%"), /*#__PURE__*/
                            React.createElement("div", null, "RAISED"), /*#__PURE__*/
                            React.createElement("div", null, this.state.raised <= this.state.goal ? '100' : (this.state.raised / this.state.goal * 100).toFixed(0), "%")), /*#__PURE__*/
                        React.createElement("div", { className: "progress-bar" }, /*#__PURE__*/
                            React.createElement("div", {
                                className: "progress-inner",
                                style: { width: `${this.getWidth(this.state.raised, this.state.goal)}%` }
                            })))), /*#__PURE__*/
                React.createElement("form", { className: "donation-amount" }, /*#__PURE__*/
                    React.createElement("label", null, /*#__PURE__*/
                        React.createElement("input", { type: "radio", checked: this.state.value === 25, onChange: this.handleChange, value: 25, id: "25" }), "$25"), /*#__PURE__*/
                    React.createElement("label", null, /*#__PURE__*/
                        React.createElement("input", { type: "radio", checked: this.state.value === 50, onChange: this.handleChange, value: 50, id: "50" }), "$50"), /*#__PURE__*/
                    React.createElement("label", null, /*#__PURE__*/
                        React.createElement("input", { type: "radio", checked: this.state.value === 100, onChange: this.handleChange, value: 100, id: "100" }), "$100")), /*#__PURE__*/
                React.createElement("button", { onClick: () => this.addGift(), className: "give-btn" }, "Give $", this.state.value, " Now!         "), /*#__PURE__*/
                React.createElement(Modal, { onClick: this.toggleModal, status: this.state.modal, raised: this.state.raised, value: this.state.value, data: this.props })));
    }
}
const Modal = props => {
    return /*#__PURE__*/(
        React.createElement("div", { className: "modal", "data-status": props.status }, /*#__PURE__*/
            React.createElement("div", { className: "modal-card" }, /*#__PURE__*/
                React.createElement("div", { className: "modal-header" }, /*#__PURE__*/
                    React.createElement("h2", { className: "title" }, props.data.name)), /*#__PURE__*/
                React.createElement("div", { className: "modal-body" }, /*#__PURE__*/
                    React.createElement("p", { className: "subtitle" }, "We would like to thank you for your generous donation of "), /*#__PURE__*/
                    React.createElement("span", { className: "donation" }, "$", props.value.toFixed(2)), /*#__PURE__*/
                    React.createElement("p", { className: "subtitle" }, "With your help we have raised ", /*#__PURE__*/React.createElement("span", { className: "donation-thin" }, "$", props.raised), " of our ", /*#__PURE__*/React.createElement("span", { className: "donation-thin" }, "$", props.data.goal), " goal. "), /*#__PURE__*/
                    React.createElement("button", { className: "give-btn", onClick: props.onClick }, /*#__PURE__*/React.createElement("span", { class: "material-icons" }, "close"))))));
};
class MainCard extends React.Component {
    constructor(...args) {
        super(...args); _defineProperty(this, "state",
            {
                error: null,
                isLoaded: false,
                data: {}
            });
    }
    //   mock AJAX call here 
    componentDidMount() {
        fetch(`/api/fundraiser/:id`) // id would have been passed in and used to retrieve correct data
            .then(res => res.json()).
            then(
                result => {
                    this.setState({
                        isLoaded: true,
                        data: result.data
                    });
                },
                error => {
                    this.setState({
                        isLoaded: true,
                        error
                    });
                });
    }
    render() {
        return /*#__PURE__*/(
            React.createElement("div", { className: "card" }, /*#__PURE__*/
                React.createElement("div", { className: "card-header" }, /*#__PURE__*/
                    React.createElement("div", { className: "logo" }, /*#__PURE__*/
                        React.createElement("img", { className: "logo-img", src: data.logo, alt: data.name, width: "100%" }))), /*#__PURE__*/
                React.createElement("div", { className: "card-body" }, /*#__PURE__*/
                    React.createElement("h4", { className: "title" },
                        data.name), /*#__PURE__*/
                    React.createElement(Thermometer, { goal: data.goal, name: data.name, raised: data.raised }))));
        // }
    }
}
const App = () => {
    return /*#__PURE__*/(
        React.createElement("div", { className: "container" }, /*#__PURE__*/
            React.createElement(MainCard, null)));
};
render( /*#__PURE__*/React.createElement(App, null), document.getElementById('root'));
<script src='https://unpkg.com/react@16/umd/react.development.js'></script>
<script src='https://unpkg.com/react-dom@16/umd/react-dom.development.js'></script>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<!-- This script got from frontendfreecode.com -->

<script src='https://unpkg.com/react@16/umd/react.development.js'></script>
<script src='https://unpkg.com/react-dom@16/umd/react-dom.development.js'></script>
<style>
.container {
  text-align: center;
  max-width: 400px;
  margin: 0;
  padding: 0;
  position: relative;
}
.card {
  width: 200px;
  background-color: #f5f8f9;
  border: 1px solid #dee;
  box-shadow: 0 6px 6px -6px #999;
}
.card .card-header {
  background-color: #fff;
}
.card .card-header .logo {
  min-height: 100px;
  display: flex;
  justify-content: center;
  align-content: center;
}
.card .card-body {
  display: flex;
  justify-content: center;
  align-content: center;
  flex-direction: column;
  font-family: "Karla", sans-serif;
}
.card .card-body .title {
  font-weight: 800;
  margin: 16px 10px;
}
.card .card-body .donation-amount {
  display: flex;
  justify-content: space-around;
}
.card .card-body .donation-amount label {
  font-size: 14px;
}
.card .card-body .donation-amount input {
  cursor: pointer;
}
.card .card-body .thermometer .thermometer-raised {
  color: #774195;
  font-weight: 800;
  font-size: 18px;
}
.card .card-body .thermometer .progress {
  margin: 10px;
}
.card .card-body .thermometer .progress .progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #888;
}
.card .card-body .thermometer .progress .progress-bar {
  width: 100%;
  height: 7px;
  background: #fff;
  border: 1px solid #dee;
}
.card .card-body .thermometer .progress .progress-bar .progress-inner {
  background: #774195;
  height: 100%;
  border-radius: 0 20px 20px 0;
  transition: 0.25s ease;
}
.card .card-body .modal {
  width: 300px;
  left: 70%;
  top: 0;
  opacity: 0;
  border: 3px solid #774195;
  box-shadow: 0 6px 6px -6px #999;
  position: absolute;
  display: flex;
  flex-direction: row;
  align-items: space-around;
  justify-content: center;
  pointer-events: none;
  transition: all 0.35s ease-in-out;
}
.card .card-body .modal[data-status=true] {
  opacity: 1;
  pointer-events: auto;
  top: 50%;
  margin-top: -170px;
}
.card .card-body .modal .modal-header {
  color: #774195;
}
.card .card-body .modal .modal-body {
  font-size: 18px;
  width: 85%;
  margin: 0 auto;
}
.card .card-body .modal .modal-body .donation {
  color: #774195;
  font-size: 24px;
  font-weight: 800;
}
.card .card-body .modal .modal-body .donation-thin {
  color: #774195;
  font-size: 20px;
}
.card .card-body .give-btn {
  background-color: #774195;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -1px;
  padding: 12px;
  margin: 10px;
  border-radius: 5px;
  border: none;
  font-family: "Karla", sans-serif;
  box-shadow: 0 6px 6px -6px #999;
}
.card .card-body .give-btn:hover {
  background-color: #fff;
  color: #774195;
  border: 1px solid #774195;
  outline: none;
  cursor: pointer;
}
.card .card-body .give-btn:focus {
  outline-color: #774195;
}
</style>

</head>
<body>
<div id="root"></div><div id="bcl"><a style="font-size:8pt;text-decoration:none;" href="http://www.devanswer.com">Free Frontend</a></div>
<script>
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } const data =
{
    id: 1,
    logo: 'http://frontendfreecode.com/img/eye-logo.png',
    name: 'The Water Project - Global Water Initiative',
    goal: 1500,
    raised: 500
};
const { render } = ReactDOM;
class Thermometer extends React.Component {
    constructor(...args) {
        super(...args); _defineProperty(this, "state",
            {
                raised: this.props.raised,
                goal: this.props.goal,
                value: 25,
                modal: false
            }); _defineProperty(this, "toggleModal",
                () => {
                    if (!this.state.modal) {
                        this.setState({
                            modal: true
                        });
                    } else {
                        this.setState({
                            modal: false
                        });
                    }
                }); _defineProperty(this, "addGift",
                    () => {
                        this.setState(prevState => {
                            return {
                                raised: prevState.raised + this.state.value
                            };
                        });
                        this.toggleModal();
                    }); _defineProperty(this, "getWidth",
                        (amountRaised, goal) => {
                            if (amountRaised / goal * 100 <= 100) {
                                return (amountRaised / goal * 100).toFixed(1);
                            } else {
                                return 100;
                            }
                        }); _defineProperty(this, "handleChange",
                            e => {
                                this.setState({
                                    value: parseInt(e.target.value)
                                });
                            });
    }
    render() {
        return /*#__PURE__*/(
            React.createElement(React.Fragment, null, /*#__PURE__*/
                React.createElement("div", { className: "thermometer" }, /*#__PURE__*/
                    React.createElement("div", { className: "thermometer-raised" }, "$",
                        this.state.raised.toFixed(2)), /*#__PURE__*/
                    React.createElement("div", { className: "progress" }, /*#__PURE__*/
                        React.createElement("div", { className: "progress-labels" }, /*#__PURE__*/
                            React.createElement("div", null, "0%"), /*#__PURE__*/
                            React.createElement("div", null, "RAISED"), /*#__PURE__*/
                            React.createElement("div", null, this.state.raised <= this.state.goal ? '100' : (this.state.raised / this.state.goal * 100).toFixed(0), "%")), /*#__PURE__*/
                        React.createElement("div", { className: "progress-bar" }, /*#__PURE__*/
                            React.createElement("div", {
                                className: "progress-inner",
                                style: { width: `${this.getWidth(this.state.raised, this.state.goal)}%` }
                            })))), /*#__PURE__*/
                React.createElement("form", { className: "donation-amount" }, /*#__PURE__*/
                    React.createElement("label", null, /*#__PURE__*/
                        React.createElement("input", { type: "radio", checked: this.state.value === 25, onChange: this.handleChange, value: 25, id: "25" }), "$25"), /*#__PURE__*/
                    React.createElement("label", null, /*#__PURE__*/
                        React.createElement("input", { type: "radio", checked: this.state.value === 50, onChange: this.handleChange, value: 50, id: "50" }), "$50"), /*#__PURE__*/
                    React.createElement("label", null, /*#__PURE__*/
                        React.createElement("input", { type: "radio", checked: this.state.value === 100, onChange: this.handleChange, value: 100, id: "100" }), "$100")), /*#__PURE__*/
                React.createElement("button", { onClick: () => this.addGift(), className: "give-btn" }, "Give $", this.state.value, " Now!         "), /*#__PURE__*/
                React.createElement(Modal, { onClick: this.toggleModal, status: this.state.modal, raised: this.state.raised, value: this.state.value, data: this.props })));
    }
}
const Modal = props => {
    return /*#__PURE__*/(
        React.createElement("div", { className: "modal", "data-status": props.status }, /*#__PURE__*/
            React.createElement("div", { className: "modal-card" }, /*#__PURE__*/
                React.createElement("div", { className: "modal-header" }, /*#__PURE__*/
                    React.createElement("h2", { className: "title" }, props.data.name)), /*#__PURE__*/
                React.createElement("div", { className: "modal-body" }, /*#__PURE__*/
                    React.createElement("p", { className: "subtitle" }, "We would like to thank you for your generous donation of "), /*#__PURE__*/
                    React.createElement("span", { className: "donation" }, "$", props.value.toFixed(2)), /*#__PURE__*/
                    React.createElement("p", { className: "subtitle" }, "With your help we have raised ", /*#__PURE__*/React.createElement("span", { className: "donation-thin" }, "$", props.raised), " of our ", /*#__PURE__*/React.createElement("span", { className: "donation-thin" }, "$", props.data.goal), " goal. "), /*#__PURE__*/
                    React.createElement("button", { className: "give-btn", onClick: props.onClick }, /*#__PURE__*/React.createElement("span", { class: "material-icons" }, "close"))))));
};
class MainCard extends React.Component {
    constructor(...args) {
        super(...args); _defineProperty(this, "state",
            {
                error: null,
                isLoaded: false,
                data: {}
            });
    }
    //   mock AJAX call here 
    componentDidMount() {
        fetch(`/api/fundraiser/:id`) // id would have been passed in and used to retrieve correct data
            .then(res => res.json()).
            then(
                result => {
                    this.setState({
                        isLoaded: true,
                        data: result.data
                    });
                },
                error => {
                    this.setState({
                        isLoaded: true,
                        error
                    });
                });
    }
    render() {
        return /*#__PURE__*/(
            React.createElement("div", { className: "card" }, /*#__PURE__*/
                React.createElement("div", { className: "card-header" }, /*#__PURE__*/
                    React.createElement("div", { className: "logo" }, /*#__PURE__*/
                        React.createElement("img", { className: "logo-img", src: data.logo, alt: data.name, width: "100%" }))), /*#__PURE__*/
                React.createElement("div", { className: "card-body" }, /*#__PURE__*/
                    React.createElement("h4", { className: "title" },
                        data.name), /*#__PURE__*/
                    React.createElement(Thermometer, { goal: data.goal, name: data.name, raised: data.raised }))));
        // }
    }
}
const App = () => {
    return /*#__PURE__*/(
        React.createElement("div", { className: "container" }, /*#__PURE__*/
            React.createElement(MainCard, null)));
};
render( /*#__PURE__*/React.createElement(App, null), document.getElementById('root'));
</script>

</body>
</html>
Preview