-
Notifications
You must be signed in to change notification settings - Fork 197
Phantom Types: Contributing
See #375 for background.
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.
- Each
Value
is an open record with a single field. The field's name is the value's name, and its type isSupported
. For examplefoo : Value { provides | foo : Supported }
- Each function returning
Style
accepts a closed record ofSupported
fields. - If a function returning
Style
takes a singleValue
, thatValue
should always supportinherit
,initial
, andunset
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 oneValue
, however, then none of its arguments should supportinherit
,initial
, orunset
, 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, butborder-radius: 5px inherit;
is invalid CSS. To reflect this,borderRadius : Value { ... } -> Style
must haveinherit : Supported
in its record, butborderRadius2 : Value { ... } -> Value { ... } -> Style
must not haveinherit : Supported
in either argument's record. If a user wants to getborder-radius: inherit
, they must callborderRadius
, notborderRadius2
! - When accepting a numeric
Value
(e.g. a length likepx
, an angle likedeg
, or a unitless number likeint
ornum
), always includezero : Supported
as well ascalc : 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, notmaster
!