Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="progress"></div>
<span class='thanks'>(thanks <a href='https://codepen.io/Grsmto/'>grsmto</a> for helping out)</span>
              
            
!

CSS

              
                /**
 * Demo variables
 */
$green: #76E19E;
$white: #FFF;
$blue: #657AED;
$red: #FB7593;
$yellow: #FFD05C;
$body-bg: $blue;

/**
 * Demo Styles
 */
%flex-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

* {
  box-sizing: border-box;
}

body {
  @extend %flex-center;
  flex-direction: column;
  height: 100vh;
  margin: 0;
  padding: 8px;
  background-color: $body-bg; 
  font-family: 'Nunito', sans-serif;
}

.thanks {
  margin-top: 50px;
  color: $white;
  opacity: 0.5;
  font-size: 12px;
  
  a {
    color: $white;
  }
}

[data-reactroot] {
  @extend %flex-center;
  flex-direction: column;
}

#progress {
  max-width: 400px;
  width: 100%;
  margin: 0 auto;
}

input {
  margin: 50px auto;
  display: block;
}

/**
 * Progress Bar variables
 */
$progress-bar-bg: $white;
$progress-default-bg: $green;
$progress-step-1-bg: $red;
$progress-step-2-bg: $yellow;
$progress-completed-bg: $green;
$progress-tick-bg: $green;
$progress-tick-color: $white;
$progress-label-color: $white;

/**
 * Progress Bar styles
 */
.progress-bar {
  width: 100%;
}

.progress-bar__bar {
  border-radius: 10px;
  background-color: $progress-bar-bg;
  margin-bottom: 14px;
}

.progress-bar__progress {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  min-width: 15px;
  height: 10px;
  border-radius: 10px;
  background-color: $progress-default-bg;
  transition: background-color 0.3s ease;
}

.progress-bar__progress--step-1 {
  background-color: $progress-step-1-bg;
}

.progress-bar__progress--step-2 {
  background-color: $progress-step-2-bg;
}

.progress-bar__progress--step-3 {
  background-color: $progress-default-bg;
}

.progress-bar__progress--step-completed {
  background-color: $progress-completed-bg;
}

.progress-bar__tick-wrapper {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  opacity: 0;
  background-color: $progress-tick-bg;
  transition: all 0.15s ease;
  transform: scale(0);

  .progress-bar__progress--step-completed & {
    opacity: 1;
    transform: scale(1);
  }
}

.progress-bar__tick {
  width: 15px;
  height: 16px;
  fill: $progress-tick-color;
}

.progress-bar__label {
  display: block;
  font-size: rem(16);
  text-align: center;
  color: $progress-label-color;
}

.progress-bar__label--left {
  text-align: left;
}

              
            
!

JS

              
                /*!
  Copyright (c) 2017 Jed Watson.
  Licensed under the MIT License (MIT), see
  http://jedwatson.github.io/classnames
*/
/* global define */

(function () {
	'use strict';

	var hasOwn = {}.hasOwnProperty;

	function classNames () {
		var classes = [];

		for (var i = 0; i < arguments.length; i++) {
			var arg = arguments[i];
			if (!arg) continue;

			var argType = typeof arg;

			if (argType === 'string' || argType === 'number') {
				classes.push(arg);
			} else if (Array.isArray(arg) && arg.length) {
				var inner = classNames.apply(null, arg);
				if (inner) {
					classes.push(inner);
				}
			} else if (argType === 'object') {
				for (var key in arg) {
					if (hasOwn.call(arg, key) && arg[key]) {
						classes.push(key);
					}
				}
			}
		}

		return classes.join(' ');
	}

	if (typeof module !== 'undefined' && module.exports) {
		classNames.default = classNames;
		module.exports = classNames;
	} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {
		// register as 'classnames', consistent with npm package name
		define('classnames', [], function () {
			return classNames;
		});
	} else {
		window.classNames = classNames;
	}
}());

/*
  Progress bar script
*/
const ProgressBar = ({ className, progress, labelLeft }) => {
  let progressInt = parseInt(progress)
  const progressClassPrefix = `progress-bar__progress--step-`
  const progressClassNames = {
    [`${progressClassPrefix}1`]: progressInt <= 25,
    [`${progressClassPrefix}2`]: progressInt > 25 && progressInt <= 50,
    [`${progressClassPrefix}3`]: progressInt > 50 && progressInt <= 99,
    [`${progressClassPrefix}completed`]: progressInt === 100
  }

  return (
    <div className={classNames('progress-bar', className)}>
      <div className="progress-bar__bar">
        <div
          className={classNames('progress-bar__progress', progressClassNames)}
          style={{width: progress + '%'}}>
          <div className="progress-bar__tick-wrapper">
            <svg className='progress-bar__tick icon-tick' viewBox='0 0 512 512'><path d="m135 280l97 97c20 20 20 52 0 72-20 20-53 20-73 0l-96-96c-20-20-20-53 0-73 20-20 52-20 72 0z m300-106c20 20 20 52 0 72l-193 193c-20 20-53 20-73 0-20-20-20-52 0-72l194-193c20-20 52-20 72 0z"/></svg>
          </div>
        </div>
      </div>
      <span className={classNames('progress-bar__label', { 'progress-bar__label--left': labelLeft })}>
        {
          progressInt === 0 ?
            `No scenes completed` :
            `${progress}% of scenes completed`
        }
      </span>
    </div>
  )
}

class CodepenProgressBar extends React.Component {
  constructor() {
    super()
    this.state = {
      progress: 50,
      value: 50
    }
  }

  onChange = (e) => {
    this.setState({ 
      progress: e.currentTarget.value,
      value: e.currentTarget.value
    })
  };

  render() {
    return (
      <div>
        <ProgressBar progress={this.state.progress} />
        <input type='range' value={this.state.value} onChange={this.onChange}/>
      </div>
    )
  }
}


/*
 * Render the above component into the div#progress
 */
ReactDOM.render(
  <CodepenProgressBar />, document.getElementById('progress'));
              
            
!
999px

Console