We've discussed that HTML input elements might want to be a document type of their own, distinct from just HTML elements.
The HTML <input>
element is weird. It's defined as a single element type, but depending on the value of the type
attribute it can represent any of a large number of very different things: text inputs, buttons, data/time selectors, check boxes etc.
We've tended to treat these all more or less as quite separate entities, and to treat the fact that they're actually all the same element as an implementation detail. This seems like a good approach from the point of view of answering the questions users are likely to have.
But these things also have some special features which normal HTML elements don't have, so we have thought we might want to model them as a distinct page type in stumptown.
I've looked through the input element pages, and tried to see if we will want a document type and if so what it should feature.
The main page:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
The individual input element pages:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/button
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/checkbox
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/color
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/datetime-local
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/hidden
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/image
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/month
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/password
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/radio
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/range
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/reset
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/search
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/submit
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/tel
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/text
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/time
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/url
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/week
Looking through these I can see three distinct features:
Value section
All these pages have an H2 "Value" which describes the format and use of the value
attribute.
Validation section
Most of the pages have an H2 "Validation" describing how the input is validated and how to add any extra validation.
Attribute handling
These pages have a different way to handle attributes, which I've gone into in detail here: https://discourse.mozilla.org/t/attributes-for-input-elements/43899. The way attributes are handled here is a mess at the moment.
I think what we should do instead is give each input element page an "Attributes" section listing the attributes that apply to that input type.
However we still need special handling here. In the normal HTML element pages, each element gets its own "attributes" directory: there's no sharing. So they are specified in the recipe by supplying the directory name, like:
attributes:
element_specific: ./attributes
But in this case it's more like: there a big list of input element attributes, then each particular type supports some subset of that list. So, for example, the placeholder
attribute is used by textbox-style inputs like url
, password
, search
and so on. These really would like to share the documentation for placeholder
.
So the obvious suggestion is to keep all the attribute documentation for input
under html/reference/elements/input/attributes, and then let the attributes
specification in the front matter list individual files, rather than a single directory:
attributes:
element_specific:
- ../attributes/maxlength.md
- ../attributes/minlength.md
- ../attributes/pattern.md
- ../attributes/placeholder.md
One question is whether any of these attributes need different documentation for different types. The only place I've found where that seems likely is step
, where the step unit is different for different input types. But even there we could document that in the preamble to the list of attributes, or we could have "../attributes/step-time.md".
Conclusions
We could avoid having an extra page type here. We could just support "Value" and "Validation" as "additional sections", and we don't need a new page type in order to support enumerated attributes.
But I think it would be helpful to model "Value" and "Validation" explicitly. So we could have a recipe that's very close to the normal element one:
related_content: /content/related_content/html.yaml
body:
- prose.short_description
- meta.interactive_example?
- prose.overview
- prose.value
- prose.validation
- prose.attributes_text?
- meta.attributes
- prose.styling?
- prose.accessibility_concerns?
- prose.*
- meta.examples
- meta.info_box:
- meta.api
- meta.permitted_aria_roles
- meta.tag_omission
- meta.browser_compatibility
- prose.see_also
@Elchi3 , @ddbeck , comments?
Acceptance criteria:
- input element recipe is written and checked into stumptown-content
- all input elements are migrated into stumptown