New functions, some refactoring.
parent
af93a09b09
commit
0c58d90f72
59
bulma.js
59
bulma.js
|
@ -1,8 +1,20 @@
|
|||
// Generated by LiveScript 1.6.0
|
||||
(function(){
|
||||
var h;
|
||||
var h, alias;
|
||||
h = require('maquette').h;
|
||||
alias = function(baseSelector){
|
||||
return function(selector, args, children){
|
||||
if (typeof selector === "object") {
|
||||
children = args;
|
||||
args = selector;
|
||||
selector = "";
|
||||
}
|
||||
return h(baseSelector + selector, args, children);
|
||||
};
|
||||
};
|
||||
module.exports = {
|
||||
container: alias('div.container'),
|
||||
footer: alias('footer.footer'),
|
||||
box: function(args, children){
|
||||
return h('div.box', args, children);
|
||||
},
|
||||
|
@ -26,30 +38,9 @@
|
|||
textarea: function(args, children){
|
||||
return h('textarea.textarea', args, children);
|
||||
},
|
||||
control: function(selector, args, children){
|
||||
if (typeof selector === "object") {
|
||||
children = args;
|
||||
args = selector;
|
||||
selector = "";
|
||||
}
|
||||
return h('div.control' + selector, args, children);
|
||||
},
|
||||
button: function(selector, args, children){
|
||||
if (typeof selector === "object") {
|
||||
children = args;
|
||||
args = selector;
|
||||
selector = "";
|
||||
}
|
||||
return h('div.button' + selector, args, children);
|
||||
},
|
||||
tag: function(selector, args, children){
|
||||
if (typeof selector === "object") {
|
||||
children = args;
|
||||
args = selector;
|
||||
selector = "";
|
||||
}
|
||||
return h('div.tag' + selector, args, children);
|
||||
},
|
||||
control: alias('div.control'),
|
||||
button: alias('div.button'),
|
||||
tag: alias('div.tag'),
|
||||
select: function(selector, args, children){
|
||||
if (typeof selector === "object") {
|
||||
children = args;
|
||||
|
@ -79,6 +70,22 @@
|
|||
},
|
||||
level: function(args){
|
||||
return h('div.level', [args.left ? h('div.level-left', args.left) : void 8, args.right ? h('div.level-right', args.right) : void 8]);
|
||||
}
|
||||
},
|
||||
navbar: function(args){
|
||||
var useContainer, classes, innerNavbar;
|
||||
args || (args = {});
|
||||
useContainer = args.useContainer || false;
|
||||
classes = args.classes || void 8;
|
||||
innerNavbar = function(){
|
||||
var start, end;
|
||||
return [args.brand ? h('div.navbar-brand', args.brand) : void 8, args.start || args.end ? h('div.navbar-menu', [(start = args.start) ? h('div.navbar-start', start) : void 8, (end = args.end) ? h('div.navbar-end', end) : void 8]) : void 8];
|
||||
};
|
||||
return h('nav.navbar', {
|
||||
classes: classes
|
||||
}, [useContainer
|
||||
? h('div.container', innerNavbar())
|
||||
: innerNavbar()]);
|
||||
},
|
||||
navbarItem: alias('a.navbar-item')
|
||||
};
|
||||
}).call(this);
|
||||
|
|
65
bulma.ls
65
bulma.ls
|
@ -1,7 +1,19 @@
|
|||
|
||||
h = require 'maquette' .h
|
||||
|
||||
alias = (base-selector) ->
|
||||
(selector, args, children) ->
|
||||
if typeof(selector) == "object"
|
||||
children = args
|
||||
args = selector
|
||||
selector = ""
|
||||
|
||||
h (base-selector + selector), args, children
|
||||
|
||||
module.exports = {
|
||||
container: alias \div.container
|
||||
footer: alias \footer.footer
|
||||
|
||||
box: (args, children) ->
|
||||
h \div.box args, children
|
||||
title: (level, args, label) ->
|
||||
|
@ -20,27 +32,9 @@ module.exports = {
|
|||
h \input.input args, children
|
||||
textarea: (args, children) ->
|
||||
h \textarea.textarea args, children
|
||||
control: (selector, args, children) ->
|
||||
if typeof(selector) == "object"
|
||||
children = args
|
||||
args = selector
|
||||
selector = ""
|
||||
|
||||
h (\div.control + selector), args, children
|
||||
button: (selector, args, children) ->
|
||||
if typeof(selector) == "object"
|
||||
children = args
|
||||
args = selector
|
||||
selector = ""
|
||||
|
||||
h (\div.button + selector), args, children
|
||||
tag: (selector, args, children) ->
|
||||
if typeof(selector) == "object"
|
||||
children = args
|
||||
args = selector
|
||||
selector = ""
|
||||
|
||||
h (\div.tag + selector), args, children
|
||||
control: alias \div.control
|
||||
button: alias \div.button # FIXME: Maybe \a.button?
|
||||
tag: alias \div.tag
|
||||
|
||||
select: (selector, args, children) ->
|
||||
if typeof(selector) == "object"
|
||||
|
@ -86,5 +80,34 @@ module.exports = {
|
|||
if args.right
|
||||
h \div.level-right args.right
|
||||
]
|
||||
|
||||
navbar: (args) ->
|
||||
args or= {}
|
||||
|
||||
use-container = args.use-container || false
|
||||
classes = args.classes || void
|
||||
|
||||
inner-navbar = -> [
|
||||
if args.brand
|
||||
h \div.navbar-brand args.brand
|
||||
if args.start || args.end
|
||||
h \div.navbar-menu [
|
||||
if start = args.start
|
||||
h \div.navbar-start start
|
||||
if end = args.end
|
||||
h \div.navbar-end end
|
||||
]
|
||||
]
|
||||
|
||||
h \nav.navbar {
|
||||
classes: classes
|
||||
} [
|
||||
if use-container
|
||||
h \div.container inner-navbar!
|
||||
else
|
||||
inner-navbar!
|
||||
|
||||
]
|
||||
navbar-item: alias \a.navbar-item
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue