Skip to content

Project structure and naming conventions #93

@vyorkin

Description

@vyorkin

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:

  1. 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 are Float, Position, Display, Overflow, Visibility, Cursor etc (in a single module). This is what we have right now.
  2. 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:

  1. In Clay they aren't prefixing property values with a property name.
    For example, its absolute instead of positionAbsolute.
    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 in CSS.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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions