Skip to content
Open

Sass #128

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions amanda_keogh/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ <h2>{{morderor.name}}</h2>
<button class="form-button" type="submit">Submit Changes</button>
<button class="form-button" data-ng-click="morderor.editing = false; refresh(morderor)">Cancel!!</button>
</form>
<button>Pick Me!</button>
<button class="form-button">Pick Me!</button>
<button class="form-button" data-ng-if="!morderor.editing" data-ng-click="morderor.editing = true">Change me!</button>
<button class="form-button" data-ng-click="remove(morderor)">Kill me!</button>
<button class="delete-button" data-ng-click="remove(morderor)">Kill me!</button>
</div>
</div>
</main>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ module.exports = function(app) {
};

$scope.create = function(morderor) {
$http.post('api/morderors', morderor)
$http.post('/api/morderors', morderor)
.then(function(res) {
$scope.morderors.push(res.data);
$scope.newMorderor = {};
console.log('morderor created');
}, function(err) {
console.log(err.data);
});
Expand All @@ -41,12 +42,12 @@ module.exports = function(app) {
console.log('morderor updated.');
}, function(err) {
console.log(err.data);
})
});
};

$scope.remove = function(morderor) {
$scope.morderors.splice($scope.morderors.indexOf(morderor), 1);
$http.delete('api/morderors/' + morderor._id)
$http.delete('/api/morderors/' + morderor._id)
.then(function(res) {
console.log('morderor removed!');
}, function(err) {
Expand All @@ -56,7 +57,7 @@ module.exports = function(app) {
};

$scope.refresh = function(morderor) {
$http.get('api/morderors/' + morderor._id)
$http.get('/api/morderors/' + morderor._id)
.then(function(res) {
console.log('refresh!');
$scope.morderors[$scope.morderors.indexOf(morderor)] = res.data[0];
Expand Down
9 changes: 9 additions & 0 deletions amanda_keogh/app/sass/_base.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
body {
color: $black;
background-color: $background-color;
font-family: 'Open Sans', sans-serif;
}

form {
background-color: $accent-color;
}
8 changes: 8 additions & 0 deletions amanda_keogh/app/sass/_config.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$blue: #51c1bc;
$white: #f6f4f0;
$black: #646464;
$yellow: #e5a919;

$background-color: $white;
$accent-color: $blue;
$second-accent: $yellow;
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
header {
background-color: #51c1bc;
background-color: $accent-color;
padding: 1.5em;
h1 {
margin: 0px;
}
}

@media all and (min-width: 420px) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.morderor {
margin: 25px;
border: 1px solid #646464;
border: 1px solid $black;
padding: 1em;
text-align: center;
}
Expand All @@ -21,10 +21,6 @@ form[name="newMorderorForm"] {
text-align: center;
}

.form-button {
margin-top: 10px;
}

.vs-box {
padding-top: 25px;
padding-bottom: 25px;
Expand Down
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions amanda_keogh/app/sass/application.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@import 'config';
@import 'buttons/buttons';
@import 'reset';
@import 'base';
@import 'layout';
@import 'modules';
@import 'state';
17 changes: 0 additions & 17 deletions amanda_keogh/app/sass/base.scss

This file was deleted.

22 changes: 22 additions & 0 deletions amanda_keogh/app/sass/buttons/_buttons.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
@import 'mixins';

%button-defaults {
border: 1px solid $black;
border-radius: 5px;
}

button {
@extend %button-defaults;
@include button($second-accent, $white, "large");
}

.form-button {
@extend button-defaults;
@include button($second-accent, $white, "small");
margin-top: 10px;
}

.delete-button {
@extend button-defaults;
@include button(#ff0000, $white, "small");
}
21 changes: 21 additions & 0 deletions amanda_keogh/app/sass/buttons/_mixins.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@mixin button-size($size) {
@if $size == "small" {
font-size: .75em;
padding: .5em;
}
@else if $size == "large" {
font-size: 1.2em;
padding: .75em;
}
}

@mixin button($background, $color, $size) {
@include button-size($size);
background-color: $background;
color: $color;

&:hover,
&:active {
background-color: lighten($background, 8%);
}
}
8 changes: 4 additions & 4 deletions amanda_keogh/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ gulp.task('webpack:test', function() {
.pipe(gulp.dest('test/client/'));
});

gulp.task('webpack:sass', function() {
return gulp.src(['app/sass/reset.scss', 'app/sass/base.scss', 'app/sass/layout.scss', 'app/sass/modules.scss', 'app/sass/state.scss'])
gulp.task('sass', function() {
return gulp.src(['app/sass/**/*.scss'])
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(sass().on('error', sass.logError))
.pipe(concatCss('styles.min.css'))
Expand All @@ -51,7 +51,7 @@ gulp.task('webpack:sass', function() {
.pipe(gulp.dest('build/'));
})

gulp.task('build:dev', ['static:dev', 'webpack:dev', 'webpack:sass']);
gulp.task('build:dev', ['static:dev', 'webpack:dev', 'sass']);

/* * * * * * * * * * * * * * * * * *
LINT TASKS
Expand Down Expand Up @@ -99,7 +99,7 @@ gulp.task('mocha', function() {
gulp.task('buildWatch', function() {
gulp.watch(htmlFiles, ['static:dev']);
gulp.watch('app/js/**/*.js', ['build:dev']);
gulp.watch('app/sass/**/*.sass', ['webpack:sass']);
gulp.watch('app/sass/**/*.scss', ['sass']);
});

// backend
Expand Down
53 changes: 46 additions & 7 deletions amanda_keogh/test/client/morderor_controller_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,58 @@ describe('morderors controller', function() {
});

it('should add to the morderors array with GETall', function() {
$httpBackend.expectGET('/api/morderors').respond(200, [{_id: 1, name: 'testthing', verb: 'testaction'}]);
$httpBackend.expectGET('/api/morderors').respond(200, [{_id: 1, name: 'getall test', verb: 'testaction'}]);
$scope.getAll();
$httpBackend.flush();
expect($scope.morderors[0].name).toBe('testthing');
expect($scope.morderors[0].name).toBe('getall test');
});

it('should post a new bear', function() {
$httpBackend.expectPOST('/api/morderors', {name: 'testthing', verb: 'testaction'}).respond(200, {name: 'differenttestthing'});
it('should post a new morderor', function() {
$httpBackend.expectPOST('/api/morderors', {name: 'testthing', verb: 'testaction'}).respond(200, {name: 'post test'});
expect($scope.morderors.length).toBe(0);
$scope.create({name: 'testthing'});
$scope.create({name: 'testthing', verb:'testaction'});
$httpBackend.flush();
expect($scope.morderors[0].name).toBe('differenttestthing');
})
expect($scope.morderors[0].name).toBe('post test');
expect($scope.newMorderor.name).toBe(undefined);
});

it('should edit a morderor', function() {
// test that "editing" property is changed
$httpBackend.expectPUT('/api/morderors/test', {_id: 'test', name: 'a test?', verb: 'no really', editing: false}).respond(200, {name: 'put test'});
$scope.update({_id: 'test', name: 'a test?', verb: 'no really'});
$httpBackend.flush();
});
});

//tests which require a dummy morderer in list
describe('delete, refresh', function() {
beforeEach(angular.mock.inject(function(_$httpBackend_, $rootScope) {
$httpBackend = _$httpBackend_;
$scope = $rootScope.$new();
$ControllerConstructor('IntroController', {$scope: $scope});
$scope.morderors = [{_id: 'test', name: 'test name', verb: 'test verb'}];
}));

afterEach(function() {
$httpBackend.verifyNoOutstandingExpectation();
$httpBackend.verifyNoOutstandingRequest();
});

it('should delete a morderor', function() {
$httpBackend.expectDELETE('/api/morderors/test').respond(200);
$scope.remove({_id: 'test'});
$httpBackend.flush();
expect($scope.morderors[0]).toBe(undefined);
});

it('should refresh the current list with new information', function() {
$httpBackend.expectGET('/api/morderors/test').respond(200, [{_id: 'test', name: 'super diff'}]);
$scope.refresh($scope.morderors[0]);
$httpBackend.flush();
expect($scope.morderors[0].name).toBe('super diff');
});

});


})