You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.2 KiB
Racket

10 years ago
#lang racket/base
(require racket/string racket/list racket/contract)
(require sugar)
(provide (all-defined-out)
(all-from-out racket/string racket/list racket/contract sugar))
(define css-property-prefixes '("-moz-" "-webkit-" "-o-" "-ms-" ""))
(define (join-css-strings properties)
(define line-ending ";\n")
(define out-string (string-join properties line-ending))
(if (ends-with? out-string line-ending) ; might already have the line ending, so don't duplicate it
out-string
(string-append out-string line-ending)))
(define (make-css-string p v)
(string-join (list (->string p) (->string v)) ": "))
(define (make-css-strings property-prefixes property-suffix values)
; general function for creating groups of css properties
; with browser prefixes and one value
(define (map-suffix suffix prefixes)
(map (λ(prefix) (string-append prefix suffix)) prefixes))
(define properties (map-suffix property-suffix property-prefixes))
; if single value provided, convert to list of values
; so that it will work with map in the next step
(when (not (list? values))
(set! values (make-list (len properties) values)))
(map make-css-string properties values))