Skip to content

Instantly share code, notes, and snippets.

@thybzi
Last active April 28, 2016 13:24
Show Gist options
  • Select an option

  • Save thybzi/520e993f22ffd0dc6c6c to your computer and use it in GitHub Desktop.

Select an option

Save thybzi/520e993f22ffd0dc6c6c to your computer and use it in GitHub Desktop.
Stylus detected types — for use with `typeof()` and `is a`: http://codepen.io/thybzi/pen/MKMGoK
/*! bool, null */
typeof() // -> "null"
typeof(null) // -> "null"
typeof(undefined) // -> "ident"
typeof(false) // -> "boolean"
typeof(no) // -> "ident"
/*! color */
typeof(#ff0000) // -> "rgba"
typeof(#f00) // -> "rgba"
typeof(red) // -> "rgba"
typeof(rgba(255, 0, 0, 0.5)) // -> "rgba"
typeof(hsla(0, 100%, 50%, 0.5)) // -> "hsla"
typeof(hsl(0, 100%, 50%)) // -> "hsla"
typeof(invert(red)) // -> "rgba"
typeof(invert(hsl(0, 100%, 50%))) // -> "rgba"
/*! ident, string, unit, call */
typeof(foobar) // -> "ident"
typeof('foobar') // -> "string"
typeof(15) // -> "unit"
typeof(15px) // -> "unit"
typeof(15deg) // -> "unit"
typeof(rotate(15deg)) // -> "call"
typeof(url('http://example.com')) // -> "call"
/*! function, mixin o_O, property */
foobar($a, $b)
$a + $b
typeof(foobar) // -> "function"
typeof(foobar(1, 2)) // -> "unit"
foobar($a, $b)
{$a}: $b
typeof(foobar) // -> "function"
typeof(foobar(1, 2)) // -> "property"
/*! object, list o_O */
typeof({ a: 42 }) // -> "object"
typeof({ a: 42 }.a) // -> "unit"
typeof(a, 42) // -> "ident"
typeof(42, a) // -> "unit"
/*! list variables */
a = 1px solid red
typeof(a) // -> "unit"
typeof(a, 42) // -> "unit"
b = italic 15px serif
typeof(b) // -> "ident"
c = (1 2 3)
typeof(c) // -> "unit"
typeof(a, b, c) // -> "unit"
typeof(b, a, c) // -> "ident"
typeof(c, b, a) // -> "unit"
b = c
typeof(b, a, c) // -> "unit"
b = rotate(45deg) scaleX(2)
typeof(b) // -> "call"
typeof(c) // -> "unit"
c = a, 42
typeof(c) // -> "unit"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment