vendor.styl 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. use('../nodes/vendor-helpers.js')
  2. @import 'config'
  3. /*
  4. * Alias "nowrap" as "no-wrap".
  5. */
  6. no-wrap = unquote('nowrap')
  7. /*
  8. * Helper to find out if a given value is a width
  9. */
  10. is-width(val)
  11. if auto == val
  12. return true
  13. else if val && 'unit' == type(val)
  14. // Stylus does not short circuit so we need to perform this as a distinct
  15. // operation to prevent errors
  16. return '' != unit(val)
  17. return false
  18. /*
  19. * Vendor support for the given prop / arguments, optionally specifying the
  20. * only prefixes to utilize, or those which should be ignored.
  21. */
  22. vendor(prop, args, only = null, ignore = null, vendor-property = true)
  23. need_normalize = !vendor-property or prop in ('transition' 'transition-property' 'border-image' 'border-image-slice')
  24. for prefix in vendor-prefixes
  25. unless (only and !(prefix in only)) or (ignore and prefix in ignore)
  26. if official == prefix
  27. if need_normalize
  28. {prop}: normalize(prop,('%s' % args))
  29. else
  30. {prop}: args
  31. else
  32. newprop = prop
  33. newprop = '-' + prefix + '-' + prop if vendor-property
  34. if need_normalize
  35. {newprop}: normalize(prop,('%s' % args),prefix)
  36. else
  37. {newprop}: args
  38. /*
  39. * Vendorize the given value.
  40. */
  41. vendor-value(arg, only = null, ignore = null)
  42. prop = current-property[0]
  43. for prefix in vendor-prefixes
  44. unless (only and !(prefix in only)) or (ignore and prefix in ignore) or official == prefix
  45. add-property(prop, '-%s-%s' % (prefix arg))
  46. arg
  47. /*
  48. * Vendor "box-shadow" support.
  49. */
  50. box-shadow()
  51. vendor('box-shadow', arguments, only: webkit official)
  52. /*
  53. * Vendor "user-select" support.
  54. */
  55. user-select()
  56. vendor('user-select', arguments, only: webkit moz ms official)
  57. /*
  58. * Vendor "column-count" support.
  59. */
  60. column-count()
  61. vendor('column-count', arguments, only: webkit moz official)
  62. /*
  63. * Vendor "column-gap" support.
  64. */
  65. column-gap()
  66. vendor('column-gap', arguments, only: webkit moz official)
  67. /*
  68. * Vendor "column-rule" support.
  69. */
  70. column-rule()
  71. vendor('column-rule', arguments, only: webkit moz official)
  72. /*
  73. * Vendor "column-rule-color" support.
  74. */
  75. column-rule-color()
  76. vendor('column-rule-color', arguments, only: webkit moz official)
  77. /*
  78. * Vendor "column-rule-width" support.
  79. */
  80. column-rule-width()
  81. vendor('column-rule-width', arguments, only: webkit moz official)
  82. /*
  83. * Vendor "column-rule-style" support.
  84. */
  85. column-rule-style()
  86. vendor('column-rule-style', arguments, only: webkit moz official)
  87. /*
  88. * Vendor "column-width" support.
  89. */
  90. column-width()
  91. vendor('column-width', arguments, only: webkit moz official)
  92. /*
  93. * Vendor "column-span" support.
  94. */
  95. column-span()
  96. vendor('column-span', arguments, only: webkit official)
  97. /*
  98. * Vendor "column-fill" support.
  99. */
  100. column-fill()
  101. vendor('column-fill', arguments, only: moz official)
  102. /*
  103. * Legacy syntax support for background-clip and background-origin
  104. */
  105. legacy-bg-values(property, args)
  106. legacy_args = ()
  107. importance = unquote('')
  108. for subargs in args
  109. for arg in subargs
  110. if arg in (border-box padding-box content-box)
  111. arg = unquote('border') if arg == border-box
  112. arg = unquote('padding') if arg == padding-box
  113. arg = unquote('content') if arg == content-box
  114. if arg != '!important'
  115. push(legacy_args,arg)
  116. else
  117. importance = !important
  118. vendor(property, unquote(join(', ',legacy_args)) importance, only: moz webkit)
  119. /*
  120. * Vendor "background-clip" support.
  121. */
  122. background-clip()
  123. if arguments[0] == text
  124. vendor('background-clip', arguments, only: webkit)
  125. else
  126. legacy-bg-values('background-clip', arguments)
  127. background-clip: arguments
  128. /*
  129. * Vendor "background-origin" support.
  130. */
  131. background-origin()
  132. legacy-bg-values('background-origin', arguments)
  133. background-origin: arguments
  134. /*
  135. * Vendor "transform" support.
  136. */
  137. transform()
  138. vendor('transform', arguments)
  139. /*
  140. * Vendor "transform-origin" support.
  141. */
  142. transform-origin()
  143. vendor('transform-origin', arguments)
  144. /*
  145. * Vendor "transform-style" support.
  146. */
  147. transform-style()
  148. vendor('transform-style', arguments)
  149. /*
  150. * Vendor "border-image" support.
  151. */
  152. border-image()
  153. vendor('border-image', arguments, only: webkit moz o official)
  154. /*
  155. * Vendor "transition" support.
  156. */
  157. transition()
  158. vendor('transition', arguments)
  159. /*
  160. * Vendor "transition-property" support.
  161. */
  162. transition-property()
  163. vendor('transition-property', arguments)
  164. /*
  165. * Vendor "transition-duration" support.
  166. */
  167. transition-duration()
  168. vendor('transition-duration', arguments)
  169. /*
  170. * Vendor "transition-timing-function" support.
  171. */
  172. transition-timing-function()
  173. vendor('transition-timing-function', arguments)
  174. /*
  175. * Vendor "transition-delay" support.
  176. */
  177. transition-delay()
  178. vendor('transition-delay', arguments)
  179. /*
  180. * Vendor "backface-visibility" support.
  181. */
  182. backface-visibility()
  183. vendor('backface-visibility', arguments, only: webkit moz ms official)
  184. /*
  185. * Vendor "perspective" support.
  186. */
  187. perspective()
  188. if mixin
  189. vendor('perspective', arguments, only: webkit moz ms official)
  190. else
  191. 'perspective(%s)' % arguments
  192. /*
  193. * Vendor "perspective-origin" support.
  194. */
  195. perspective-origin()
  196. vendor('perspective-origin', arguments, only: webkit moz ms official)
  197. /*
  198. * Opacity with conditional IE support.
  199. */
  200. opacity(n, args...)
  201. opacity: n args
  202. if support-for-ie
  203. if n == inherit or n == initial
  204. -ms-filter: n args
  205. filter: n args
  206. else
  207. val = round(n * 100)
  208. if val == 100
  209. -ms-filter: none args
  210. filter: none args
  211. else
  212. -ms-filter: '"progid:DXImageTransform.Microsoft.Alpha(Opacity=%s)"' % val args
  213. filter: 'alpha(opacity=%s)' % val args
  214. /*
  215. * Vendor "text-size-adjust"
  216. */
  217. text-size-adjust()
  218. vendor('text-size-adjust', arguments)
  219. /*
  220. * Alias the "white-space" property.
  221. */
  222. whitespace()
  223. white-space: arguments
  224. /*
  225. * Vendor "box-sizing" support.
  226. */
  227. box-sizing()
  228. vendor('box-sizing', arguments, only: webkit moz official)
  229. /*
  230. * Vendor "box-orient" support.
  231. */
  232. box-orient()
  233. vendor('box-orient', arguments, only: webkit moz official)
  234. /*
  235. * Vendor "box-flex-group" support.
  236. */
  237. box-flex-group()
  238. vendor('box-flex-group', arguments, only: webkit moz official)
  239. /*
  240. * Vendor "box-ordinal-group" support.
  241. */
  242. box-ordinal-group()
  243. vendor('box-ordinal-group', arguments, only: webkit moz ms official)
  244. /*
  245. * Vendor "box-align" support.
  246. */
  247. box-align()
  248. vendor('box-align', arguments, only: webkit moz ms official)
  249. /*
  250. * Vendor "box-pack" support.
  251. */
  252. box-pack()
  253. vendor('box-pack', arguments, only: webkit moz ms official)
  254. /*
  255. * Vendor "box-direction" support.
  256. */
  257. box-direction()
  258. vendor('box-direction', arguments, only: webkit moz ms official)
  259. /*
  260. * Vendor "animation" support.
  261. */
  262. animation()
  263. vendor('animation', arguments)
  264. /*
  265. * Vendor "animation-name" support.
  266. */
  267. animation-name()
  268. vendor('animation-name', arguments)
  269. /*
  270. * Vendor "animation-duration" support.
  271. */
  272. animation-duration()
  273. vendor('animation-duration', arguments)
  274. /*
  275. * Vendor "animation-delay" support.
  276. */
  277. animation-delay()
  278. vendor('animation-delay', arguments)
  279. /*
  280. * Vendor "animation-direction" support.
  281. */
  282. animation-direction()
  283. vendor('animation-direction', arguments)
  284. /*
  285. * Vendor "animation-iteration-count" support.
  286. */
  287. animation-iteration-count()
  288. vendor('animation-iteration-count', arguments)
  289. /*
  290. * Vendor "animation-timing-function" support.
  291. */
  292. animation-timing-function()
  293. vendor('animation-timing-function', arguments)
  294. /*
  295. * Vendor "animation-play-state" support.
  296. */
  297. animation-play-state()
  298. vendor('animation-play-state', arguments)
  299. /*
  300. * Vendor "animation-fill-mode" support.
  301. */
  302. animation-fill-mode()
  303. vendor('animation-fill-mode', arguments)
  304. /*
  305. * Vendor "hyphens" support.
  306. */
  307. hyphens()
  308. vendor('hyphens', arguments, only: webkit moz ms official)
  309. /*
  310. * Vendor "appearance" support.
  311. */
  312. appearance()
  313. vendor('appearance', arguments, only: webkit moz official)
  314. /*
  315. * Vendor "tab-size" support.
  316. */
  317. tab-size()
  318. vendor('tab-size', arguments, only: moz o official)
  319. /*
  320. * Vendor "overflow-scrolling" support.
  321. */
  322. overflow-scrolling()
  323. vendor('overflow-scrolling', arguments, only: webkit official)
  324. /*
  325. * Vendor "text-overflow" support, , -o- for opera 9.* - 10.*
  326. */
  327. text-overflow()
  328. vendor('text-overflow', arguments, only: official o)
  329. /*
  330. * Vendor "text-size-adjust" support.
  331. */
  332. text-size-adjust()
  333. vendor('text-size-adjust', arguments, only: official webkit ms)
  334. /*
  335. * Vendor "font-smoothing" support, webkit only.
  336. */
  337. font-smoothing()
  338. vendor('font-smoothing', arguments, only: webkit)
  339. /**
  340. * Vendor input-placeholder/placeholder support.
  341. *
  342. * Examples:
  343. * // Default syntax
  344. * body
  345. * placeholder(color #333, font-weight normal)
  346. *
  347. * // The comma is important
  348. * .placeholder-red
  349. * placeholder(color red,)
  350. *
  351. * // We can pass a function
  352. * green-placeholder()
  353. * color green
  354. * .placeholder-green
  355. * placeholder(green-placeholder)
  356. *
  357. * // We can pass a hash
  358. * textarea
  359. * placeholder((font-style italic) (font-weight bold) (padding '4px 10px'))
  360. */
  361. placeholder()
  362. for v in ':-webkit-input' '-moz' ':-moz' '-ms-input'
  363. &:{v}-placeholder
  364. for pair in arguments
  365. if typeof(pair) == 'function'
  366. pair()
  367. else if pair is not null && pair[0] is not null
  368. {pair[0]}: type(pair[1]) == 'string' ? s(pair[1]) : pair[1]
  369. input-placeholder = placeholder
  370. /*
  371. * Vendor background support (gradients).
  372. */
  373. background()
  374. if match('-gradient\(', ''+arguments)
  375. vendor('background', arguments, vendor-property: false)
  376. else
  377. background arguments
  378. background-image()
  379. if match('-gradient\(', ''+arguments)
  380. vendor('background-image', arguments, vendor-property: false)
  381. else
  382. background-image arguments
  383. cursor()
  384. if match('-gradient\(', ''+arguments)
  385. vendor('cursor', arguments, vendor-property: false)
  386. else
  387. cursor arguments
  388. list-style()
  389. if match('-gradient\(', ''+arguments)
  390. vendor('list-style', arguments, vendor-property: false)
  391. else
  392. list-style arguments
  393. list-style-image()
  394. if match('-gradient\(', ''+arguments)
  395. vendor('list-style-image', arguments, vendor-property: false)
  396. else
  397. list-style-image arguments