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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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 = "root">
  

</div>
              
            
!

CSS

              
                #root{
  margin-top : 5vh;
  margin-left : 10vw;
  margin-right : 10vw;
}
              
            
!

JS

              
                // jshint esversion : 6

// Initial data for the rendered recipes;
var recipes = [
  {title: "Pumpkin Pie", ingredients: ["Pumpkin Puree", "Sweetened Condensed Milk", "Eggs", "Pumpkin Pie Spice", "Pie Crust"]}, 
  {title: "Spaghetti", ingredients: ["Noodles", "Tomato Sauce", "(Optional) Meatballs"]}, 
  {title: "Onion Pie", ingredients: ["Onion", "Pie Crust", "Sounds Yummy right?"]}
];

class Recipe extends React.Component{
  constructor(props){
    super(props);
    
    this.state = {
      showIngredients : true
    };
    
    this.toggleIngredients = this.toggleIngredients.bind(this);
  }
  toggleIngredients(){
    this.setState((prevState) => {
      showIngredients : !prevState.showIngredients
    });
  }
  render(){
    let ingredientList = <IngredientList ingredients={this.props.ingredients}/>;
    console.log(ingredientList);
    return(
    <div className="tile is-child notification is-dark has-shadow" onClick={this.toggleIngredients}>
        <p className="subtitle">{this.props.recipeName}</p>
        {this.state.showIngredients == true ? {ingredientList} : "Nothin"}
    </div>
      );
  }
}

class IngredientList extends React.Component{
  constructor(props){
    super(props);
  }
  render(){
    let ingredientList = this.props.ingredients.map((ingredient) => {
      console.log(ingredient);
      return <div className="tile is-child notification is-info"><p className="subtitle">{ingredient}</p></div>
    });
    return (
        <div className="tile is-child notification is-vertical is-primary">
          <p className="title">Ingredients</p>
          {ingredientList}
          <div className = "tile is-child notification is-dark">
            <button className = "button">Edit</button>
            <button className="button is-warning">Delete</button>
          </div>
        </div>
    );
  }
}

class RecipeBox extends React.Component{
  constructor(props){
    super(props);
  }
  render(){
    let renderingRecipes = recipes.map((recipe) => {
      return <Recipe recipeName = {recipe.title} ingredients = {recipe.ingredients}/>
    }); 
    return (   
      <div className="tile is-ancestor">
          <div className="tile is-parent is-10 box notification is-info is-vertical" id="root">
            <p className="title">Recipe Box For You</p>
            <p className="subtitle">Built with React And Bulma</p>
            {renderingRecipes}
          </div>
      </div>
    );
  }
}
ReactDOM.render(<RecipeBox/>, document.getElementById("root"));
              
            
!
999px

Console