-
Notifications
You must be signed in to change notification settings - Fork 38
Description
I'm adding some CSS props and their values as I discover whats missing so I just want to clarify some conventions to make things that I'm adding look consistent.
Regarding the project structure I see there are (at least) two ways to do it:
- Keep the same (or very close) module structure as in Clay. If I get it right they put several CSS properties that are logically related to each other. For example, in
Clay.Display
there areFloat
,Position
,Display
,Overflow
,Visibility
,Cursor
etc (in a single module). This is what we have right now. - Make smaller/granular modules (keep a module per CSS property and its values). I don't know if it makes sense to refactor and split existing modules (will be a breaking change), but maybe it makes sense for new modules (new CSS props).
I prefer the first option, but I'm not sure we have to choose between the two.
For example, in Clay, they keep the cursor
property and its values in the Display
module:
https://github.com/sebastiaanvisser/clay/blob/54dc9eaf0abd180ef9e35d97313062d99a02ee75/src/Clay/Display.hs#L268
Also some values are prefixed with a property name, like cursorText
:
https://github.com/sebastiaanvisser/clay/blob/54dc9eaf0abd180ef9e35d97313062d99a02ee75/src/Clay/Display.hs#L278
I'm about making a PR that adds this prop so I'm thinking about putting it in a separate module because there are too many values and some of them have names like default
or text
.
Regarding the naming of CSS props and values:
- In Clay they aren't prefixing property values with a property name.
For example, itsabsolute
instead ofpositionAbsolute
.
Such naming convention sometimes may lead to collisions.
One way to prevent potential collisions is not to re-export everything from the source module, so inCSS.purs
we'll be re-exporting only unique most commonly used CSS properties and values. When we want to use something specific we have to use qualified imports, e.g.:
import CSS.Float as Float
fromString "foo" ? do
float Float.left
As I can see, this is how its currently done, but with some exceptions, for example, the values of float
are prefixed:
https://github.com/slamdata/purescript-css/blob/9e78699ea728f519ec5b3e830aa2036823dd50a7/src/CSS/Display.purs#L125
https://github.com/slamdata/purescript-css/blob/9e78699ea728f519ec5b3e830aa2036823dd50a7/src/CSS/Display.purs#L168
2. Another way (which I dislike for long names) is to always make prefixed values (but keep the old names as is?).
Actually, after writing the naming options above now I think it makes sense to use both (as we have now): not to prefix values if its possible, but sometimes prefix them when its unavoidable and may lead to clashes.