Skip to content

Phantom Types: Contributing

Richard Feldman edited this page Jun 17, 2018 · 7 revisions

See #375 for background.

Implementation Guidelines

Previously the linking policy was to either link to MDN or not to bother writing documentation (e.g. have {-| -} for a doc comment.) The new policy is to have documentation for every value, including at least one code example, and which links to relevant documentation on that property.

I originally linked to MDN for all the docs, but I've since discovered CSS Tricks has some really well-written guides on how to use various properties and values in practice, and those articles tend to link to MDN documentation at the end anyway. So the new policy is to link to CSS Tricks if there's an appropriate article for that value, and to fall back on linking directly to MDN if CSS Tricks happens not to have anything relevant.

Don't worry about tests for now. I decided against trying to get them compiling along the way; seems easier to wait until everything is converted, at which point the tests will hopefully reveal any accidental regressions in implementations.

Contribution Checklist

  • Each Value is an open record with a single field. The field's name is the value's name, and its type is Supported. For example foo : Value { provides | foo : Supported }
  • Each function returning Style accepts a closed record of Supported fields.
  • If a function returning Style takes a single Value, that Value should always support inherit, initial, and unset because all CSS properties support those three values! For example, borderFoo : Value { foo : Supported, bar : Supported, inherit : Supported, initial : Supported, unset : Supported } -> Style
  • If a function returning Style takes more than one Value, however, then none of its arguments should support inherit, initial, or unset, because these can never be used in conjunction with other values! For example, border-radius: 5px 5px; is valid CSS, border-radius: inherit; is valid CSS, but border-radius: 5px inherit; is invalid CSS. To reflect this, borderRadius : Value { ... } -> Style must have inherit : Supported in its record, but borderRadius2 : Value { ... } -> Value { ... } -> Style must not have inherit : Supported in either argument's record. If a user wants to get border-radius: inherit, they must call borderRadius, not borderRadius2!
  • When accepting a numeric Value (e.g. a length like px, an angle like deg, or a unitless number like int or num), always include zero : Supported as well as calc : Supported!
  • Every exposed value has documentation which includes at least 1 code sample.
  • Documentation links to to a CSS Tricks article if available, and MDN if not.
  • Make a pull request against the phantom-types branch, not master!
Clone this wiki locally