For every AST node, the bredon-types
package also ships a builder function which safely creates AST nodes manually.
- dimension
- expression
- float
- functionExpression
- hexColor
- identifier
- integer
- operator
- parenthesis
- separator
- stringLiteral
- url
- value
- valueList
where Unit refers to one of the valid units:
%
, em
, ex
, ch
, rem
, vw
, vh
, vmin
, vmax
, cm
, mm
, q
, in
, pt
, pc
, px
, deg
, grad
, rad
, turn
, s
, ms
, Hz
, kHz
, dpi
, dpcm
, dppx
import { dimension } from 'bredon-types'
dimension(integer(300), 'px') // => 30px
dimension(float(33, 33, true), '%') // => -33.33%
import { expression } from 'bredon-types'
expression([ /* child nodes */ ])
import { float } from 'bredon-types'
float(0, 55) // => .55
float(1, 10, true) // => -1.10
import { functionExpression } from 'bredon-types'
functionExpression('rgba', [ /* param nodes */ ]) // => rgba(...)
import { hexColor } from 'bredon-types'
hexColor('FFF') // => #FFF
import { identifier } from 'bredon-types'
identifier('solid') // => solid
import { integer } from 'bredon-types'
integer(55) // => 55
integer(55, true) // => -55
import { operator } from 'bredon-types'
operator('+') // => +
import { parenthesis } from 'bredon-types'
parenthesis('(') // => (
import { seperator } from 'bredon-types'
seperator() // => /
import { stringLiteral } from 'bredon-types'
stringLiteral("Hello, I am a string.", '"') // => "Hello, I am a string."
import { url } from 'bredon-types'
url("https://www.github.com/") // => url("https://www.github.com/")
import { cssValue } from 'bredon-types'
value([ /* child nodes */ ])
value([ /* child nodes */ ], true)
import { valueList } from 'bredon-types'
valueList([ /* value nodes */])