Skip to content

Commit

Permalink
Merge pull request child-first-authority-fcc-project#420 from dting/C…
Browse files Browse the repository at this point in the history
…hangeFromIsCollapsedToExpandedInSidebar

Reverse the starting state of the sidebar
  • Loading branch information
dting committed Apr 11, 2016
2 parents 4dca413 + 745e220 commit 7ca0ffa
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 26 deletions.
2 changes: 1 addition & 1 deletion client/app/main/visualization/visualization.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function VisualizationCtrl($scope, $timeout, School, Sidebar, Visualization) {
});
// Timeout used to redraw the chart after animation delay of resizing the
// sidebar.
$scope.$watch('sidebar.isCollapsed', function() {
$scope.$watch('sidebar.expanded', function() {
$timeout(function() {
if ($scope.loaded) {
$scope.cfaChartObj.reflow();
Expand Down
2 changes: 1 addition & 1 deletion client/components/navbar/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
ng-if="showSidebarToggle()"
ng-click="sidebar.toggle()">
<span class="sr-only">Toggle sidebar menu</span>
<i class="fa fa-bars fa-lg" ng-class="{'fa-rotate-90': sidebar.isCollapsed}"></i>
<i class="fa fa-bars fa-lg" ng-class="{'fa-rotate-90': !sidebar.expanded}"></i>
</button>
<a ui-sref="dashboard" class="navbar-brand">Child First Authority</a>
<button class="navbar-toggle"
Expand Down
2 changes: 1 addition & 1 deletion client/components/sidebar/sidebar.controller.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

angular.module('app').controller('SidebarCtrl',
function($scope, $state, $window, Auth, Sidebar, matchmedia) {
function($scope, $state, Auth, Sidebar, matchmedia) {
$scope.states = [{
name: 'dashboard',
url: 'dashboard',
Expand Down
2 changes: 1 addition & 1 deletion client/components/sidebar/sidebar.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ app.directive('sidebar', function(matchmedia) {
link: function(scope) {
function collapseSidebar(mediaQueryList) {
if (mediaQueryList.matches) {
scope.sidebar.isCollapsed = true;
scope.sidebar.expanded = false;
}
}
var maxCleanup = matchmedia.on('(max-width: 1200px)', collapseSidebar);
Expand Down
2 changes: 1 addition & 1 deletion client/components/sidebar/sidebar.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ul class="sidebar-nav nav-pills nav-stacked" ng-class="{isCollapsed: sidebar.isCollapsed}">
<ul class="sidebar-nav nav-pills nav-stacked" ng-class="{expanded: sidebar.expanded}">
<li ng-repeat="state in states"
ng-class="{active: active(state.name)}"
ng-if="!state.requiredRole || userIs(state.requiredRole)">
Expand Down
11 changes: 4 additions & 7 deletions client/components/sidebar/sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ sidebar {
flex: 1;
background-color: $teal;
background: linear-gradient(to right, $teal-d05, $teal);
width: 250px;
width: $cfa-unit;
margin: 0;
padding: 0;
list-style: none;
overflow-y: auto;
&.isCollapsed {
width: $cfa-unit;
&.expanded {
width: 250px;
}
li {
overflow: hidden;
Expand Down Expand Up @@ -59,15 +59,12 @@ sidebar {
}
a:hover {
background-color: $orange-l10;

}
}
}
transition: all 0.5s ease;
@media(max-width: 1200px) {
&.isCollapsed {
width: 0;
}
width: 0;
}
@include cfa-scrollbar(1px, 0, $teal, $teal-d05);
}
Expand Down
13 changes: 4 additions & 9 deletions client/components/sidebar/sidebar.service.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
'use strict';

angular.module('app').factory('Sidebar', function() {
function Sidebar() {
this.isCollapsed = true;
}

Sidebar.prototype.toggle = function() {
this.isCollapsed = !this.isCollapsed;
angular.module('app').service('Sidebar', function() {
this.expanded = false;
this.toggle = function() {
this.expanded = !this.expanded;
};

return new Sidebar();
});
10 changes: 5 additions & 5 deletions client/components/sidebar/sidebar.service.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ describe('Service: SidebarService', function() {
sidebar = _Sidebar_;
}));

it('should be created with isCollapsed true', function() {
expect(sidebar.isCollapsed).toBe(true);
it('should be created with expanded false', function() {
expect(sidebar.expanded).toBe(false);
});

it('should toggle isCollapsed when toggle() is called', function() {
expect(sidebar.isCollapsed).toBe(true);
it('should toggle expanded when toggle() is called', function() {
expect(sidebar.expanded).toBe(false);
sidebar.toggle();
expect(sidebar.isCollapsed).toBe(false);
expect(sidebar.expanded).toBe(true);
});
});

0 comments on commit 7ca0ffa

Please sign in to comment.