pollination-viewer v0.23.5
Lavender VTKJS Component Library
React component library using:
- Rollup
- Sass
- TypeScript
- Storybook to help you create and show off your components
- Jest and React Testing Library enabling testing of the components
Created using this excellent resource▸
Development
Testing
Minimal tests have been written for the components in this library.
npm run testBuilding
npm run buildStorybook
To run a live-reload Storybook server on your local machine:
npm run storybookTo export your Storybook as static files:
npm run storybook:exportYou can then serve the files under storybook-static using S3, GitHub pages, Express etc.
Generating New Components
npm run generate YourComponentNameThis will generate:
/src
/components
/YourComponentName
YourComponentName.tsx
YourComponentName.stories.tsx
YourComponentName.test.tsx
YourComponentName.types.ts
YourComponentName.scssThe default templates for each file can be modified under util/templates.
Don't forget to add the component to your index.ts exports if you want the library to export the component!
Installing Component Library Locally
This component library can be installed using npm link.
If you are getting errors like Invalid Hook Call Warning you may need to add the following to your webpack.config:
resolve: {
alias: {
"react/jsx-dev-runtime": "react/jsx-dev-runtime",
"react/jsx-runtime": "react/jsx-runtime",
"react": "react"
}
}Check ../solo-viewer/config-overrides.js for how we solved this problem in an (unejected) create-react-app.
Publishing
Hosting via NPM
First, make sure you have an NPM account and are logged into NPM using the npm login command.
Then update the name field in package.json to reflect your NPM package name in your private or public NPM registry. Then run:
npm publishThe "prepublishOnly": "npm run build" script in package.json will execute before publish occurs, ensuring the build/ directory and the compiled component library exist.
Usage
Usage of the component (after the library installed as a dependency into another project) will be:
import React from "react";
import { TestComponent } from "lavender-vtkjs";
const App = () => (
<div className="app-container">
<h1>Hello I'm consuming the component library</h1>
<TestComponent theme="primary" />
</div>
);
export default App;Using Component Library SASS Variables
I've found that it's helpful to export SASS variables to projects consuming the library. As such, I've added the rollup-plugin-copy NPM package and used it to copy the src/typography.scss and variables.scss into the build directory as part of the Rollup bundle process. This allows you to use these variables in your projects consuming the component library.
For example, let's say you installed lavender-vtkjs into your project. To use the exported variables/mixins, in a SASS file you would do the following:
@import '~lavender-vtkjs/build/typography';
.example-container {
@include heading;
color: $vtkjs-white;
}1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago