Skip to content

Commit c83e542

Browse files
committed
snippet list scaffolded
1 parent 092a2f3 commit c83e542

12 files changed

Lines changed: 202 additions & 13 deletions

File tree

src/_bootstrap.scss

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
// Core variables and mixins
2-
@import "../node_modules/bootstrap-sass/assets/stylesheets/bootstrap/variables";
3-
@import "../node_modules/bootstrap-sass/assets/stylesheets/bootstrap/mixins";
2+
@import "variables";
3+
@import "mixins";
44

55
// Reset and dependencies
66
@import "../node_modules/bootstrap-sass/assets/stylesheets/bootstrap/normalize";
77
@import "../node_modules/bootstrap-sass/assets/stylesheets/bootstrap/print";
8-
// @import "../node_modules/bootstrap-sass/assets/stylesheets/bootstrap/glyphicons";
98

109
// Core CSS
1110
@import "../node_modules/bootstrap-sass/assets/stylesheets/bootstrap/scaffolding";

src/_mixins.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@import "../node_modules/bootstrap-sass/assets/stylesheets/bootstrap/mixins";

src/_variables.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@import "../node_modules/bootstrap-sass/assets/stylesheets/bootstrap/variables";
2+
3+
$side-view-bg: $navbar-inverse-bg;
4+
$side-view-color: $navbar-inverse-color;
5+
$side-view-link-color: $navbar-inverse-link-color;
6+
$side-view-link-active-color: $navbar-inverse-link-active-color;
7+
$side-view-link-hover-color: $navbar-inverse-link-hover-color;
8+
$side-view-link-active-bg: $navbar-inverse-link-active-bg;
9+
$side-view-link-hover-bg: $navbar-inverse-link-hover-bg;

src/directives/side-nav.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
12
angular.module('codexen.directives')
23
.directive('sideNav', function(){
34
return {
4-
templateUrl:'directives/side-nav.tpl.html',
5-
controller:'SideNavController as vm'
5+
templateUrl: 'directives/side-nav.tpl.html',
6+
controller: 'SideNavController as vm'
67
}
78
})
89
.controller('SideNavController', function($auth, User, $rootScope, $scope){

src/directives/side-nav.scss

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@import "../variables";
2+
3+
$side-view-link-hover-color: $gray-dark;
4+
$side-view-link-active-color: $link-color;
5+
$side-view-link-active-bg: $body-bg;
6+
7+
#side-view ul.nav.nav-pills{
8+
li a{
9+
color: white;
10+
&:hover{
11+
color: $side-view-link-hover-color;
12+
}
13+
}
14+
15+
li.active a{
16+
color:$side-view-link-active-color;
17+
background-color: $side-view-link-active-bg;
18+
}
19+
}

src/directives/side-nav.tpl.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
<div class="current-user">
32
<div ng-if="vm.currentUser">
43
<img width="30" ng-src="http://www.gravatar.com/avatar/{{ vm.currentUser.email | gravatar }}">
@@ -20,6 +19,9 @@
2019

2120
<p>Side Nav</p>
2221
<ul class="nav nav-pills nav-stacked">
22+
<li ui-sref-active="active">
23+
<a ui-sref="home"><i class="fa fa-home"></i> Home</a>
24+
</li>
2325
<li>
2426
<a href="">My Page</a>
2527
</li>

src/main.scss

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@ $fa-font-path: "./resources/fonts";
44
@import "bootstrap";
55
@import "ui-select";
66

7-
@import "../node_modules/bootstrap-sass/assets/stylesheets/bootstrap/variables";
8-
9-
$side-view-bg: $navbar-inverse-bg;
10-
$side-view-color: $navbar-inverse-color;
11-
127
html {
138
overflow: hidden;
149
height: 100%;
@@ -17,6 +12,10 @@ html {
1712
body {
1813
height: 100%;
1914
overflow: auto;
15+
font-family: "Lato", sans-serif;
16+
}
17+
label{
18+
font-family: "Lato", sans-serif;
2019
}
2120

2221
#side-view{
@@ -45,5 +44,5 @@ body {
4544
left: 200px;
4645
right: 0;
4746
overflow-x: hidden;
48-
overflow-y: scroll;
47+
overflow-y: auto;
4948
}

src/services/snippet.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
angular.module('codexen.services')
2+
.factory('Snippet', function ($http, $auth, apiUrl) {
3+
var findByUserId = function (userId) {
4+
var url = apiUrl + 'snippets'
5+
6+
return $http.get(url, {
7+
params: {
8+
userId: userId
9+
}
10+
})
11+
}
12+
13+
return {
14+
findByUserId: findByUserId
15+
}
16+
})

src/states/home/home.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* global angular */
2+
angular.module('codexen.states')
3+
.controller('HomeController', function ($auth, Snippet, $scope) {
4+
var vm = this
5+
6+
vm.isLoaded = false
7+
8+
var laodSnippets = function () {
9+
if ($auth.isAuthenticated) {
10+
console.log($auth.getPayload())
11+
var userId = $auth.getPayload().sub
12+
Snippet.findByUserId(userId)
13+
.success(function (data) {
14+
console.log('snippets fetched', data.snippets)
15+
vm.isLoaded = true
16+
vm.snippets = data.snippets
17+
vm.isGuest = false
18+
})
19+
}else {
20+
vm.isLoaded = true
21+
vm.isGuest = true
22+
vm.snippets = void 0
23+
}
24+
}
25+
26+
laodSnippets()
27+
28+
$scope.$on('userSignIn', function () {
29+
laodSnippets()
30+
})
31+
32+
$scope.$on('userSignOut', function () {
33+
laodSnippets()
34+
})
35+
36+
})

src/states/home/home.scss

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
@import "../../variables";
2+
@import "../../mixins";
3+
4+
$left-pane-width: 275px;
5+
6+
7+
$pane-border-color: #ddd;
8+
$snippet-list-border-color: #ddd;
9+
$snippet-list-item-hover-bg: #EEE;
10+
11+
.home-state{
12+
position: absolute;
13+
top:0;
14+
left:0;
15+
right:0;
16+
bottom:0;
17+
.left-pane{
18+
position: absolute;
19+
top: 0;
20+
bottom: 0;
21+
left: 0;
22+
width: $left-pane-width;
23+
overflow-x: hidden;
24+
overflow-y: auto;
25+
border-right: solid 1px $pane-border-color;
26+
.snippet-list{
27+
list-style: none;
28+
padding: 0;
29+
li{
30+
padding: 5px;
31+
border-bottom: solid 1px $snippet-list-border-color;
32+
h4{
33+
margin: 0;
34+
}
35+
&:hover{
36+
background-color: $snippet-list-item-hover-bg;
37+
}
38+
p{
39+
margin:0;
40+
}
41+
}
42+
}
43+
}
44+
.right-pane{
45+
position: absolute;
46+
top: 0;
47+
bottom: 0;
48+
left: $left-pane-width;
49+
right: 0;
50+
}
51+
}

0 commit comments

Comments
 (0)