Skip to content

Commit

Permalink
Merge pull request #21 from mike-goodwin/development
Browse files Browse the repository at this point in the history
list-groups
  • Loading branch information
mike-goodwin authored Dec 9, 2016
2 parents 921a9e9 + 8dad5b0 commit f494b7a
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 12 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pug-bootstrap",
"version": "0.0.8",
"version": "0.0.9",
"homepage": "https://github.com/mike-goodwin/pug-bootstrap",
"authors": [
"[email protected]"
Expand Down
23 changes: 13 additions & 10 deletions components/list-groups.pug
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
//- list-group mixins
mixin list-group(items)
mixin list-group(items,active)
ul.list-group
each item, index in items
li.list-group-item #{item}
each item, index in items
if(index === active)
li.list-group-item.active #{item}
else
li.list-group-item #{item}

mixin list-group-links(items,active)
.list-group
each item, index in items
if(index === active)
a.list-group-item.active(href="#{item.url}") #{item.text}
else
a.list-group-item(href="#{item.url}") #{item.text}
each item, index in items
if(index === active)
a.list-group-item.active(href=item.url) #{item.text}
else
a.list-group-item(href=item.url) #{item.text}

mixin list-group-item(url,active)
if(active === "true")
a.list-group-item.active(href="#{url}")
a.list-group-item.active(href=url)
block
else
a.list-group-item(href="#{url}")
a.list-group-item(href=url)
block

mixin list-group-custom()
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pug-bootstrap",
"version": "0.0.8",
"version": "0.0.9",
"description": "Bootstrap framework written completely using mixins in pug",
"main": "bootstrap.pug",
"scripts": {
Expand All @@ -21,6 +21,10 @@
"mixins"
],
"author": "Mike Goodwin",
"contributors": [
"https://github.com/techjeffharris",
"https://github.com/Nakira"
],
"license": "MIT",
"bugs": {
"url": "https://github.com/mike-goodwin/pug-bootstrap/issues"
Expand Down
16 changes: 16 additions & 0 deletions test/fixtures/list-groups/list-group-custom.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
include ../../../components/list-groups
+list-group-custom()
+list-group-item("url1","true")
h4.list-group-item-heading heading1
p.list-group-item-text
| text1

+list-group-item("url2")
h4.list-group-item-heading heading2
p.list-group-item-text
| text2

+list-group-item("url3")
h4.list-group-item-heading heading3
p.list-group-item-text
| text3
2 changes: 2 additions & 0 deletions test/fixtures/list-groups/list-group-links.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../../../components/list-groups
+list-group-links(items,active)
2 changes: 2 additions & 0 deletions test/fixtures/list-groups/list-group.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../../../components/list-groups
+list-group(items,active)
54 changes: 54 additions & 0 deletions test/list-groups.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
var pug = require("pug");
var assert = require("assert");
var path = require("path");

describe('Simple List Group', function () {

var items = ['item1', 'item2', 'item3'];

it('should render a simple list group', function () {
var fn = pug.compileFile(path.join(__dirname, "fixtures/list-groups", 'list-group.pug'));
var actual = '<ul class="list-group"><li class="list-group-item">item1</li><li class="list-group-item active">item2</li><li class="list-group-item">item3</li></ul>';
var locals = {
items: items,
active: 1
};
assert.equal(actual, fn(locals));
});
});

describe('Link List Group', function () {

var items = [
{
text: 'item1',
url: 'url1'
},
{
text: 'item2',
url: 'url2'
},
{
text: 'item3',
url: 'url3'
}
];

it('should render a link list group', function () {
var fn = pug.compileFile(path.join(__dirname, "fixtures/list-groups", 'list-group-links.pug'));
var actual = '<div class="list-group"><a class="list-group-item" href="url1">item1</a><a class="list-group-item active" href="url2">item2</a><a class="list-group-item" href="url3">item3</a></div>';
var locals = {
items: items,
active: 1
};
assert.equal(actual, fn(locals));
});
});

describe('Custom List Group', function () {
it('should render a custom list group', function () {
var fn = pug.compileFile(path.join(__dirname, "fixtures/list-groups", 'list-group-custom.pug'));
var actual = '<div class="list-group"><a class="list-group-item active" href="url1"><h4 class="list-group-item-heading">heading1</h4><p class="list-group-item-text">text1</p></a><a class="list-group-item" href="url2"><h4 class="list-group-item-heading">heading2</h4><p class="list-group-item-text">text2</p></a><a class="list-group-item" href="url3"><h4 class="list-group-item-heading">heading3</h4><p class="list-group-item-text">text3</p></a></div>';
assert.equal(actual, fn());
});
});

0 comments on commit f494b7a

Please sign in to comment.