cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Looking for quick-add? Try the external resource search, it's quicker and gives you access to the most recent version of thousands of libraries. ☝️

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

            
              <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<body>
  <div class="row">
    <div id="wrapper" class="wrapper col-xl-10 col-xl-offset-1col-lg-10 col-lg-offset-1  col md-12  col sm-12 col-xs-12">
    </div>
  </div>
  <div class='row text-center'>
        <a href="http://raymondrizzo.com/Portfolio" target="_blank">Raymond Rizzo</a>
      </div>
</body>
            
          
!
            
              $primary-text: #ffffff;
$secondary-text: #000000;
$primary-background: #337ab7;
$secondary-background: #ffffff;
$tertiary-background: #333333;

body {
  background-color: $primary-background;
}

h3 {
}
.outer-well {
  margin-top: 40px;
  background-color: $secondary-background;
  
}

.recipe {
  width: 100%;
  margin-bottom: 5px;
}

.edit-buttons{
  margin: 20px 0px 20px 1px;
}

.add-edit {
  position: absolute;
  z-index: 1;
  min-height: 200px;
	box-shadow: 5px 5px 15px #000000;
  padding: 20px;
}

.hide-me {
  visibility: hidden;
}

.form-control {
  max-width: 100%;
}

a, a:hover, a:visited {
  color: $primary-text;
  margin: auto;
}
            
          
!
            
              var BuildIngredients = React.createClass({
  render: function(){
    var ingredientMap = this.props.recipe.ingredients.map(function(ingredient, i){
      return <li id={ 'ingredient-' + i} className='ingredient list-group-item'>{ingredient}</li>;
    });
   return <ul className='list-group'>{ingredientMap}</ul>;
  }
});

var AddEdit = React.createClass({
  close: function(){
    $('#add-edit-popup').addClass('hide-me');
  },
  render: function(){
    return (
      <div className='row'>
        <div id='add-edit-popup' className='well add-edit hide-me col-lg-6 col-lg-offset-2 col-md-6 col-md-offset-2 col sm-12 col-xs-12'><button onClick={this.close} className='pull-right'>X</button>
          <div id='add-edit-target'></div>
        </div>
      </div>
      );
  }
});

var EditItems = React.createClass({
  getInitialState: function(){
    this.state = { 
      name: this.props.recipe.name,
      ingredients: this.props.recipe.ingredients
    };
    console.log(this.state.name);
    console.log(this.state.ingredients);
    return { recipe: this.props.recipe};
  },
  componentDidMount: function(){
    console.log('EditItems.componentDidMount ');
    $('#recipeName').val(this.props.recipe.name);
    $('#recipeIngredients').val(this.props.recipe.ingredients);  
  },
  componentDidUpdate: function() {
    this.state = { 
      name: this.props.recipe.name,
      ingredients: this.props.recipe.ingredients
    };
    console.log('EditItems.componentDidUpdate');
    console.log(this.state.name);
    console.log(this.state.ingredients);
    $('#recipeName').val(this.props.recipe.name);
    $('#recipeIngredients').val(this.props.recipe.ingredients);   
  },
  saveIt: function(){
    if($('#recipeName').val() !== '' && $('#recipeIngredients').val() !== ''){
      console.log('EditItems.save');
      console.log(this.props.indexNumber);
      this.state = {recipeList: JSON.parse(localStorage.getItem('_username_recipes.recipeBox'))};
      if(this.state.recipeList.length === this.props.indexNumber){
        this.state.recipeList.push({name: $('#recipeName').val(), ingredients: $('#recipeIngredients').val().split(',')});
      } else {
        this.state.recipeList[this.props.indexNumber].name = $('#recipeName').val();
        this.state.recipeList[this.props.indexNumber].ingredients = ($('#recipeIngredients').val().split(','));
      }
        localStorage.setItem('_username_recipes.recipeBox', JSON.stringify(this.state.recipeList));
  }
   // recipeBox = null;
        //ReactDOM.render(<BuildScreen recipeList={this.state.recipeList} />, document.getElementById('wrapper'));
         ReactDOM.render(<BuildScreen />, document.getElementById('wrapper'));
      $('#add-edit-popup').addClass('hide-me');
  },
  render: function(){
    return (
      <div>
        <h3>{this.props.recipeType} Recipe</h3>
        <span className='pull-left'>Name</span><input id='recipeName' type='text' className='form-control' />
        <span className='pull-left'>Ingredients</span><textarea id='recipeIngredients' className='form-control' />
        <button className='btn btn-primary edit-buttons' id='saveMe' onClick={() => this.saveIt()}>Save</button>
      </div>
    );
  }
});

var BuildRecipes = React.createClass({
  addEdit: function(recipe, i) {
    console.log('BuildRecipes.addEdit');
    console.log(recipe);
    $('#add-edit-popup').removeClass('hide-me');
    document.getElementById('add-edit-popup').style.marginTop = window.pageYOffset + 120 + 'px';
    ReactDOM.render(<EditItems recipe={recipe} recipeType='Edit' indexNumber={i}/>, document.getElementById('add-edit-target'));
  },
 delete: function(i, recipe) {
   console.log('BuildRecipes.delete' + this.props.recipeList);
   var deleteIt = confirm('Are you sure that you want to delete the recipe "' + recipe + '"?');
   if(deleteIt){
    $('#recipe-container-' + i).fadeOut('slow', function(){
    });
     this.props.recipeList.splice(i,1);
     localStorage.setItem('_username_recipes.recipeBox', JSON.stringify(this.props.recipeList));
   console.log('BuildRecipes.delete - If' + this.props.recipeList);
   } else {
   console.log('BuildRecipes.delete - Else' + this.props.recipeList);
   }
  },
  render: function(){
    var _this = this, recipeMap = this.props.recipeList.map(function(recipe,i){
      return (
        <div id={'recipe-container-' + i}>
          <button className='btn btn-primary recipe' data-toggle='collapse' data-target={'#recipe-' + i}>{recipe.name}</button>
          <div id={'recipe-' + i} className='collapse'>
            <h3 className='text-center'>Ingredients</h3><br />
            <BuildIngredients recipe={recipe} />
          <button onClick={() => _this.delete(i, recipe.name)} id={'recipe-' + i} className='btn btn-danger edit-buttons pull-right'>Delete</button>
          <button onClick={() => _this.addEdit(recipe, i)} className='btn edit-buttons'>Edit</button>
          </div>
        </div>
      );
    });
    return <div>{recipeMap}</div>;
  }
});


var BuildScreen = React.createClass({
  componentWillMount: function(){
    // Check for local storage.
    if(!localStorage.getItem('_username_recipes.recipeBox')){
      // Set default values and save to local storage if it does not existz
      var recipeBox = [{ name: 'Pumpkin Pie', ingredients: ['Pumpkin Puree', 'Sweetened Condensed Milk','Eggs', 'Pumpkin Pie Spice', 'Pie Crust']}, {name: 'Spaghetti', ingredients: ['Noodles', 'Tomato Sauce', '(Optional) Meatballs']}, {name: 'Onion Pie', ingredients: ['Onion', 'Pie Crust', 'Sounds Yummy right?']}];
      localStorage.setItem('_username_recipes.recipeBox', JSON.stringify(recipeBox));
    } 
    this.state = { recipeList: JSON.parse(localStorage.getItem('_username_recipes.recipeBox')) };
    console.log(this.state.recipeList);
  },
  componentDidUpdate: function() {
    this.state.recipeList = JSON.parse(localStorage.getItem('_username_recipes.recipeBox'));
    console.log('BuildScreen.componentDidUpdate');
    console.log(this.state.recipeList);
  },
  addNew: function(){
    console.log('BuildScreen.addNew');
    console.log(this.state.recipeList);
    console.log(this.state.recipeList.length);
    $('#add-edit-popup').removeClass('hide-me');
    document.getElementById('add-edit-popup').style.marginTop = window.pageYOffset + 120 + 'px';
    ReactDOM.render(<EditItems recipe={this.state.recipeList} recipeType='New' indexNumber={this.state.recipeList.length}/>, document.getElementById('add-edit-target'));
  },
  render: function(){
    return (
      <div>
        <AddEdit />
        <div id='outer-well' className='well outer-well col-lg-10 col md-10 col sm-12 col-xs-12'>
          <BuildRecipes recipeList={this.state.recipeList} />
          <button onClick={ () => this.addNew() } recipeList={this.state.recipeList} className='btn btn-info'>Add New Recipe</button>
        </div>
      </div>
    );
  }
});

ReactDOM.render(<BuildScreen />, document.getElementById('wrapper'));
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console