garden icon indicating copy to clipboard operation
garden copied to clipboard

Idea: Expand Vectors of CSS Properties

Open xcthulhu opened this issue 8 years ago • 8 comments

It would convenient if vectors of keywords could be automatically expanded.

Here's what I have in mind:

(def user-select [:-webkit-touch-callout 
                  :-webkit-user-select 
                  :-khtml-user-select 
                  :-moz-user-select 
                  :-ms-user-select 
                  :user-select])

(garden.core/css {user-select "none"})
; => "{-webkit-touch-callout: none; -webkit-user-select: none; -khtml-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none;}"

This corresponds to a feature in SASS: https://github.com/sass/sass/issues/109

xcthulhu avatar Jan 21 '16 23:01 xcthulhu

@xcthulhu Let me think about this one.

noprompt avatar Jan 23 '16 17:01 noprompt

It's nice to have, but not critical... in SASS since they aren't embedded in a real programming language they can't just quick things like:

(-> {:size "12pt"} (into (for [p user-select] [p "none"]))

On the other hand, the behavior as it is doesn't produce valid CSS:

(garden.core/css ["*" {[:padding-left :padding-right] "4pt"}])
;; => "* {\n  [:padding-left :padding-right]: 4pt;\n}"

So, I know I'm a lowly internet rando, but I would suggest picking one of these options:

  1. Expanding vectors as per my original suggestion
  2. Throwing an exception

My 2¢

xcthulhu avatar Jan 26 '16 17:01 xcthulhu

@xcthulhu I do like this idea. @priyatam What do you think?

noprompt avatar Jan 27 '16 20:01 noprompt

A PR is nice to have :).

In general, I would be interested in ideas focused on improving core CSS standards compatibility, versus utilities.

priyatam avatar Jan 29 '16 05:01 priyatam

@priyatam I'm not sure I want a PR just yet. I think the main thing I was interested in is whether or not you'd use a feature like this?

noprompt avatar Jan 29 '16 19:01 noprompt

I won't use it, but I agree with @xcthulhu that we should have better error reporting if something is obviously incorrect—which is a larger issue, I think.

priyatam avatar Jan 29 '16 19:01 priyatam

I'd use the feature I suppose, to be honest it's not a big deal.

I would point out you can't do such things when you are in a {:style {...}} in for instance; it's probably for the best that the syntax for garden and hiccup stay exactly the same at this level as per the principle of least astonishment.

xcthulhu avatar Jan 29 '16 20:01 xcthulhu

otoh i'm seeing sass libraries starting to downplay their support for vendor prefixing in favour of https://github.com/postcss/autoprefixer so if that's the only use case for this it might be less urgent?

thedavidmeister avatar Oct 22 '16 00:10 thedavidmeister