commit af93a09b09953bb6c1c87114a6d3f95cb6bb0154 Author: Luka Vandervelden Date: Fri Jan 3 10:09:45 2020 +0100 Initial commit. diff --git a/bulma.js b/bulma.js new file mode 100644 index 0000000..6c040f2 --- /dev/null +++ b/bulma.js @@ -0,0 +1,84 @@ +// Generated by LiveScript 1.6.0 +(function(){ + var h; + h = require('maquette').h; + module.exports = { + box: function(args, children){ + return h('div.box', args, children); + }, + title: function(level, args, label){ + if (!label) { + label = args; + args = {}; + } + return h("div.title.is-" + level, args, [label]); + }, + label: function(args, label){ + if (!label) { + label = args; + args = {}; + } + return h('label.label', args, [label]); + }, + input: function(args, children){ + return h('input.input', args, children); + }, + 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); + }, + select: function(selector, args, children){ + if (typeof selector === "object") { + children = args; + args = selector; + selector = ""; + } + return h('div.select' + selector, {}, [h('select', { + onchange: args.onchange || function(){} + }, children)]); + }, + field: function(selector, args, children){ + if (typeof selector === "object") { + children = args; + args = selector; + selector = ""; + } + return h('div.field' + selector, args, children); + }, + form: function(method, url, content){ + return h('form.form', { + action: url, + method: method + }, content); + }, + media: function(args){ + return h('div.media', [args.left ? h('div.media-left', args.left) : void 8, args.content ? h('div.media-content', args.content) : void 8, args.right ? h('div.media-right', args.right) : void 8]); + }, + 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]); + } + }; +}).call(this); diff --git a/bulma.ls b/bulma.ls new file mode 100644 index 0000000..c96bb27 --- /dev/null +++ b/bulma.ls @@ -0,0 +1,90 @@ + +h = require 'maquette' .h + +module.exports = { + box: (args, children) -> + h \div.box args, children + title: (level, args, label) -> + if not label + label = args + args = {} + + h "div.title.is-#{level}", args, [label] + label: (args, label) -> + if not label + label = args + args = {} + + h \label.label args, [label] + input: (args, children) -> + 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 + + select: (selector, args, children) -> + if typeof(selector) == "object" + children = args + args = selector + selector = "" + + h (\div.select + selector), { + } [ + h \select { + onchange: args.onchange || -> + } children + ] + + # FIXME: Use only args and add args.label and args.input? + # Or maybe args.name and args.type could be used directly? + field: (selector, args, children) -> + if typeof(selector) == "object" + children = args + args = selector + selector = "" + + h (\div.field + selector), args, children + + form: (method, url, content) -> + h \form.form { + action: url + method: method + }, content + media: (args) -> + h \div.media [ + if args.left + h \div.media-left args.left + if args.content + h \div.media-content args.content + if args.right + h \div.media-right args.right + ] + level: (args) -> + h \div.level [ + if args.left + h \div.level-left args.left + if args.right + h \div.level-right args.right + ] +} + diff --git a/package.json b/package.json new file mode 100644 index 0000000..e6d57ef --- /dev/null +++ b/package.json @@ -0,0 +1,15 @@ +{ + "name": "maquette-bulma", + "version": "0.1.0", + "description": "Bulma wrappers for maquette.", + "main": "bulma.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC", + "dependencies": { + "livescript": "^1.6.0", + "maquette": "^3.3.4" + } +} diff --git a/project.zsh b/project.zsh new file mode 100644 index 0000000..ec94fe9 --- /dev/null +++ b/project.zsh @@ -0,0 +1,20 @@ + +package=maquette-bulma +version=0.1.0 + +find . | grep -v '^\./node_modules/' | grep .ls$ | while read file_ls; do + file_js="${file_ls%.ls}.js" + targets=($file_js) + type[$file_js]=livescript + sources[$file_js]=$file_ls +done + +# FIXME: We’ll need an upstream update. The “livescript” module currently +# uses browserify, which we don’t want. +function livescript.build { + write "${target}: ${sources[$target]} $(dirdep $target)" + write "\t@echo '$(LSC $target)'" + write "\t${Q}npx lsc -c ${sources[$target]} > $target || (i=\$\$?; rm $target; return \$\$i)" + write +} +