You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These mixins show how nicely Pre can simplify and DRY up code for repetitious elements like email and password inputs. The mixin can optionally have parameters or be easily modified to include "help text", etc.
Mixin for basic inputs
// This would probably be most appropriate when// the mixin will have predictable parameters
.controlGroup(@text: "Email", @type: "Email", @for: "input"@{type}) {
.control-group {
label.control-label {
for: @for;
text: @text;
}
.controls {
input {
type: ~`@{type}.toLowerCase()`;
id: @for;
placeholder: @text;
}
}
}
}
Mixin for a labeled checkbox and a button, with no paramaters
About the semantics, I meant class names in form field markup. To be honest controls and controlGroup looks very confusing to me, especially the latter (sounds more like a set of several fields).
I would use classes like these:
.field {
.field-label {...}
.field-body {
input {...}
// possibly some extra elements
}
}
I don't know when they added those control names to Bootstrap but they weren't there last time I looked...
First of all, named mixin attributes are a must.
This is unreadable:
This is much better:
Even better:
Besides, you may want to leave the freedom to additionally pass arbitrary HTML attributes to mixins, e.g.