Add user profile side nav

This commit is contained in:
Toby Zerner 2015-03-12 12:59:32 +10:30
parent 720fbd6ac6
commit edac830371
8 changed files with 80 additions and 30 deletions

View File

@ -20,7 +20,7 @@ export default DS.Model.extend(HasItemLists, {
readTime: DS.attr('date'), readTime: DS.attr('date'),
discussionsCount: DS.attr('number'), discussionsCount: DS.attr('number'),
postsCount: DS.attr('number'), commentsCount: DS.attr('number'),
canEdit: DS.attr('boolean'), canEdit: DS.attr('boolean'),
canDelete: DS.attr('boolean'), canDelete: DS.attr('boolean'),

View File

@ -13,7 +13,8 @@ Router.map(function() {
}); });
this.resource('user', {path: '/u/:username'}, function() { this.resource('user', {path: '/u/:username'}, function() {
this.route('activity'); this.route('activity', {path: '/'});
this.route('discussions');
this.route('posts'); this.route('posts');
this.route('edit'); this.route('edit');
}); });

View File

@ -3,5 +3,11 @@ import Ember from 'ember';
export default Ember.Route.extend({ export default Ember.Route.extend({
model: function(params) { model: function(params) {
return this.store.find('user', params.username); return this.store.find('user', params.username);
},
afterModel: function(model) {
if (!model.get('joinTime')) {
return model.reload();
}
} }
}); });

View File

@ -21,6 +21,11 @@
margin: 10px 0; margin: 10px 0;
background-color: @fl-body-control-bg; background-color: @fl-body-control-bg;
} }
& .count {
font-weight: bold;
font-size: 12px;
margin-left: 5px;
}
} }
.dropdown-split.item-count-1 { .dropdown-split.item-count-1 {
& .btn { & .btn {
@ -105,3 +110,25 @@
.box-shadow(none); .box-shadow(none);
} }
} }
.nav-list() {
& > li > a {
padding: 8px 0;
color: @fl-body-muted-color;
&:hover {
background: none;
color: @link-hover-color;
}
& .fa {
margin-right: 8px;
font-size: 15px;
}
}
& > li.active > a {
background: none;
color: @fl-body-primary-color;
font-weight: bold;
}
}

View File

@ -1,7 +1,7 @@
// ------------------------------------ // ------------------------------------
// Sidebar // Sidebar
.index-nav > ul { .side-nav > ul {
margin: 0; margin: 0;
padding: 0; padding: 0;
list-style: none; list-style: none;
@ -13,41 +13,22 @@
// larger than a phone, however, we need to affix the sidebar and expand the // larger than a phone, however, we need to affix the sidebar and expand the
// .dropdown-select into a plain list. // .dropdown-select into a plain list.
@media @tablet, @desktop, @desktop-hd { @media @tablet, @desktop, @desktop-hd {
.index-nav { .side-nav {
// Expand the dropdown-select component into a normal nav list // Expand the dropdown-select component into a normal nav list.
// @todo Extract this into a mixin as we'll probably need to do it elsewhere.
& .dropdown-select { & .dropdown-select {
display: block; display: block;
.expand-dropdown(); .expand-dropdown();
& .dropdown-menu { & .dropdown-menu {
& > li > a { .nav-list();
padding: 8px 0;
color: @fl-body-muted-color;
&:hover {
background: none;
color: @link-hover-color;
}
& .fa {
margin-right: 8px;
font-size: 15px;
}
}
& > li.active > a {
background: none;
color: @fl-body-primary-color;
font-weight: bold;
}
} }
} }
} }
} }
@media @tablet { @media @tablet {
.index-nav { .side-nav {
padding: 15px 0; padding: 15px 0;
white-space: nowrap; white-space: nowrap;
overflow: auto; overflow: auto;
@ -78,7 +59,7 @@
} }
@media @desktop, @desktop-hd { @media @desktop, @desktop-hd {
.index-nav { .side-nav {
float: left; float: left;
&, & > ul { &, & > ul {
@ -94,6 +75,8 @@
margin-bottom: 10px; margin-bottom: 10px;
} }
} }
}
.index-nav {
& .new-discussion { & .new-discussion {
display: block; display: block;
margin-bottom: 20px; margin-bottom: 20px;

View File

@ -6,7 +6,7 @@
<div class="container"> <div class="container">
<nav class="index-nav"> <nav class="side-nav index-nav">
{{ui/item-list items=view.sidebar}} {{ui/item-list items=view.sidebar}}
</nav> </nav>

View File

@ -1,7 +1,7 @@
{{user/user-card user=model class="hero user-hero" editable=true controlsButtonClass="btn btn-default"}} {{user/user-card user=model class="hero user-hero" editable=true controlsButtonClass="btn btn-default"}}
<div class="container"> <div class="container">
<nav class="user-nav"> <nav class="side-nav user-nav">
{{ui/item-list items=view.sidebar}} {{ui/item-list items=view.sidebar}}
</nav> </nav>

View File

@ -1,7 +1,40 @@
import Ember from 'ember'; import Ember from 'ember';
import HasItemLists from 'flarum/mixins/has-item-lists'; import HasItemLists from 'flarum/mixins/has-item-lists';
import NavItem from 'flarum/components/ui/nav-item';
import DropdownSelect from 'flarum/components/ui/dropdown-select';
var precompileTemplate = Ember.Handlebars.compile;
export default Ember.View.extend(HasItemLists, { export default Ember.View.extend(HasItemLists, {
itemLists: ['sidebar'] itemLists: ['sidebar'],
populateSidebar: function(items) {
var nav = this.populateItemList('nav');
items.pushObjectWithTag(DropdownSelect.extend({items: nav, listItemClass: 'title-control'}), 'nav');
},
populateNav: function(items) {
items.pushObjectWithTag(NavItem.extend({
label: 'Activity',
icon: 'user',
layout: precompileTemplate('{{#link-to "user.activity"}}{{fa-icon icon}} {{label}}{{/link-to}}')
}), 'activity');
items.pushObjectWithTag(NavItem.extend({
label: 'Discussions',
icon: 'reorder',
badge: Ember.computed.alias('user.discussionsCount'),
user: this.get('controller.model'),
layout: precompileTemplate('{{#link-to "user.discussions"}}{{fa-icon icon}} {{label}} <span class="count">{{badge}}</span>{{/link-to}}')
}), 'discussions');
items.pushObjectWithTag(NavItem.extend({
label: 'Posts',
icon: 'comment-o',
badge: Ember.computed.alias('user.commentsCount'),
user: this.get('controller.model'),
layout: precompileTemplate('{{#link-to "user.posts"}}{{fa-icon icon}} {{label}} <span class="count">{{badge}}</span>{{/link-to}}')
}), 'posts');
}
}); });