Skip to content

Commit bc54227

Browse files
committed
first commit
0 parents  commit bc54227

7 files changed

+75
-0
lines changed

component.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "viewport-toolbar",
3+
"description": "A toolbar for the viewport component.",
4+
"dependencies": {
5+
"debianw/b64icons": "*",
6+
"component/classes": "*",
7+
"component/domify": "*"
8+
},
9+
"scripts": [
10+
"index.js",
11+
"template.js",
12+
"item.js"
13+
],
14+
"styles": [
15+
"style.css"
16+
]
17+
}

index.js

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* Module dependencies.
3+
*/
4+
5+
var template = require('./template')
6+
, item = require('./item')
7+
, domify = require('domify')
8+
, classes = require('classes');
9+
10+
11+
module.exports = Toolbar;
12+
13+
/**
14+
*
15+
*/
16+
17+
function Toolbar (options) {
18+
19+
if (!(this instanceof Toolbar)) return new Toolbar(options);
20+
21+
var templateEl = domify(template)
22+
, contentEl = templateEl.querySelector('#content')
23+
, itemEl
24+
, txtEl
25+
, iconEl
26+
, items;
27+
28+
this.el = templateEl;
29+
30+
options = options || {};
31+
items = options.items || [];
32+
33+
items.forEach(function (it) {
34+
itemEl = domify(item);
35+
txtEl = itemEl.querySelector('p');
36+
iconEl = itemEl.querySelector('.icon');
37+
38+
if ("string" === typeof it.status) classes(itemEl).add(it.status || "");
39+
if ("string" === typeof it.icon) classes(iconEl).add(it.icon || "");
40+
41+
txtEl.innerHTML = it.text || "";
42+
43+
contentEl.appendChild(itemEl);
44+
});
45+
46+
return this;
47+
}

item.html

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<li>
2+
<div class="icon"></div>
3+
<p></p>
4+
</li>

item.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = '<li>\n <div class="icon"></div>\n <p></p>\n</li>';

style.css

Whitespace-only changes.

template.html

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<!-- toolbar -->
2+
<nav id="viewport-toolbar">
3+
<ul id="content" class="topcoat-navigation-bar"></ul>
4+
</nav>
5+
<!-- /toolbar -->

template.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)