Tools
The ink ecosystem contains multiple environments utilizing the same samples. Each environment serves a different purpose but every sample adheres to ink's best practices. Samples are often served as ink guidelines or implementation references so we must keep them updated and organized.
All samples are contained in a samples.js
file in each component's folder and follow this format:
{group: 'Component',name: 'Sample name must be unique',description: 'Relevant information', // optionalenvironments: ['docs', 'expose', 'playroom'], // at least onecode: `</>`}
Each sample should test and isolate an idea so we can prove weather or not it works
Selectable rows
Selectable rows, using helpers
Samples should be displayed starting from the most basic use cases, up to the most complex
Bugs reported to us (such as from the #ink channel) but were not regressed prior, should always have a sample added. We don't know all the use cases of how our users want to use our components but as we discover them, we should regress them to ensure that they don't reappear when we make other changes.
At least one environment is required
environments: ["docs", "expose", "playroom"]; // compiledenvironments: ["plain-text"]; // not compiled
The ink documentation is our source of truth. Samples here are meant to showcase their intended usage. ALL samples here should be sharable snippets as we often send them in the #ink channel to answer questions.
description
where relevantsolidBackground: true
as an alternative to the transparent background in order to reflect our production environment when applicableDon't add samples that we wouldn't encourage the use of such as legacy props or visuals. Those only need to be regressed in Exposé.
These are snippet meant to be embedded in our docs' usage guidelines. The formatting for these don't have to adhere to any particular standard as they aren't compiled.
The Exposé is used for both automated visual regression (via BackstopJS) and/or integration testing (via Cypress)
docs
or playroom
must also appear in exposeexpose
onlyVisual regression
to the sample name if the sample is added specifically for BackstopJSCheck our readme for backstop for the full details. In short, samples are automatically included as a snapshot in the initial loading state via BackstopJS. Additional snapshots are added for interactive visuals such as dropdown or twiddle states (opened/closed). Snapshots can be skipped only if:
skipFlakyBackstop: true
skipInitialBackstop: true
The Playroom is our prototyping tool of choice especially useful for sharing mocks and/or debugging. Check out our Playroom 101 guide.
Check our readme for Cypress for the full details. Although not an environment option, the samples in our Exposé are also used for integration testing. We want to assert that the interactive behavior is as the user would expect.
Is this page helpful?