sebastiaanvisser / clay

A CSS preprocessor as embedded Haskell.
Other
357 stars 72 forks source link

margin needs a redesign #211

Open BebeSparkelSparkel opened 4 years ago

BebeSparkelSparkel commented 4 years ago

Currently, margin :: Size a -> Size a -> Size a -> Size a -> Css accepts 4 arguments. This makes it impossible to have margin: auto.

margin would be better if it accepted one argument.

margin :: ToMargin a => a -> CSS
margin = key "margin" . value

class ToMargin a where toMargin :: forall b. Val b => a -> b
instance ToMargin (a,b,c,d) where toMargin (w, x, y, z) = (w, (x, (y, z)))
instance ToMargin Auto where -- not correct but you get my drift
turion commented 4 years ago

How about simply adding a function marginAuto :: Css?

Or an algebraic datatype that works with the Val typeclass, like e.g. Color? See http://hackage.haskell.org/package/clay-0.13.1/docs/Clay-Color.html#t:Color

BebeSparkelSparkel commented 4 years ago

ADT sounds better. Allows a lot more functionality. Not sure what to name the function though unless we want to break margin

github-actions[bot] commented 3 years ago

This issue has not seen any activity in a long time. If no further activity occurs, it will be closed after ten weeks.