Skip to content

Commit

Permalink
Merge pull request #20 from mike-goodwin/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
mike-goodwin authored Dec 8, 2016
2 parents 5957eae + 0adec18 commit 921a9e9
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 11 deletions.
23 changes: 13 additions & 10 deletions components/tooltips.pug
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
//- tooltip
mixin tooltip(text,tooltip,placement)
a(href="#",data-toggle="tooltip",data-placement="#{placement}",title="#{tooltip}")= text
mixin tooltip(text,tooltip,placement,href)
if undefined != href
a(href=href,data-toggle=tooltip,data-placement=placement,title=tooltip)= text
else
a(href="#",data-toggle=tooltip,data-placement=placement,title=tooltip)= text

//- tooltip-left
mixin tooltip-left(text,tooltip)
+tooltip(text,tooltip,"left")
mixin tooltip-left(text,tooltip,href)
+tooltip(text,tooltip,"left",href)

//- tooltip-right
mixin tooltip-right(text,tooltip)
+tooltip(text,tooltip,"right")
mixin tooltip-right(text,tooltip,href)
+tooltip(text,tooltip,"right",href)

//- tooltip-top
mixin tooltip-top(text,tooltip)
+tooltip(text,tooltip,"top")
mixin tooltip-top(text,tooltip,href)
+tooltip(text,tooltip,"top",href)

//- tooltip-bottom
mixin tooltip-bottom(text,tooltip)
+tooltip(text,tooltip,"bottom")
mixin tooltip-bottom(text,tooltip,href)
+tooltip(text,tooltip,"bottom",href)
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.7",
"version": "0.0.8",
"description": "Bootstrap framework written completely using mixins in pug",
"main": "bootstrap.pug",
"scripts": {
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/tooltips/tooltip-bottom.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../../../components/tooltips.pug
+tooltip-bottom(text,tooltip,href)
2 changes: 2 additions & 0 deletions test/fixtures/tooltips/tooltip-left.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../../../components/tooltips.pug
+tooltip-left(text,tooltip,href)
2 changes: 2 additions & 0 deletions test/fixtures/tooltips/tooltip-right.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../../../components/tooltips.pug
+tooltip-right(text,tooltip,href)
2 changes: 2 additions & 0 deletions test/fixtures/tooltips/tooltip-top.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
include ../../../components/tooltips.pug
+tooltip-top(text,tooltip,href)
44 changes: 44 additions & 0 deletions test/tooltips.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
var assert = require('assert');
var pug = require('pug');
var fs = require('fs');
var path = require('path');

var types = ["left", "right", "top", "bottom"];

describe('Tooltips', function () {

// Write fixture data
types.forEach(function (m) {
var fileTemplate = `include ../../../components/tooltips.pug
+tooltip-${m}(text,tooltip,href)`;
var fileName = `tooltip-${m}.pug`;
fs.writeFileSync(path.join(__dirname, "fixtures/tooltips", fileName), fileTemplate);
});

// specs
types.forEach(function (type) {
var spec = `should render a ${type} tooltip (no href)`;
it(spec, function () {
var fixture = `tooltip-${type}.pug`;
var locals = {
text: `${type} tooltip text`,
tooltip: `${type}-tooltip`
};
var actual = `<a href="#" data-toggle="${locals.tooltip}" data-placement="${type}" title="${locals.tooltip}">${locals.text}</a>`;
var fn = pug.compileFile(path.join(__dirname, "fixtures/tooltips", fixture));
assert.equal(actual, fn(locals));
});
var spec = `should render a ${type} tooltip (supplied href)`;
it(spec, function () {
var fixture = `tooltip-${type}.pug`;
var locals = {
text: `${type} tooltip text`,
tooltip: `${type}-tooltip`,
href: `${type}-link`
};
var actual = `<a href="${locals.href}" data-toggle="${locals.tooltip}" data-placement="${type}" title="${locals.tooltip}">${locals.text}</a>`;
var fn = pug.compileFile(path.join(__dirname, "fixtures/tooltips", fixture));
assert.equal(actual, fn(locals));
});
});
});

0 comments on commit 921a9e9

Please sign in to comment.