Skip to content

Commit

Permalink
fieldsets instead of divs for .form-group
Browse files Browse the repository at this point in the history
  • Loading branch information
thylux committed Feb 11, 2017
1 parent 8b0bfc0 commit ec1c5a6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions components/forms.pug
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
include icons
//- Input control with form-group wrapper
mixin input(type,id,placeholder,label,name)
.form-group
fieldset.form-group
label(for=id) #{label}
input.form-control(type=type,id=id,placeholder=placeholder,name=name)

Expand All @@ -12,7 +12,7 @@ mixin input-simple(type,id,placeholder)
//- Input control with form-group wrapper
mixin textarea(id,placeholder,label,name,rows)
- rows = rows || 3 //- Default of 3 rows
.form-group
fieldset.form-group
label(for=id) #{label}
textarea.form-control(id=id,placeholder=placeholder,name=name,rows=rows)

Expand Down Expand Up @@ -49,12 +49,12 @@ mixin radio-inline(text,name,id)

//- Submit button
mixin submit(text,name,id)
.form-group
fieldset.form-group
button.btn.btn-default(type="submit",name=name,id=id)= text

//- Input group - both prepend and append options available, and block is passed
mixin input-group(prepend,append)
.form-group
fieldset.form-group
.input-group
unless !prepend
.input-group-addon
Expand Down
4 changes: 2 additions & 2 deletions layouts/jumbotron.pug
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ block body
a.navbar-brand(href='#') Project name
#navbar.navbar-collapse.collapse
form.navbar-form.navbar-right
.form-group
fieldset.form-group
input.form-control(type='text', placeholder='Email')
.form-group
fieldset.form-group
input.form-control(type='password', placeholder='Password')
button.btn.btn-success(type='submit') Sign in

Expand Down
2 changes: 1 addition & 1 deletion layouts/non-responsive.pug
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ block body
li
a(href='#') One more separated link
form.navbar-form.navbar-left(role='search')
.form-group
fieldset.form-group
input.form-control(type='text', placeholder='Search')
button.btn.btn-default(type='submit') Submit
ul.nav.navbar-nav.navbar-right
Expand Down
8 changes: 4 additions & 4 deletions test/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var path = require("path");
describe("Forms", function() {
it("should generate input control", function() {
var fn = pug.compileFile(path.join(__dirname, "fixtures/forms","input.pug"));
assert.equal('<div class="form-group"><label for="txtInput">Label</label><input class="form-control" type="text" id="txtInput" placeholder="Placeholder" name="txtInput"/></div>',fn({ type:"text",id: "txtInput",placeholder:"Placeholder",label:"Label",name:"txtInput"}));
assert.equal('<fieldset class="form-group"><label for="txtInput">Label</label><input class="form-control" type="text" id="txtInput" placeholder="Placeholder" name="txtInput"/></fieldset>',fn({ type:"text",id: "txtInput",placeholder:"Placeholder",label:"Label",name:"txtInput"}));
});

it("should generate simple input control", function() {
Expand All @@ -15,7 +15,7 @@ describe("Forms", function() {

it("should generate text area control", function() {
var fn = pug.compileFile(path.join(__dirname, "fixtures/forms","textarea.pug"));
assert.equal('<div class="form-group"><label for="txtInput">Label</label><textarea class="form-control" id="txtInput" placeholder="Placeholder" name="txtInput" rows="3"></textarea></div>',fn({ id: "txtInput",placeholder:"Placeholder",label:"Label",name:"txtInput"}));
assert.equal('<fieldset class="form-group"><label for="txtInput">Label</label><textarea class="form-control" id="txtInput" placeholder="Placeholder" name="txtInput" rows="3"></textarea></fieldset>',fn({ id: "txtInput",placeholder:"Placeholder",label:"Label",name:"txtInput"}));
});

it("should generate simple text area control", function() {
Expand Down Expand Up @@ -46,12 +46,12 @@ describe("Forms", function() {

it("should generate a submit button",function() {
var fn = pug.compileFile(path.join(__dirname, "fixtures/forms", "submit.pug"));
assert.equal('<div class="form-group"><button class="btn btn-default" type="submit" name="btnSubmit" id="btnSubmit">Submit</button></div>',fn({ text: "Submit", name:"btnSubmit", id:"btnSubmit"}));
assert.equal('<fieldset class="form-group"><button class="btn btn-default" type="submit" name="btnSubmit" id="btnSubmit">Submit</button></fieldset>',fn({ text: "Submit", name:"btnSubmit", id:"btnSubmit"}));
});

it("should generate a input group", function() {
var fn = pug.compileFile(path.join(__dirname, "fixtures/forms", "input-group.pug"));
assert.equal('<div class="form-group"><div class="input-group"><div class="input-group-addon">Prepend</div><input type="text"/><div class="input-group-addon">Append</div></div></div>',fn({prepend: "Prepend", append: "Append"}));
assert.equal('<fieldset class="form-group"><div class="input-group"><div class="input-group-addon">Prepend</div><input type="text"/><div class="input-group-addon">Append</div></div></fieldset>',fn({prepend: "Prepend", append: "Append"}));
});

it("should generate a icon button", function() {
Expand Down

0 comments on commit ec1c5a6

Please sign in to comment.