All definitions should have a single argument #3

Open
opened 2026-03-19 16:10:44 +01:00 by christian · 0 comments
Owner

I would like to apply the "principle of least surprise" more strictly to the arguments of the CSS definitions.

A CSS definition function should always have exactly one argument which allows passing the most common values. For properties, that allow passing multiple comma-separated values, like backdrop-filter, this means that the function should accept a single value instead of a list:

background_image (url "logo.png")

(* instead of: *)
background_image [ url "logo.png" ]

We should still allow passing multiple values by providing an additional variant of the function. In elm-css those functions have Many suffix. We could just add a ':

(* single value variant (least surprise): *)
background_image (url "logo.png")

(* multiple values variant: *)
background_image' [ (url "lizard.png"); (url "star.png") ] 

(* alternatively do it like in elm-css: *)
background_image_many [ (url "lizard.png"); (url "star.png") ] 
I would like to apply the "principle of least surprise" more strictly to the arguments of the CSS definitions. A CSS definition function should always have exactly one argument which allows passing the most common values. For properties, that allow passing multiple comma-separated values, like ``backdrop-filter``, this means that the function should accept a single value instead of a list: ```ocaml background_image (url "logo.png") (* instead of: *) background_image [ url "logo.png" ] ``` We should still allow passing multiple values by providing an additional variant of the function. In ``elm-css`` those functions have ``Many`` suffix. We could just add a `'`: ```ocaml (* single value variant (least surprise): *) background_image (url "logo.png") (* multiple values variant: *) background_image' [ (url "lizard.png"); (url "star.png") ] (* alternatively do it like in elm-css: *) background_image_many [ (url "lizard.png"); (url "star.png") ] ```
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
christian/ppx_stylesheet#3
No description provided.