Using components (o2) via npm
This guide shows an example of including “o2” Origami components in a project via npm.
“o2” npm packages include Sass and JavaScript, which your project must bundle. Whilst some “o2” packages include TSX templates, most people copy HTML from Storybook.
Knowledge about these and other technologies is assumed. We also assume you’re already setup to bundle assets, e.g. transpile Sass to CSS.
If you have questions or need further help please reach out to the Origami team.
Install npm peer dependencies
Install as peer dependencies to ensure only one version of an Origami package is installed for your project. This is to avoid technical conflicts, ensure consistency of the user experience, and reduce bundle sizes.
E.g.
Include HTML
Whilst some “o2” packages include TSX templates, most people copy HTML from Storybook.
Include Sass
- Set a
$o-brand
Sass variable for your project (one ofcore
,internal
, orwhitelabel
). - Set a
$system-code
Sass variable to the BizOps System Code for your project, or$$$-no-bizops-system-code-$$$
if your project does not relate to a System. - Import the
main
Sass file of your installed packages.
E.g.
By default, including Origami Sass does not output any CSS. Use the component’s Sass API, documented for each component in Storybook, to output styles.
E.g. To set the page background and output all table styles.
Include JavaScript
We may then import the component’s client side JavaScript.
E.g. o-table
By default this will do nothing until we initialise the table. We can do that in 3 ways, using o-table
as an example:
Wrap-up
We’ve briefly covered how to include the HTML, CSS (via Sass), and JavaScript for an “o2” Origami component. If you have questions or need help please reach out to the Origami team at any time.