Add user-badge component.

This commit is contained in:
Vikhyat Korrapati 2014-04-16 15:32:57 +05:30
parent cba7d3fc82
commit 057c56ef9b
5 changed files with 41 additions and 32 deletions

View File

@ -0,0 +1,7 @@
Discourse.UserBadgeComponent = Ember.Component.extend({
tagName: 'span',
badgeTypeClassName: function() {
return "badge-type-" + this.get('badge.badge_type.name').toLowerCase();
}.property('badge.badge_type.name')
});

View File

@ -0,0 +1,4 @@
<span {{bind-attr class=":user-badge badgeTypeClassName" data-badge-name="badge.name" title="badge.description"}}>
<i class='fa fa-certificate'></i>
{{badge.name}}
</span>

View File

@ -10,7 +10,7 @@
{{#if showBadges}}
<div class="badge-section">
{{#each user.featured_user_badges}}
<span class="user-badge badge-type-{{unbound badge.badge_type_id}}"><i class='fa fa-certificate'></i> {{badge.name}}</span>
{{user-badge badge=badge}}
{{/each}}
{{#if showMoreBadges}}
<span class="btn more-user-badges">{{i18n badges.more_badges count=moreBadgesCount}}</span>

View File

@ -102,39 +102,12 @@
font-size: 14px;
margin-bottom: -8px;
}
}
.more-user-badges {
@extend .user-badge;
padding: 4px 8px;
}
}
}
.user-badge, .more-user-badges {
font-size: 12px;
margin: 0;
line-height: 16px;
display: inline-block;
.fa {
padding-right: 5px;
font-size: 16px;
}
}
.user-badge {
padding: 3px 8px;
border: 1px solid $secondary-border-color;
}
.more-user-badges {
padding: 4px 8px;
}
.badge-type-1 .fa-certificate {
color: #A67D3D;
}
.badge-type-2 .fa-certificate {
color: silver;
}
.badge-type-1 .fa-certificate {
color: gold;
}

View File

@ -0,0 +1,25 @@
.user-badge {
padding: 3px 8px;
border: 1px solid $secondary-border-color;
font-size: 12px;
line-height: 16px;
margin: 0;
display: inline-block;
.fa {
padding-right: 5px;
font-size: 16px;
}
&.badge-type-gold .fa {
color: #ffd700;
}
&.badge-type-silver .fa {
color: #c0c0c0;
}
&.badge-type-bronze .fa {
color: #cd7f32;
}
}