// (C)opyright 2020-11-17 Dirk Holtwick, holtwick.it. All rights reserved.

// Some aliases for true and false

on = true
off = false

yes = true
no = false

// 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:
//
// do windy-animation
// windy-animation default
// windy-animation go
//
// Instead of windy-animation()

windy(fn)
  for fn in arguments
    wfn = lookup("windy-" + fn)
    if wfn is a 'function'
      wfn()
    else if fn is a 'function'
      fn()
    else
      s('/* Error: Unknown mixin with name "%s" or "windy-%s" */', fn, fn)
      error("Unknown mixin: " + fn)

// Not sure yet which one will make the race

do = windy
use = windy
apply = windy

default = ()
go = ()
set = ()

// A special opinionated measurement in Windy 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`

windy-size-factor ?= (1 / 16)rem

rex(value)
  if value is a 'unit' && unit(value) == '' && value != 0
    (value * windy-size-factor)
  else
    value

// 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

// Some "best practice" values for rex, the power of 2 :)

-rex-2 = rex(2)
-rex-4 = rex(4)
-rex-8 = rex(8)
-rex-12 = rex(12)
-rex-16 = rex(16)
-rex-20 = rex(20)
-rex-24 = rex(24)
-rex-32 = rex(32)
-rex-64 = rex(64)
-rex-128 = rex(128)
-rex-256 = rex(256)
