Replies: 3 comments 6 replies
-
Thoughts on this? This makes the most sense to me, though I'm trying to find cases where this might backfire (components with too many props, etc.). |
Beta Was this translation helpful? Give feedback.
-
What do folks think about using |
Beta Was this translation helpful? Give feedback.
-
Are we wanting to drop the labs and preview badges from the docs? I’m fine either way, I just noticed they were absent from the Introduction section. |
Beta Was this translation helpful? Give feedback.
-
In an effort to standardize how our MDX docs are structured, I'm proposing the following format for organizing our docs. I examined a few different approaches to how we've organized our docs so far...
canvas-site
(the Input components have been migrated tocanvas-kit
in this PR)canvas-kit
(e.g., Pagination, Tabs, Popup, Modal, Box, Flex, etc.)... and tried to come up with a format that incorporates the best parts of each of these approaches.
I've broken the overall
Component.stories.mdx
file into three sections to make this document easier to digest:A complete
Component.stories.mdx
file would be the simple sequence of these sections:Introduction
Every MDX should begin the same way with imports, the
<Meta />
tag, the name and description of the component, and installation instructions.All instances of
Component
should be replaced with the component name.In some cases, it may be helpful to add content at the beginning of the component documentation to provide extra information or high-level context. These sections may be added as additional level two headings below
Installation
. For example, it would make sense for the What's the difference between Flex and Box? section in theFlex
docs to appear here.Usage
The format of the
Usage
section will vary based on the type of component. I've classified components into three types:As a general rule of thumb, there should be an example for each prop supported by the component (but use your judgment; some components may have too many props to have an example for each one). Props that are simply forwarded to the underlying HTML element via
elemProps
as HTML attributes (e.g.,placeholder
in<TextInput placeholder="Placeholder text">
) do not need to have examples, though you may include them if you wish.Usage: Simple Component
Examples: Text Input (MDX)
Note the mention of how
elemProps
are handled in theProps
section.Usage: Component Family with Multiple Components
Examples: Button (MDX), Icon Button (MDX) (note: Icon and Icon Button docs don't stick to the exact format below yet)
Some modules contain multiple related components that should be documented together in a single page. Buttons and Icon Buttons are the clearest example of this.
Usage: Compound Component
Examples: Skeleton (MDX) (note: we have a number of Compound Components with MDXes that don't that yet follow the format below such as Popup and Pagination).
Compound Components are the most complex type of component and thus require the most documentation out of the three types. In addition to
Usage
, they contain a required level two heading forComponents
(i.e., Subcomponents), as well as optional level two headings forModel
,Behavior Hooks + Other Hooks
or justHooks
(if there are noBehavior Hooks
), andUtilities
.Note that code in the
Components
,Behavior Hooks/Other Hooks/Hooks
, andUtilities
sections don't necessarily useExampleCodeBlock
, instead opting for regular code blocks since they may not be self-contained examples. This should help keep the number of stories listed in the Storybook navigation in check given the many code snippets likely to be present in Compound Component documentation.See
Popup.stories.mdx
for an example of how to displayArgsTables
for the model state, events, and config.Specifications
If the component has integration tests, add a
Specifications
section to the end to display the tests in a readable format.Beta Was this translation helpful? Give feedback.
All reactions