Skip to content

css package #1

@nsaunders

Description

@nsaunders

I noticed that you list the css package here in the README. About a year ago, I took over maintainership, but it didn't take me long to realize that it needed a complete overhaul:

  1. The library is simply too incomplete for any serious project. Examples: virtually no pseudo-selectors, virtually no support for media queries, no grid properties, and so on.

  2. Countless issues with namespacing and keyword reuse. For example, I might have to write a declaration like overflow overflowInherit because the CSS.Common.inherit value is incompatible with the overflow function/property. Similarly, I would have to float floatLeft or textAlign leftTextAlign.

  3. While some type classes exist to support keyword reuse (even if not implemented consistently), they don't solve conflicts between property names and keyword values. For example, left is both a value (e.g. float: left) and a property (e.g. left: 100px). Without fundamental design changes, the only solution is to awkwardly name the functions that represent them and/or require them to be imported (qualified) from separate modules.

  4. Not all that much type safety. For example, backgroundImage [] would compile just fine but result in the invalid declaration background-image: ;. Similarly, the boxShadow function accepts any Size a values including percentages, but actually the box-shadow property doesn't support percentages.

  5. Not much flexibility. For example, boxShadow only supports a single shadow, while the corresponding CSS property allows multiple shadows or none. Less critically, but just as annoyingly, properties like padding require values for all four sides, instead of supporting their very commonly used shorthand syntax.

  6. Producing invalid output actually makes static typing counterproductive.

garyb, a previous maintainer and prominent member of the PureScript Core Team, alluded to problems as far back as 2018. Another core team member acknowledged to me privately that the css package is "quite old" and "not in the best shape". The earliest committers are long gone. And I was given sole maintainership after a single decent PR. I think it's safe to say (although I am sorry to say it) that no one feels much of a sense of ownership over this codebase, and I doubt that anyone familiar believes it's particularly good.

Hopefully, then, you'll understand why I essentially gave up and created a new CSS library called Tecton. I'm not claiming perfection, but I certainly have addressed all of the issues described above and then some. For each feature I've implemented, I've carefully referenced the relevant W3C specifications; and I've heavily leveraged type classes to achieve a flexible API that actually somewhat resembles the underlying CSS. For good measure, I've implemented over 1,700 tests based on real CSS examples from the W3C and MDN and adapted a sizable real-world example to help ensure adequate CSS coverage.

I do regret that I had to create a new library because many in the PureScript community are unaware of it and newcomers will almost certainly stumble upon the css package first. However, the alternative was to break compatibility in a big way, which I'm not sure everyone would be willing to accept. (On the other hand, this creates a bit of a "namespacing" issue and potential fragmentation in the community, so perhaps there is some possibility of Tecton replacing the css package in the future.)

Anyway, thanks for reading. Please do check out Tecton and, if you feel it is appropriate, consider replacing the css listing in the README.

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