goodbye browser prefixes

Matthew Butterick 6 years ago
parent fb4e781ac9
commit 0a653f8fac

@ -4,20 +4,19 @@
(provide (all-defined-out))
(define (make-css-columns #:count count #:gap [gap #f])
(define empty '())
; shorthand for css column declaration
(join-css-strings (append
(make-css-strings css-property-prefixes "column-count" count)
(join-css-strings (list*
(make-css-string "column-count" count)
(if gap
(make-css-strings css-property-prefixes "column-gap" gap)
(list (make-css-string "column-gap" gap))
(define (make-css-avoid-column-break-inside)
; this gets applied to list items to keep them from breaking across columns
; however it doesn't work in Firefox due to bug; workaround is stupid
(join-css-strings (append
(make-css-strings css-property-prefixes "column-break-inside" "avoid")
(make-css-strings css-property-prefixes "break-inside" "avoid-column"))))
(join-css-strings (list
(make-css-string "column-break-inside" "avoid")
(make-css-string "break-inside" "avoid-column"))))

@ -4,8 +4,6 @@
(provide (all-defined-out))
(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))
@ -42,8 +40,6 @@
(define (make-css-editable)
(join-css-strings (list "user-modify: read-write"
"-moz-user-modify: read-write"
"-webkit-user-modify: read-write-plaintext-only"
"outline-style: none")))
@ -73,20 +69,13 @@
; with form style="[string]" so double quotes are irritating
(define feature-tag-string (string-join (map (λ(tag value) (format "'~a' ~a" tag value)) feature-tags feature-values) ", "))
; I hate accommodating old browsers but I'll make an exception because OT support is
; critical to most MB projects
; if this comes before new-style -moz- declaration, it will work for all.
(define feature-tag-string-old-firefox (string-join (map (λ(tag value) (format "'~a=~a'" tag value)) feature-tags feature-values) ", "))
(define feature-tag-property "font-feature-settings")
(join-css-strings (append
(make-css-strings '("-moz-") feature-tag-property feature-tag-string-old-firefox)
(make-css-strings css-property-prefixes feature-tag-property feature-tag-string))))
(make-css-string feature-tag-property feature-tag-string))
(define (make-css-hyphens [value "auto"])
(join-css-strings (make-css-strings css-property-prefixes "hyphens" value)))
(make-css-string "hyphens" value))
(define (make-css-small-caps)
(join-css-strings (list "text-transform: lowercase" (make-css-ot-features "c2sc"))))
@ -128,10 +117,10 @@
; can't use standard make-css-strings in this case because the prefixes appear in the value,
; not in the property (which is always "background")
(define gradient-strings (map (λ(prefix) (format "background: ~a~a-gradient(~a, ~a)" prefix gradient-type gradient-direction color-stop-string)) css-property-prefixes))
(define gradient-string (format "background: ~a-gradient(~a, ~a)" gradient-type gradient-direction color-stop-string))
; just fill with the last color if gradient not available
(define fallback-string (format "background: ~a" (last colors)))
; put fallback string at front of list
(join-css-strings (cons fallback-string gradient-strings)))
(join-css-strings (list fallback-string gradient-string)))

@ -4,13 +4,10 @@
(provide (all-defined-out))
(define (make-css-transition property duration #:timing-function [timing-function #f] #:delay [delay #f])
(define transition-prefixes '("-moz-" "-webkit-" ""))
(join-css-strings (append
(make-css-strings transition-prefixes "transition-property" property)
(make-css-strings transition-prefixes "transition-duration" duration)
(if timing-function
(make-css-strings transition-prefixes "transition-timing-function" timing-function)
(if delay
(make-css-strings transition-prefixes "transition-delay" delay)
(join-css-strings (filter values (list
(make-css-string "transition-property" property)
(make-css-string "transition-duration" duration)
(and timing-function
(make-css-string "transition-timing-function" timing-function))
(and delay
(make-css-string "transition-delay" delay))))))