UNPKG

oui-kit

Version:

> *...c'est un "kit" pour Vue.js :)*

64 lines (53 loc) 1.37 kB
// Funny shortcuts for nicer code. If you have a function that // does not require arguments but want to make it look like // it was a regular property you have those choices: use(fn) { for fn in arguments { wfn = lookup("oui-" + fn); if wfn is a "function" { wfn(); } else if fn is a "function" { fn(); } else { s('/* Error: Unknown mixin with name "%s" or "oui-%s" */', fn, fn); error("Unknown mixin: " + fn); } } } // Not sure yet which one will make the race // A special opinionated measurement in twindy CSS is a `rex` // We assume that `1rem == 16px`, so `1rex == 0.0625rem` // The advantage is that the sizes nicely scale to different // default font sizes defined in `html` oui-size-factor ?= (1 / 16)rem; rex(value) { if value is a "unit" && unit(value) == "" && (value != 0) { value * oui-size-factor; } else { value; } } px = rex; // Can take any arguments and if it encounters pure numbers it // will convert them to rex values rexArgs(args) { list = (); for arg in args { if arg is a "unit" { push(list, rex(arg)); } else { push(list, arg); } } list; } // Helper to only add a global mixin once __oui_once(name) { check = "__oui_once__" + name; if lookup(check) != check { define(check, check, true); true; } else { false; } }