-
Notifications
You must be signed in to change notification settings - Fork 19
Refactor SCSS into file folders and Refactored with Services and Directives #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
KenjiCrosland
wants to merge
28
commits into
codefellows-sea-d45-javascript:master
Choose a base branch
from
KenjiCrosland:refactor
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
5556d31
Following in class code
KenjiCrosland 2d696eb
Add first auth test
KenjiCrosland 8357427
Auth tests pass
KenjiCrosland 0bc3b92
Unique user and auth tests pass
KenjiCrosland 3ff1c51
Adding a few comments
KenjiCrosland 790ea01
Merge pull request #1 from KenjiCrosland/auth
KenjiCrosland dac2231
Add before all hook
KenjiCrosland 330f3fc
Add simple client
KenjiCrosland c118953
Remove build files
KenjiCrosland 2683f87
Small change
KenjiCrosland 88ba284
Solving merge conflict with .gitignore file (hopefully)
KenjiCrosland 069f913
Solving merge conflict with .gitignore file (hopefully)
KenjiCrosland 9ff9399
Add edit cancellation
KenjiCrosland 0eabc64
with .gitignore
KenjiCrosland 5f39610
Karma tests pass
KenjiCrosland 7a1f084
Add css
KenjiCrosland 1ba004e
Change css
KenjiCrosland b70dab4
Last css before moving on to SASS
KenjiCrosland 82a58ab
It just got SASSy in here
KenjiCrosland 3e2e59b
Can remove ingredients from recipes
KenjiCrosland 0c4b0e2
Add advanced SASS
KenjiCrosland 63017a1
Add semicolons
KenjiCrosland 8c35d30
Adding cf resource service
KenjiCrosland 559287c
Refactor recipe form
KenjiCrosland 8ecc543
Add card directive
KenjiCrosland ba985a5
Use card directive in index.html
KenjiCrosland 95b0daa
Refactored scss into file folders
KenjiCrosland 84b8ae0
Moved repetitive html into directives
KenjiCrosland File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| **/*.sw? | ||
| node_modules | ||
| db | ||
| build | ||
| **/*bundle.js |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
| <link rel="stylesheet" type="text/css" href="application.css"> | ||
| <title>Our Super Recipe App</title> | ||
| </head> | ||
| <body data-ng-app="recipeApp"> | ||
| <main class="container" data-ng-controller="RecipesController" data-ng-init="getAll()"> | ||
| <section class="row top-row"> | ||
| <h1 class="main-headline">Our Super Recipe App</h1> | ||
| </section> | ||
| <div data-card-directive | ||
| header="h2" | ||
| data-header-text="Add a New Recipe!" | ||
| data-width="row"> | ||
| <form class="card-form" name="newRecipeForm" data-ng-submit="create(newRecipe)"> | ||
| <label for="newRecipeTitle">Recipe Name: </label> | ||
| <input type="text" id="newRecipeTitle" required data-ng-model="newRecipe.title"> | ||
| <button class="btn" type="submit" data-ng-disabled="newRecipeForm.$invalid">Create New Recipe</button> | ||
| </form> | ||
| </div> | ||
| <div class="row"> | ||
| <div data-card-directive | ||
| header="h3" | ||
| data-header-text="Recipe List" | ||
| data-width="one-third column"> | ||
| <ul class="recipe-list"> | ||
| <li data-ng-repeat="recipe in recipes"> | ||
| <button type="button" class="btn" data-ng-click="seeRecipe(recipe)"> | ||
| {{recipe.title}} | ||
| </button> | ||
| </li> | ||
| </ul> | ||
| </div> | ||
| <div data-card-directive | ||
| data-ng-if="currentRecipe !== null" | ||
| data-header-text="{{currentRecipe.title}}" | ||
| data-width="two-thirds column"> | ||
| <div data-ng-if="currentRecipe.editing" data-recipe-form-directive | ||
| header="h3" | ||
| data-button-text="Update Recipe" | ||
| data-form-name="recipeForm{{currentRecipe._id}}" | ||
| data-recipe="currentRecipe" | ||
| data-add-ingredient-field="addIngredientField(recipe, ingredient)" | ||
| data-remove-ingredient-field="removeIngredientField(recipe)" | ||
| data-cancel="cancelEditing(recipe)" | ||
| data-save="update(recipe)"> | ||
| </div> | ||
| <div data-ng-if="!currentRecipe.editing"> | ||
| <strong>Ingredients:</strong> | ||
| <ul> | ||
| <li data-ng-repeat="ingredient in currentRecipe.ingredients"> | ||
| {{ingredient}} | ||
| </li> | ||
| </ul> | ||
| <button class="btn btn-edit" data-ng-click="makeCopy(currentRecipe)">Edit</button> | ||
| <button class="btn btn-delete" data-ng-click="remove(currentRecipe)">Delete</button> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </main> | ||
| <script src="bundle.js"></script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| require('angular/angular'); | ||
| var angular = window.angular; | ||
|
|
||
| var recipeApp = angular.module('recipeApp', []); | ||
| require('./services/services')(recipeApp); | ||
| require('./recipes/recipes')(recipeApp); |
64 changes: 64 additions & 0 deletions
64
kenji_crosland/app/js/recipes/controllers/recipes_controller.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| module.exports = function(app) { | ||
| app.controller('RecipesController', ['$scope', '$http', 'cfResource', function($scope, $http, cfResource){ | ||
| $scope.recipes = []; | ||
| $scope.editing = {}; | ||
| $scope.currentRecipe = null; | ||
|
|
||
| $scope.seeRecipe = function(recipe){ | ||
| $scope.currentRecipe = recipe; | ||
| } | ||
|
|
||
| $scope.makeCopy = function(recipe) { | ||
| recipe.editing = true; | ||
| $scope.editing[recipe._id] = angular.copy(recipe); | ||
| } | ||
|
|
||
| $scope.cancelEditing = function(recipe) { | ||
| $scope.editing[recipe._id].editing = false; | ||
| for(i = 0; i < $scope.recipes.length; i++){ | ||
| if($scope.recipes[i]._id === recipe._id){ | ||
| angular.copy($scope.editing[recipe._id], $scope.recipes[i]); | ||
| delete $scope.editing[recipe._id]; | ||
| return; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| $scope.addIngredientField = function(recipe) { | ||
| if (recipe.ingredients[recipe.ingredients.length - 1] !== "") { | ||
| recipe.ingredients.push(""); | ||
| } | ||
| } | ||
|
|
||
| $scope.removeIngredientField = function(recipe, ingredient) { | ||
| recipe.ingredients.splice(recipe.ingredients.indexOf(ingredient), 1); | ||
| } | ||
|
|
||
| $scope.getAll = function() { | ||
| cfResource('/allrecipes').getAll(function(err, data){ | ||
| if (err) return err; | ||
| $scope.recipes = data; | ||
| }); | ||
| }; | ||
|
|
||
| $scope.create = function(recipe) { | ||
| cfResource('/recipes', recipe).post(function(err, data){ | ||
| $scope.recipes.push(data); | ||
| }); | ||
| }; | ||
|
|
||
| $scope.update = function(recipe) { | ||
| recipe.editing = false; | ||
| cfResource('/recipes/' + recipe._id, recipe).put(function(err, data) { | ||
| console.log('Recipe updated!'); | ||
| }); | ||
| } | ||
|
|
||
| $scope.remove = function(recipe) { | ||
| $scope.recipes.splice($scope.recipes.indexOf(recipe), 1); | ||
| cfResource('/recipes/' + recipe._id).delete(function(err, data){ | ||
| console.log('Totes cool. Recipe is gone.') | ||
| }) | ||
| } | ||
| }]); | ||
| } |
15 changes: 15 additions & 0 deletions
15
kenji_crosland/app/js/recipes/directives/card_directive.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| module.exports = function(app) { | ||
| app.directive('cardDirective', function() { | ||
| return { | ||
| restrict: 'AC', | ||
| replace: true, | ||
| transclude: true, | ||
| templateUrl: '/templates/card_template.html', | ||
| scope: { | ||
| header: '@', | ||
| headerText: '@', | ||
| width: '@' //two columns, three columns, etc | ||
| } | ||
| } | ||
| }) | ||
| } |
19 changes: 19 additions & 0 deletions
19
kenji_crosland/app/js/recipes/directives/recipe_form_directive.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| module.exports = function(app) { | ||
| app.directive('recipeFormDirective', function() { | ||
| return { | ||
| restrict: 'AC', | ||
| replace: true, | ||
| templateUrl: '/templates/recipe_form_template.html', | ||
| scope: { | ||
| buttonText: '@', | ||
| formClass: '@', | ||
| formName: '@', | ||
| recipe: '=', | ||
| addIngredientField: '&', | ||
| removeIngredientField: '&', | ||
| cancel: '&', | ||
| save: '&' | ||
| } | ||
| } | ||
| }) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| module.exports = function(app){ | ||
| require('./controllers/recipes_controller')(app); | ||
| require('./directives/card_directive')(app); | ||
| require('./directives/recipe_form_directive')(app); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| //Made with help from watching in-class code videos | ||
|
|
||
| var handleSuccess = function(callback) { | ||
| return function(res) { | ||
| callback(null, res.data) | ||
| }; | ||
| }; | ||
|
|
||
| var handleFail = function(callback) { | ||
| return function(res) { | ||
| console.log(res); | ||
| callback(res.data); | ||
| } | ||
| } | ||
|
|
||
| module.exports = function(app) { | ||
| app.factory('cfResource', ['$http', function($http) { | ||
| return function(resourceName, resourceData) { | ||
| var resource = {}; | ||
| resource.getAll = function(callback) { | ||
| $http.get(resourceName) | ||
| .then(handleSuccess(callback), handleFail(callback)); | ||
| }; | ||
| resource.get = function(callback) { | ||
| $http.get(resourceName) | ||
| .then(handleSuccess(callback), handleFail(callback)); | ||
| }; | ||
| resource.post = function(callback) { | ||
| $http.post(resourceName, resourceData) | ||
| .then(handleSuccess(callback), handleFail(callback)); | ||
| }; | ||
| resource.put = function(callback) { | ||
| $http.put(resourceName, resourceData) | ||
| .then(handleSuccess(callback), handleFail(callback)); | ||
| } | ||
| resource.delete = function(callback) { | ||
| $http.delete(resourceName) | ||
| .then(handleSuccess(callback), handleFail(callback)); | ||
| } | ||
| return resource; | ||
| }; | ||
| }]); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module.exports = function(app) { | ||
| require('./cf_resource')(app); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| @import url(https://fonts.googleapis.com/css?family=Nunito); | ||
| @import url(https://fonts.googleapis.com/css?family=Dancing+Script); | ||
| @import url(https://fonts.googleapis.com/css?family=Ledger); | ||
|
|
||
| html {font-size: 1.125em;} | ||
|
|
||
| body { | ||
| font-family: 'Ledger', serif; | ||
| background-color: $light-background; | ||
| font-weight: 400; | ||
| line-height: 1.45; | ||
| color: #333; | ||
| } | ||
|
|
||
| p {margin-bottom: 1.3em;} | ||
|
|
||
| h1, h2, h3, h4 { | ||
| font-family: 'Ledger', serif; | ||
| margin: 1.414em 0 0.5em; | ||
| font-weight: inherit; | ||
| line-height: 1.2; | ||
| } | ||
|
|
||
| h1 { | ||
| margin-top: 0; | ||
| font-size: 2.074em; | ||
| } | ||
|
|
||
| h2 {font-size: 1.728em;} | ||
|
|
||
| h3 {font-size: 1.44em;} | ||
|
|
||
| h4 {font-size: 1.2em;} | ||
|
|
||
| small, .font_small {font-size: 0.833em;} | ||
|
|
||
| //Forms | ||
|
|
||
| input { | ||
| display: table-cell; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe put these in
%headings {...}and then extend it for all the headings that use it? Not necessarily better than what you have, but it would be Sass-ier :)