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

              
                #app
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Lato:400,300,700);
@import "compass";
$blue: #3a8bbb;
$teal: #3FB8AF;
$red: #e54b4b;
$grey-lt: #aaa;
$grey: #777;

html {
	display: flex;
	font-size: initial;
}

/* boostrap overrides */

a, a:hover, a:visited {
	text-decoration: none;
}
p{
	margin: 0;
}
label {
	display: initial;
}

/*******************/

body {
@include background-image(linear-gradient(left bottom, #226a96 0%,#99d5e8 100%));
	font-family: 'Lato';
	background-color: #eee;
	color: #555;
min-width: 100%;
	display: flex;
	perspective: 8000px;

}

* {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

#app {
	display: flex;
	flex-grow: 1;
}
ul {
  list-style: none;
  margin: auto;
  padding: 0;
}
.card-container {
	transform-style: preserve-3d;
	transition: transform 1s;
}
li {
	cursor: grab;
	position: relative;
	transform-style: preserve-3d;
	float: left;
	&[draggable=false]{
		cursor: default;
		figure.front,
		figure.back {
			box-shadow: none;
		}
	}
	 .card-container {
		 
		pointer-events:none;
	}
	input[type="text"],
	input[type="number"]{
		border: 0 none;
		border-bottom: 1px solid #eee;
		pointer-events: initial;
		width: 100%;
		height: 40px;
		margin-bottom: 20px;
		outline: 0 none;
		font-size: 1rem;
		transition: border-bottom 0.2s ease-in-out;
		&:focus {
			border-bottom: 1px solid $blue;
		}
	}
	&.placeholder{ 
		background: rgba(255,255,255,0.2);
		height: 494px;
		display: flex;
		width: 330px;
		border-radius: 5px;
	
	}
}

.modal {
	overflow-y: auto;
	&-dialog {
		width: 400px;
	}
	.fund-container {
		border: 1px solid #ddd;
		border-radius: 3px;
		height: 40px;
		margin-left: 5px;
		margin-top: 20px;
		margin-bottom: 10px;
		padding: 10px 0;
		width: 125px;
		text-align: right;
	}
	label {
		display: inline-block;
		width: 48%;
	}
	.data {
		width: 50%;
    text-align: right;
    margin-left: 5px;
    display: inline-block;
	}
	.smallprint {
		font-size: .7rem;
		text-align: right;
	}
	.pre-money {
		opacity: .7;
	}
}

h1,h2,h3,h4,h5 {
	margin: 0;
}
.modal-container {
  position: relative;
}
.modal-container .modal, .modal-container .modal-backdrop {
  position: absolute;
}

button {
	pointer-events: initial;
}



.card-title {
	    text-align: center;
    margin-bottom: 20px;
    font-size: 1rem;
}
.back-arrow {
	pointer-events: initial;
    display: table;
    position: absolute;
    padding: 20px;
    margin: -20px;
    font-size: 1.2rem;
	&:hover .fa {
			color: darken($grey-lt, 20%);
	}
}
.edit-money {
	display: table;
	position: absolute;
	margin-top: 10px;
	opacity: .7;
	+ input {
		padding-left: 15px;
	}
}
.delete {
	color: $grey;
	pointer-events: initial;
	text-align: center;
	font-size: .8rem;
	margin: 0 auto;
	margin-top: 10px;
	padding: 10px;
	display: table;
	transition: color 0.2s ease-in-out;
	&:hover {
		color: $red;
	}
}

figure{
	  backface-visibility: hidden;
	&.front {
  background: #fff;
  transform: rotateY(0deg);
	overflow: hidden;
		pointer-events: intial;
  border-radius: 5px;
		padding: 20px;
		margin: 10px;
		width: 330px;
		transition: all 0.2s ease-in-out;
		box-shadow: 0 10px 20px 0 rgba(13, 59, 86, 0.5);
		
	}
	&.back {
		background-color: #fff;
	transform: rotateY( 180deg );
 flex-wrap: wrap;
  display: flex;
		flex-direction: column;
   position: absolute;
  left: 0;
	margin: 10px;
		margin-top: 0;
	padding: 20px;
  width: 330px;
  height: 100%;
  top: 0;
		border-radius: 5px;
		opacity: 0;
transition: all .3s ease-in-out;
}

	.input-container {
		flex-grow: 1;
	}
	
}

	.flipped figure.back {
		opacity: 1;
	
	}
	
.flipped {
	transform: rotateY( 180deg );
	-webkit-transform: rotateY( 180deg );
}




.goal {
	&__name {
		color: #777;
		font-size: .75rem;
		text-align: center;
		width: 80%;
		margin: 10px auto;
		text-transform: uppercase;
		letter-spacing: 3px;
	}
	&--progress {
		color: #222;
		font-size: 1.7rem;
		margin-bottom: 10px;
		text-align: center;
	}
	&--remain {
		color: #222;
	}
	&--amount {
		color: #777;
		font-size: .8rem;
		text-align: center;
	}
	
	&--top {

		display: flex;
		flex-direction: column;
		position: relative;
		height: 375px;
		&__container {
			margin: auto;
			position: relative;
		}
	}

}

.edit {
		pointer-events: initial;
		padding: 20px;
	position: absolute;
	right: 0;
	margin: -20px;
	top: 0;
	margin-top: -13px;
	&:hover .fa {
			color: darken($grey-lt, 20%);
	}
	.fa {
		font-size: 1.2rem;
	}
}

.money {
	&:before {
			content: "$";
		}
}

.right {
	float: right;
	margin-left: 5px;
}

.percent {
	color: #777;
}

.descriptor {
	font-size: .8rem;
	margin-bottom: 20px;
}

.dropdown-wrapper {
	margin-top: 10px;
	pointer-events: initial;
   border: 1px solid #eee;
   border-radius: 5px;
   position: relative;
	cursor: pointer;
	width: 100%;
	transition: border 0.2s ease-in-out;
	&:hover {
		border: 1px solid darken(#eee, 10%);
	}
   &:after {
      font-family: 'FontAwesome';
      content: "\f107";
      color: #3FB8AF;
      position: absolute;
      right: 10px;
      top: 7px;
   }
   &.outline {
      border: 1px solid rgba(#3FB8AF, .5);
      box-shadow: 0 0 10px rgba(#3FB8AF, .2);
   }
}
select {
		cursor: pointer;
		pointer-events: initial;
    appearance: none;
    background: none;
    border: 0 none;
    font-size: .8em;
	padding: 10px;
    outline: 0;
	width: 100%;
	display: block;
}

.button {
	background: $blue;
	border: 0 none;
	color: #fff;
	margin-bottom: auto;
	cursor: pointer;
	border-radius: 5px;
		pointer-events: initial;
	height: 44px;
	text-transform: uppercase;
	text-align: center;
	font-size: .7rem;
	letter-spacing: 2px;
	padding: 15px;
	transition: all 0.2s ease-in-out;
	width: 100%;
	&:hover {
		background: darken($blue, 5%);
	}
}

.fa {
	font-family: 'FontAwesome';
	display: block;
	text-align: center;
	&.category{
			left: 0;
	right: 0;
	top: -40px;
	margin: auto;
	position: absolute;
	}
	&.fa-plane {
		color: $teal;
	}
	&.fa-car {
		color: $red;
	}
	&.fa-pencil-square-o,
	&.fa-angle-left{
		color: $grey-lt;
		transition: color 0.2s ease-in-out;
	}
}

/** svg **/



.svg-container { 
	display: inline-block;
	position: relative;
	width: 100%;
	height: 100%;
  vertical-align: middle;
  overflow: hidden;
}

.svg-content { 
	display: inline-block;
	margin: 0 auto;
	margin-top: 20px;
  width: 100%;
}

.animated {
  animation: dash 1s cubic-bezier(0.165, 0.840, 0.440, 1.000) forwards;

}

.box {
    width: 100%;
    height: 100%;
    margin: 0 auto;
	position: absolute;
	left: 0;
	right: 0;
	
}
svg {
	transform: rotate(-90deg);
}

text {
  text-anchor: middle;
}

circle {
	stroke-linecap: round;
}

.shadow {
	opacity: .6;
}

@keyframes dash {
  to {
    stroke-dashoffset: 0;
  }
}


              
            
!

JS

              
                //var ReactCSSTransitionGroup = React.addons.CSSTransitionGroup;
'use strict';
var placeholder = document.createElement("li");
placeholder.className = "placeholder";
var Button = ReactBootstrap.Button;
var Modal = ReactBootstrap.Modal;
var OverlayTrigger = ReactBootstrap.OverlayTrigger;
class Pie extends React.Component {
	render() {
		const {
			color,
			width,
			progress
		} = this.props;
		const pi = 3.14159265359;
		const r = (400 / 2);
		const c = (2 * pi) * r;
		const realProgress = c * progress;
		return (
			<div className="svg-container"> 
        <div
          className="svg-content"
        >
          <svg
            viewBox="0 0 500 500"
            preserveAspectRatio="xMinYMin meet"
          >
		<filter id="shadow">
    <feGaussianBlur in="SourceGraphic" stdDeviation="15" />
			<feOffset dx="-5" dy="-4" />
  </filter>
						
            <circle
							
              className="animated"
              cx="250"
              cy="250"
              r="200"
              stroke={""}
              fillOpacity="0"
              strokeWidth={width + 10}
              strokeDasharray={[realProgress,  c]}
              strokeDashoffset={c * progress}
            />
							 <circle
							filter="url(#shadow)"
						  className="animated shadow"
              cx="250"
              cy="250"
              r="200"
              stroke={color}
              fillOpacity="0"
              strokeWidth={width}
              strokeDasharray={[realProgress,  c]}
              strokeDashoffset={c * progress}
            />
            
            <circle
						  className="animated fill"
              cx="250"
              cy="250"
              r="200"
              stroke={color}
              fillOpacity="0"
              strokeWidth={width}
              strokeDasharray={[realProgress,  c]}
              strokeDashoffset={c * progress}
            />
					
           
            <circle
              cx="250"
              cy="250"
              r="200"
              stroke={color}
              fillOpacity="0"
              strokeWidth="5"
              strokeDasharray={[c,  c]}
              strokeOpacity="0.1"
            />
            
          </svg>
        </div>
      </div>
		);
	}
}
class Application extends React.Component {

	render() {
		var percent = this.props.percent;
		var colorChart = this.props.colorChart;
		return (
			<div>
        <div className="box">
          <Pie
             color={colorChart}
            width={15}
				progress={percent}
            
          />
        </div>
      </div>
		);
	}
}
var progressUpdate;
var goals = [{
	category: 'car',
	name: 'Car',
	amount: 20000,
	progress: 6593,
	flipped: false,
	dragStatus: true
}, {
	category: 'plane',
	name: 'Vacation',
	amount: 3500,
	progress: 2984,
	flipped: false,
	dragStatus: true
}];

var dragStatus = true;

class GoalCard extends React.Component {
  constructor(props) {
  super(props);
  this.state = { condition: false, 
								progress: this.props.item.progress,
								input1: this.props.item.name,
							 	input2: this.props.item.amount,
								input3: this.props.item.progress,
								selectValue: this.props.item.category
							 };
}
	addMoney() {
		var addFunds = prompt('Add funds for: ' + this.props.item.name, "0");
		this.props.item.progress += Number(addFunds);
		this.setState({
			item: this.props.item
		});
}
onSave(){
	this.props.item.progress = progressUpdate;
	this.setState({
		item:this.props.item
	})
}
editGoal(index){
	this.props.onFlip(index);
  this.setState( { 
			condition : !this.state.condition,
			input1:this.props.item.name,
	 		input2: this.props.item.amount,
	 		input3: this.props.item.progress,
			selectValue: this.props.item.category
	    });
}
deleteGoal(index){
	this.props.onDelete(index);
	this.setState({ condition : !this.state.condition,
								input1: this.props.item.name,
							 	input2: this.props.item.amount,
								input3: this.props.item.progress,
								selectValue: this.props.item.category,
								flipped: false,
							 	dragStatus: true
							  });
}
cancelEdit(index){
	this.props.onFlip(index);
	this.setState({ condition : !this.state.condition,
								input1: this.props.item.name,
							 	input2: this.props.item.amount,
								input3: this.props.item.progress,
								selectValue: this.props.item.category} );
}
saveGoal(index){
	this.props.onFlip(index);
	this.setState( { condition : !this.state.condition } );
	this.props.item.name = this.state.input1;
	this.props.item.amount = Number(this.state.input2);
	this.props.item.progress = Number(this.state.input3);
	this.props.item.category = this.state.selectValue;
}
handleChange(name, e){
	var change = {};
	change[name] = e.target.value;
	this.setState(change);
 }
handleDropdown(e){
	this.setState( {selectValue: e.target.value});
}


render(){
	var message;
	var strokeColor;
	var status;
	var remaining;
	var percentRemaining;
	if ((this.props.item.progress/this.props.item.amount)<1){
		strokeColor="#01579B";
		status = "Remaining";
		remaining = ((this.props.item.amount - this.props.item.progress)).toLocaleString();
					percentRemaining = "(" + (((this.props.item.amount - this.props.item.progress)/this.props.item.amount)*100).toFixed(0) + "%)";
				}
	else {
		strokeColor="#7dbf69";
		status = "Exceeded"
		remaining = Math.abs((this.props.item.amount - this.props.item.progress)).toLocaleString();
			percentRemaining = "(" + Math.abs(((this.props.item.amount - this.props.item.progress)/this.props.item.amount)*100).toFixed(0) + "%)";
}
			
	return(
		<div className={this.state.condition ? "flipped card-container" :"card-container"} >
			
						<figure className="front">
					<div className="goal--top">
						<a href="#" className="edit" onClick={this.editGoal.bind(this, this.props.item.index)}><i className="fa fa-pencil-square-o"></i></a>
					<div className="goal__name">{this.props.item.name}</div>	
	<Application percent={(this.props.item.progress/this.props.item.amount)} colorChart={strokeColor}/>
					<div className="goal--top__container">
						<i className={'category fa fa-' + this.props.item.category} aria-hidden="true"></i>
						<div className="goal--progress"><span className="money">
							{(this.props.item.progress).toLocaleString()}</span>
						</div>
						<div className="goal--amount">of <span className="money">{(this.props.item.amount).toLocaleString()}</span>
						</div>
					</div>
				</div>
				<div className="goal--bottom">
					<div className="descriptor">{status}
						<span className="money right goal--remain">{remaining}</span>
						<span className="percent right">{percentRemaining}</span>
					</div>
				
					<Example 
						name={this.props.item.name}
						progress={this.props.item.progress}
						amount={this.props.item.amount}
						onSave={this.onSave.bind(this)}
		
					/>
				</div>
							</figure>
						<figure className="back">
							
							<a href="#" className="back-arrow" onClick={this.cancelEdit.bind(this, this.props.item.index)}><i className="fa fa-angle-left"></i></a>
							<h3 className="card-title">Goal Details</h3>
							<div className="input-container">
								<label name="name" className="descriptor">Name</label>
							<input type="text" placeholder="Goal Name" value={this.state.input1} onChange={this.handleChange.bind(this, 'input1')} />
									<label name="amount" className="descriptor">Goal</label>
								<span className="edit-money">$</span><input type="number" placeholder="Amount" value={this.state.input2} onChange={this.handleChange.bind(this, 'input2')} />
	<label name="progress" className="descriptor">Progress</label>
								<span className="edit-money">$</span>	<input type="number" placeholder="Progress" value={this.state.input3} onChange={this.handleChange.bind(this, 'input3')} />									<label name="icon" className="descriptor">Icon</label>
								<div className="dropdown-wrapper">
								 <select value={this.state.selectValue} 
 onChange={this.handleDropdown.bind(this)} 
 >
    <option value="car">Car</option>
    <option value="plane">Plane</option>
    <option value="">None</option>
  </select>
									</div>
								</div>
								<input type="button" className="button" value="Save Changes" onClick={this.saveGoal.bind(this, this.props.item.index)} />
							<a href="#" className="delete" onClick={this.deleteGoal.bind(this, this.props.item.index)}>Delete Goal</a>
						</figure>
          </div>
			)}
}

const Example = React.createClass({
  getInitialState() {
    return { showModal: false,
					 progress: this.props.progress,
					input1: "",
						sum: ""
					 }
  },

  close() {
    this.setState({ showModal: false });
  },
	submit(e){
		 if (e.key === 'Enter') {
			progressUpdate =this.state.sum;
		this.props.onSave();
    this.setState({ 
			showModal: false
		});
		 }
		
	},
  save() {
	progressUpdate =this.state.sum;
		this.props.onSave();
    this.setState({ 
			showModal: false
		});

  },
  open() {
    this.setState({ showModal: true,
									sum: this.props.progress,
									input1: ""});
  },
	handleChange(name, e){
	var change = {};
	change[name] = e.target.value;
	
			this.setState(change);
		this.setState({
			sum: Number(this.props.progress) + Number(change[name])
			 
		})
		
 }
	,
  render() {


    return (
      <div>

        <Button
          bsStyle="primary"
          bsSize="large"
          onClick={this.open}
					className="button"
        >
          Add funds
        </Button>

        <Modal show={this.state.showModal} onHide={this.close}>
          <Modal.Header closeButton>
            <Modal.Title>Add Funds for {this.props.name}</Modal.Title>
          </Modal.Header>
          <Modal.Body>
						<label>Current progress:</label>
						<div className="data">${(this.props.progress).toLocaleString()}</div>
						<label>Add amount:</label>
						<div className="data">
						<span className="pre-money">$</span> <input type="number" className="fund-container" defaultValue="" onKeyPress={this.submit.bind(this)} onChange={this.handleChange.bind(this, 'input1')} autoFocus/></div>
						<p className="smallprint"> Total Progress: <span className="pre-money">$</span>{(this.state.sum).toLocaleString()}</p>
          </Modal.Body>
          <Modal.Footer>
            <Button onClick={this.close}>Close</Button>
						<Button type="button" className="btn-primary" onClick={this.save.bind(this, this.props)}>Update Progress</Button>
          </Modal.Footer>
        </Modal>
      </div>
    );
  }
});


var GoalList = React.createClass({
	getInitialState: function() {
		return {
			data: this.props.data
		};
	},
	dragStart: function(e) {
		//this.refs['update'].updateGoal();
		this.dragged = e.currentTarget;
		e.dataTransfer.effectAllowed = 'move';
		e.dataTransfer.setData("text/html", e.currentTarget);

	},
	dragEnd: function(e) {
		this.dragged.style.display = "block";
		placeholder.remove();
		// Update data
		var data = this.state.data;
		var from = Number(this.dragged.dataset.id);
		var to = Number(this.over.dataset.id);
		if (from < to) to--;
		if (this.nodePlacement == "after") to++;
		data.splice(to, 0, data.splice(from, 1)[0]);
		this.setState({
			data: data
		});
		
	},
	dragOver: function(e) {
	
		e.preventDefault();
		this.dragged.style.display = "none";
		if (e.target.className == "placeholder") return;
		this.over = e.target;
		// Inside the dragOver method
		var relY = e.pageY - this.over.offsetTop;
		var height = this.over.offsetHeight / 2;
		var relX = e.pageX - this.over.offsetLeft;
		var width = this.over.offsetWidth / 2;
		var parent = e.target.parentNode;

		if (relX >= width) {
			this.nodePlacement = "after";
			parent.insertBefore(placeholder, e.target.nextElementSibling);
		} else {
			this.nodePlacement = "before"
			parent.insertBefore(placeholder, e.target);
		}
	this.setState({
			data: this.props.data
		});
	},
	onFlip: function(i){
		var data= this.state.data;
		data[i].flipped = !data[i].flipped;
		
		this.setState({ 
			data: data});
		
		if (data[i].flipped){
			var data=this.props.data;
		//	data[i].dragStatus = false;
			dragStatus = false;
		}
		else {
		//	data[i].dragStatus= true;
			dragStatus = true;
		}
	
	},	
	onDelete: function(i){
		var data = this.props.data;
		 var newData = this.state.data.slice(); //copy array
    newData.splice(i, 1); //remove element
    this.setState({data: newData}); //update state
		this.props = newData;
		//var data = this.props.data;
		data[i].flipped = !data[i].flipped;
		if (data[i].flipped){

		//	data[i].dragStatus = false;
			dragStatus = false;
		}
		else {
		//	data[i].dragStatus= true;
			dragStatus = true;
		}
		data = newData
		//data.splice(i, 1);

	//	this.setState({ data: data});

	},
	render: function() {

		return <ul className="goal__list" onDragOver={this.dragOver}>

			
			 	{this.state.data.map(function(item, i) {
		
			
      	return (
				
					<li data-id={i}
            key={i}
           // draggable={goals[i].dragStatus}
						draggable = {dragStatus}
            onDragEnd={this.dragEnd.bind(this)}
            onDragStart={this.dragStart.bind(this)}
		
          >
					<GoalCard item={item} 
						onFlip={this.onFlip.bind(this, i)}
						cancelEdit={this.onFlip.bind(this,i)}
						saveGoal={this.onFlip.bind(this,i)}
						onDelete={this.onDelete.bind(this,i)}
						
						/>
				
          </li>
        )
   	 	}, this)}
    </ul>
	}

});

ReactDOM.render(<GoalList data={goals} />, document.getElementById('app'));
              
            
!
999px

Console