sebastiaanvisser / clay

A CSS preprocessor as embedded Haskell.
Other
360 stars 73 forks source link

Make an example showing how to add new properties #147

Closed jmn closed 4 years ago

jmn commented 7 years ago

I'd like to do something like img{ object-fit: scale-down; }

But Clay doesn't seem to have objectFit. It would be most helpful to have a code example showing how to add a new property.

jmn commented 7 years ago

I think I figured my particular case out by looking at commits. Something like

{-# LANGUAGE OverloadedStrings, GeneralizedNewtypeDeriving #-}
import Clay
import Clay.Property
newtype ObjectFit = ObjectFit Value
  deriving (Val, Inherit, Initial, Unset, Normal)

scaleDown :: ObjectFit
scaleDown = ObjectFit "scale-down"

objectFit :: ObjectFit -> Css
objectFit = key "object-fit"
chrissound commented 7 years ago

I would think this is probably a a good pull request. But I agree, it might be worth mentioning how to add new properties. Is it really that simple as the code sample above?

dbaynard commented 7 years ago

As a quick workaround, there's the "object-fit" -: "scale-down" option (take care when quoting, though) using -:.

turion commented 5 years ago

Happy to accept a PR adding this feature with docs.

github-actions[bot] commented 4 years ago

Stale issue message