Skip to content

Commit

Permalink
Merge pull request #9 from mike-goodwin/development
Browse files Browse the repository at this point in the history
Merge version 0.0.5 changes
  • Loading branch information
mike-goodwin authored Nov 29, 2016
2 parents d575f6a + 277b266 commit 45418c4
Show file tree
Hide file tree
Showing 12 changed files with 132 additions and 9 deletions.
28 changes: 28 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Run Tests",
"program": "${workspaceRoot}\\node_modules\\mocha\\bin\\_mocha",
"runtimeExecutable": null,
"cwd": "${workspaceRoot}",
"args": [
"-R",
"spec",
"--colors",
"--no-timeouts"
]
},
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"port": 5858
}
]
}
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.1",
"version": "0.0.5",
"homepage": "https://github.com/mike-goodwin/pug-bootstrap",
"authors": [
"[email protected]"
Expand Down
18 changes: 11 additions & 7 deletions components/navbar.pug
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ mixin navbar(name, id, style, href)
block

mixin nav_item(href, active)
li(class=active): a( href=href )
block

if(active)
li(class="active"): a( href=href ): block
else
li: a( href=href ): block

mixin nav_item_dropdown(href, active)
li(class=["dropdown", active])
- var ddclass = active ? ["dropdown", "active"] : "dropdown"
li(class=ddclass)
a.dropdown-toggle( href=href, data-toggle="dropdown", role="button", aria-expanded="false" )= attributes.label
span.caret
ul.dropdown-menu( role="menu" )
Expand All @@ -35,7 +39,7 @@ mixin nav_header
li.dropdown-header
block

mixin navbar-fixed(name,id,style)
mixin navbar-fixed(name,id,style,href)
- var style = (typeof style === 'undefined') ? "default" : style
nav( role="navigation", class=["navbar","navbar-fixed-top","navbar-" + style] )
.container
Expand All @@ -45,12 +49,12 @@ mixin navbar-fixed(name,id,style)
span.icon-bar
span.icon-bar
span.icon-bar
a.navbar-brand(href='#')= name
a.navbar-brand(href=href)= name
.collapse.navbar-collapse( id=id )
ul.nav.navbar-nav
block

mixin navbar-static(name,id,style)
mixin navbar-static(name,id,style,href)
- var style = (typeof style === 'undefined') ? "default" : style
nav( role="navigation", class=["navbar","navbar-static-top","navbar-" + style] )
.container
Expand All @@ -60,7 +64,7 @@ mixin navbar-static(name,id,style)
span.icon-bar
span.icon-bar
span.icon-bar
a.navbar-brand(href='#')= name
a.navbar-brand(href=href)= name
.collapse.navbar-collapse( id=id )
ul.nav.navbar-nav
block
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pug-bootstrap",
"version": "0.0.4",
"version": "0.0.5",
"description": "Bootstrap framework written completely using mixins in pug",
"main": "bootstrap.pug",
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/navbars/nav-divider.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../../../components/navbar.pug
+nav_divider
2 changes: 2 additions & 0 deletions test/fixtures/navbars/nav-header.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../../../components/navbar.pug
+nav_header Test Header
2 changes: 2 additions & 0 deletions test/fixtures/navbars/nav-item-dropdown.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../../../components/navbar.pug
+nav_item_dropdown(href, active)
2 changes: 2 additions & 0 deletions test/fixtures/navbars/navbar-fixed.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../../../components/navbar.pug
+navbar-fixed(name, id, style, href)
2 changes: 2 additions & 0 deletions test/fixtures/navbars/navbar-item.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../../../components/navbar.pug
+nav_item(href, active) Test
2 changes: 2 additions & 0 deletions test/fixtures/navbars/navbar-static.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../../../components/navbar.pug
+navbar-static(name, id, style, href)
2 changes: 2 additions & 0 deletions test/fixtures/navbars/navbar.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../../../components/navbar.pug
+navbar(name, id, style, href)
77 changes: 77 additions & 0 deletions test/navbars.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
var assert = require("assert");
var jade = require("pug");
var fs = require("fs");
var path = require("path");

describe("Navbars", function () {
it('should generate a navbar', function () {
var locals = {
name: 'navbar-name',
id: 'navbar-id',
style: 'style',
href: 'href'
};
var fn = jade.compileFile(path.join(__dirname, "fixtures/navbars", "navbar.pug"));
assert.equal('<nav class="navbar navbar-style" role="navigation"><div class="navbar-header"><button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target="#navbar-id" aria-expanded="false" aria-controls="navbar"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><a class="navbar-brand" href="href">navbar-name</a></div><div class="collapse navbar-collapse" id="navbar-id"><ul class="nav navbar-nav"></ul></div></nav>', fn(locals));
});
it('should generate a static navbar', function () {
var locals = {
name: 'navbar-name',
id: 'navbar-id',
style: 'style',
href: 'href'
};
var fn = jade.compileFile(path.join(__dirname, "fixtures/navbars", "navbar-static.pug"));
assert.equal('<nav class="navbar navbar-static-top navbar-style" role="navigation"><div class="container"><div class="navbar-header"><button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target="#navbar-id" aria-expanded="false" aria-controls="navbar"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><a class="navbar-brand" href="href">navbar-name</a></div><div class="collapse navbar-collapse" id="navbar-id"><ul class="nav navbar-nav"></ul></div></div></nav>', fn(locals));
});
it('should generate a fixed navbar', function () {
var locals = {
name: 'navbar-name',
id: 'navbar-id',
style: 'style',
href: 'href'
};
var fn = jade.compileFile(path.join(__dirname, "fixtures/navbars", "navbar-fixed.pug"));
assert.equal('<nav class="navbar navbar-fixed-top navbar-style" role="navigation"><div class="container"><div class="navbar-header"><button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target="#navbar-id" aria-expanded="false" aria-controls="navbar"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button><a class="navbar-brand" href="href">navbar-name</a></div><div class="collapse navbar-collapse" id="navbar-id"><ul class="nav navbar-nav"></ul></div></div></nav>', fn(locals));
});
it('should generate a navbar item', function () {
var locals = {
href: 'href'
};
var fn = jade.compileFile(path.join(__dirname, "fixtures/navbars", "navbar-item.pug"));
assert.equal('<li><a href="href">Test</a></li>', fn(locals));
});
it('should generate an active navbar item', function () {
var locals = {
href: 'href',
active: true
};
var fn = jade.compileFile(path.join(__dirname, "fixtures/navbars", "navbar-item.pug"));
assert.equal('<li class="active"><a href="href">Test</a></li>', fn(locals));
});
it('should generate a navbar divider', function () {
var locals = {};
var fn = jade.compileFile(path.join(__dirname, "fixtures/navbars", "nav-divider.pug"));
assert.equal('<li class="divider"></li>', fn(locals));
});
it('should generate a navbar dropdown', function () {
var locals = {
href: 'href'
};
var fn = jade.compileFile(path.join(__dirname, "fixtures/navbars", "nav-item-dropdown.pug"));
assert.equal('<li class="dropdown"><a class="dropdown-toggle" href="href" data-toggle="dropdown" role="button" aria-expanded="false"><span class="caret"></span></a><ul class="dropdown-menu" role="menu"></ul></li>', fn(locals));
});
it('should generate an active navbar dropdown', function () {
var locals = {
href: 'href',
active: true
};
var fn = jade.compileFile(path.join(__dirname, "fixtures/navbars", "nav-item-dropdown.pug"));
assert.equal('<li class="dropdown active"><a class="dropdown-toggle" href="href" data-toggle="dropdown" role="button" aria-expanded="false"><span class="caret"></span></a><ul class="dropdown-menu" role="menu"></ul></li>', fn(locals));
});
it('should generate a navbar header', function () {
var locals = {};
var fn = jade.compileFile(path.join(__dirname, "fixtures/navbars", "nav-header.pug"));
assert.equal('<li class="dropdown-header">Test Header</li>', fn(locals));
});
});

0 comments on commit 45418c4

Please sign in to comment.