FCC Recipe Box

Developer
Size
7,585 Kb
Views
6,072

How do I make an fcc recipe box?

What is a fcc recipe box? How do you make a fcc recipe box? This script and codes were developed by Victoria on 02 December 2022, Friday.

FCC Recipe Box Previews

FCC Recipe Box - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>FCC Recipe Box</title> <link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div id='container'></div> <script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/classnames/2.2.5/dedupe.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.3.1/react-dom.min.js'></script>
<script src='https://npmcdn.com/[email protected]/lib/mobx.umd.js'></script>
<script src='https://npmcdn.com/[email protected]/index.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react-bootstrap/0.30.5/react-bootstrap.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.15.0/lodash.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

FCC Recipe Box - Script Codes CSS Codes

@import url("https://fonts.googleapis.com/css?family=Covered+By+Your+Grace");
#container { text-align: center; margin: auto; width: 70%;
}
.header { margin: 5%; font-family: 'Covered By Your Grace', cursive; font-size: 500%;
}
.modal-title { font: 36px 'Covered By Your Grace', cursive;
}
.left-text { text-align: left;
}
.buttons { width: 100%; height: 25px; display: flex; flex-flow: row nowrap; justify-content: flex-end;
}
.delete-recipe { cursor: pointer; margin: 10px;
}
.edit-recipe { cursor: pointer; margin: 10px;
}
.delete-recipe:hover { color: red; font-size: 15px;
}
.edit-recipe:hover { color: blue; font-size: 15px;
}
.table.table-striped { width: auto; text-align: left; cursor: default;
}
.header-cell { height: 30px; padding-right: 10%; min-width: 100px;
}
.table-row:hover { background-color: #ffd8e4; text-decoration: double;
}
.modal-label { font-weight: normal; margin: 10px 5px; font-size: 30px; font-family: 'Covered By Your Grace', cursive;
}
.modal-input { margin: 5px; min-height: 35px; border-radius: 5%; outline: none; background-color: #eaecf1; padding-left: 5px;
}
.modal-input:focus { border: 1px solid #003780;
}

FCC Recipe Box - Script Codes JS Codes

'use strict';
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var _React = React;
var Component = _React.Component;
var _mobxReact = mobxReact;
var observer = _mobxReact.observer;
var _mobx = mobx;
var observable = _mobx.observable;
var autorun = _mobx.autorun;
var _ReactBootstrap = ReactBootstrap;
var Modal = _ReactBootstrap.Modal;
var Button = _ReactBootstrap.Button;
var Accordion = _ReactBootstrap.Accordion;
var Panel = _ReactBootstrap.Panel;
var getInitialRecipes = function getInitialRecipes() { var rs = localStorage.getItem('recipes'); if (rs) { return JSON.parse(rs); } else { return [{ recipeTitle: "Penapple", ingredients: [{ name: 'Pen', qty: 1, unit: 'pc' }, { name: 'Apple', qty: '1', unit: 'pc' }], instructions: 'Bdish!' }]; }
};
var RecipeStore = function () { function RecipeStore() { var _this = this; _classCallCheck(this, RecipeStore); this.recipes = observable(getInitialRecipes()); autorun(function () { _this.refreshLocalStorage(_this.recipes); }); } RecipeStore.prototype.addRecipe = function addRecipe(recipe) { this.recipes.push({ recipeTitle: recipe.recipeTitle, ingredients: recipe.ingredients, instructions: recipe.instructions }); }; RecipeStore.prototype.deleteRecipe = function deleteRecipe(id) { this.recipes.splice(id, 1); }; RecipeStore.prototype.editRecipe = function editRecipe(id, recipe) { this.recipes[id] = recipe; }; RecipeStore.prototype.refreshLocalStorage = function refreshLocalStorage(r) { localStorage.setItem('recipes', JSON.stringify(r)); }; return RecipeStore;
}();
var recipeStore = new RecipeStore();
var RecipeBox = observer(function (_React$Component) { _inherits(RecipeBox, _React$Component); function RecipeBox(props) { _classCallCheck(this, RecipeBox); var _this2 = _possibleConstructorReturn(this, _React$Component.call(this, props)); _this2.close = function () { _this2.setState({ showModal: false, editRecipeId: null }); }; _this2.open = function () { _this2.setState({ showModal: true }); }; _this2.edit = function (i) { _this2.setState({ showModal: true, editRecipeId: i }); }; _this2.state = { editRecipeId: null, showModal: false }; return _this2; } RecipeBox.prototype.render = function render() { var _this3 = this; var store = this.props.store; return React.createElement( 'div', { className: 'recipe_box' }, React.createElement( 'div', { className: 'header' }, 'Reactive Recipes' ), React.createElement( Panel, null, React.createElement( Accordion, null, store.recipes.map(function (recipe, i) { return React.createElement( Panel, { header: recipe.recipeTitle, eventKey: i, key: i }, React.createElement( 'span', { className: 'modal-label' }, 'Ingredients' ), recipe.ingredients.map(function (ingredient, id) { return React.createElement( 'div', { className: 'left-text', key: id }, ingredient.name, ': ', ingredient.qty, ' ', ingredient.unit ); }), React.createElement( 'div', { className: 'modal-label' }, 'Instructions' ), React.createElement( 'div', { className: 'left-text' }, recipe.instructions ), React.createElement( 'div', { className: 'buttons' }, React.createElement( 'span', { onClick: function onClick() { return _this3.edit(i); }, className: 'edit-recipe' }, React.createElement( 'span', { className: 'label-text' }, 'Edit' ) ), React.createElement( 'div', { onClick: function onClick() { return _this3.props.store.deleteRecipe(i); }, className: 'delete-recipe' }, React.createElement( 'span', { className: 'label-text' }, 'Delete' ) ) ) ); }) ) ), React.createElement( Button, { bsStyle: 'primary', bsSize: 'large', id: 'show', onClick: this.open }, 'Add recipe' ), this.state.showModal ? React.createElement(AddRecipe, { recipeId: this.state.editRecipeId, show: this.state.showModal, onClose: this.close, store: store, label: this.state.editRecipeId !== null ? 'Save' : 'Add it!' }) : null ); }; return RecipeBox;
}(React.Component));
var AddRecipe = observer(function (_React$Component2) { _inherits(AddRecipe, _React$Component2); function AddRecipe(props) { _classCallCheck(this, AddRecipe); var _this4 = _possibleConstructorReturn(this, _React$Component2.call(this, props)); _this4.add = function () { _this4.props.store.addRecipe({ recipeTitle: _this4.state.recipeTitle, ingredients: _this4.state.ingredients, instructions: _this4.state.instructions }); _this4.setState({ recipeTitle: '', ingredients: [{ name: '', qty: '', unit: '' }], instructions: '' }); _this4.props.onClose(); }; _this4.edit = function () { _this4.props.store.editRecipe(_this4.props.recipeId, { recipeTitle: _this4.state.recipeTitle, ingredients: _this4.state.ingredients, instructions: _this4.state.instructions }); _this4.setState({ recipeTitle: '', ingredients: [{ name: '', qty: '', unit: '' }], instructions: '' }); _this4.props.onClose(); }; _this4.handleIngredientDelete = function (i) { _this4.setState({ ingredients: _this4.state.ingredients.filter(function (ing, ingIndex) { return ingIndex !== i; }) }); }; props.recipeId !== null ? _this4.state = { recipeTitle: _this4.props.store.recipes[_this4.props.recipeId].recipeTitle, ingredients: _this4.props.store.recipes[_this4.props.recipeId].ingredients, instructions: _this4.props.store.recipes[_this4.props.recipeId].instructions } : _this4.state = { recipeTitle: '', ingredients: [{ name: '', qty: '', unit: '' }], instructions: '' }; return _this4; } AddRecipe.prototype.handleTitleChange = function handleTitleChange(e) { this.setState({ recipeTitle: e.target.value }); }; AddRecipe.prototype.addIngredientsInput = function addIngredientsInput() { this.setState({ ingredients: this.state.ingredients.concat([{}]) }); }; AddRecipe.prototype.handleInstructionsChange = function handleInstructionsChange(e) { this.setState({ instructions: e.target.value }); }; AddRecipe.prototype.handleIngredientNameChange = function handleIngredientNameChange(i, e) { this.setState({ ingredients: [].concat(this.state.ingredients.slice(0, i), [_extends({}, this.state.ingredients[i], { name: e.target.value })], this.state.ingredients.slice(i + 1, this.state.ingredients.length)) }); }; AddRecipe.prototype.handleIngredientQtyChange = function handleIngredientQtyChange(i, e) { this.setState({ ingredients: [].concat(this.state.ingredients.slice(0, i), [_extends({}, this.state.ingredients[i], { qty: e.target.value })], this.state.ingredients.slice(i + 1, this.state.ingredients.length)) }); }; AddRecipe.prototype.handleIngredientUnitChange = function handleIngredientUnitChange(i, e) { this.setState({ ingredients: [].concat(this.state.ingredients.slice(0, i), [_extends({}, this.state.ingredients[i], { unit: e.target.value })], this.state.ingredients.slice(i + 1, this.state.ingredients.length)) }); }; AddRecipe.prototype.render = function render() { var _this5 = this; return React.createElement( 'div', null, React.createElement( Modal, { show: this.props.show, onHide: this.props.onClose }, React.createElement( Modal.Header, { closeButton: true }, React.createElement( Modal.Title, null, 'Your Recipe' ) ), React.createElement( Modal.Body, null, React.createElement( 'label', { className: 'modal-label' }, 'Title' ), ' ', React.createElement('br', null), React.createElement('input', { className: 'modal-input', value: this.state.recipeTitle, onChange: this.handleTitleChange.bind(this), type: 'text', id: 'title', placeholder: 'New recipe name here' }), ' ', React.createElement('br', null), React.createElement( 'label', { className: 'modal-label' }, 'Ingredients' ), React.createElement( 'button', { className: 'btn btn-primary btn-xs', onClick: this.addIngredientsInput.bind(this) }, '+' ), ' ', React.createElement('br', null), React.createElement( 'div', null, this.state.ingredients.map(function (_ref, i) { var name = _ref.name; var qty = _ref.qty; var unit = _ref.unit; return React.createElement( 'div', { key: i }, React.createElement('input', { className: 'modal-input', value: name, type: 'text', placeholder: 'Ingredient', onChange: _this5.handleIngredientNameChange.bind(_this5, i) }), React.createElement('input', { className: 'modal-input', type: 'number', value: qty, placeholder: 'Qty', size: '3', onChange: _this5.handleIngredientQtyChange.bind(_this5, i) }), React.createElement('input', { className: 'modal-input', type: 'text', value: unit, placeholder: 'Unit', size: '3', onChange: _this5.handleIngredientUnitChange.bind(_this5, i) }), React.createElement( 'button', { className: 'btn btn-danger btn-xs', onClick: function onClick() { return _this5.handleIngredientDelete(i); } }, 'X' ) ); }) ), React.createElement('br', null), React.createElement( 'label', { className: 'modal-label' }, 'Instructions' ), ' ', React.createElement('br', null), React.createElement('input', { className: 'modal-input', type: 'text', value: this.state.instructions, onChange: this.handleInstructionsChange.bind(this) }) ), React.createElement( Modal.Footer, null, React.createElement( Button, { className: 'btn btn-primary', onClick: this.props.recipeId === null ? this.add : this.edit }, this.props.label ), React.createElement( Button, { className: 'btn btn-danger', onClick: this.props.onClose }, 'Cancel' ) ) ) ); }; return AddRecipe;
}(React.Component));
var App = function (_Component) { _inherits(App, _Component); function App() { _classCallCheck(this, App); return _possibleConstructorReturn(this, _Component.apply(this, arguments)); } App.prototype.render = function render() { return React.createElement(RecipeBox, { store: recipeStore }); }; return App;
}(Component);
ReactDOM.render(React.createElement(App, null), document.getElementById('container'));
FCC Recipe Box - Script Codes
FCC Recipe Box - Script Codes
Home Page Home
Developer Victoria
Username Enieste
Uploaded December 02, 2022
Rating 3
Size 7,585 Kb
Views 6,072
Do you need developer help for FCC Recipe Box?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Victoria (Enieste) Script Codes
Create amazing sales emails with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!