From dcd7f70741971737cb7cf1a57e85d5de60932463 Mon Sep 17 00:00:00 2001 From: Evan Lucas Date: Mon, 21 Mar 2016 22:53:41 -0500 Subject: [PATCH] lib: add badge component --- lib/views/components/badge.js | 7 +++++++ lib/views/sidebar/channels.js | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 lib/views/components/badge.js diff --git a/lib/views/components/badge.js b/lib/views/components/badge.js new file mode 100644 index 0000000..4e55624 --- /dev/null +++ b/lib/views/components/badge.js @@ -0,0 +1,7 @@ +'use strict' + +const h = require('virtual-dom/h') + +module.exports = function badge(count) { + return h('.badge', '' + count) +} diff --git a/lib/views/sidebar/channels.js b/lib/views/sidebar/channels.js index 0692f4b..b446161 100644 --- a/lib/views/sidebar/channels.js +++ b/lib/views/sidebar/channels.js @@ -3,6 +3,7 @@ const h = require('virtual-dom/h') const inherits = require('util').inherits const Base = require('vdelement') +const badge = require('../components/badge') module.exports = Channels @@ -61,7 +62,7 @@ Channels.prototype.render = function render(chans) { ] if (chan.unread) { - kids.push(h('.badge', '' + chan.unread)) + kids.push(badge(chan.unread)) } let classNames = []