@vectara/vectara-ui
Version:
Vectara's design system, codified as a React and Sass component library
112 lines (70 loc) • 4.79 kB
Markdown
# Vectara UI
This is Vectara's design system, codified as a React component library. It's intended solely for consumption by Vectara and currently it isn't available for use by anybody else. For more information see [NO_LICENSE](./NO_LICENSE).
## Usage
Import components like this:
```tsx
import { VuiFlexContainer, VuiItem } from "@vectara/vectara-ui";
```
Import our utils like this:
```tsx
import { extractCitations } from "@vectara/vectara-ui/lib/utils/citations";
```
To import the CSS for the components, import this stylesheet at the root level:
```tsx
import "@vectara/vectara-ui/lib/styles/index";
```
If you are using Sass and need Vectara UI's Sass variables, you can use this import in the files that use the variables:
```scss
@import "@vectara/vectara-ui/lib/sassUtils/index";
```
## Software design principles
We use these principles to guide how we design components, utilities, and other code in VUI.
### Features must have clear use cases
- Adding code is easy. Removing code is hard. Try not to add code.
- Only add code if we'll use it.
- If we'll use the code, demonstrate how with an example in the docs.
### Module surface area should be as small as possible
- Nobody enjoys tracking dependencies.
- Modules with many exports make it hard to know which exports matter.
- Keep modules simple. Export only what the consumer will need.
### Props should be opinionated
- Nobody enjoys CSS. The primary interface of VUI is React and TS, not CSS.
- Design props as abstractions over the CSS. Optimize for common use cases.
- Expect the consuming developer to think about the CSS as a last resort.
### Components should be composable
- Treat components like Legos.
- Only add a feature to a component if it can't be done by putting components together.
- If you're writing a lot of custom code in an example, consider moving it to a component.
### Optimize for greppability
- JS refers to CSS via strings. Our tools don't tell us when those references break.
- Grep is the best way to find relevant CSS class names.
- Write CSS class names out fully. Avoid Sass concatenation outside of loops.
## Publishing
Publishing a new version of the package consists of three steps:
1. Maintaining the CHANGELOG.
2. Versioning the package.
3. Publishing to NPM.
### Maintain the CHANGELOG
As you introduce changes, record them in the CHANGELOG beneath the `main` section. Before you create a new version, submit a PR that updates the `package.json` version and moves the `main` content into a new section for the new version. We follow semver, so breaking changes should result in a major version bump.
### Version the package
1. Run `npm version {number}` to update package.json with the new version number and create a tag to track the version.
2. Run `git push origin --tags` to push the new tag to the repo.
3. Optional: [Manually create a release in GitHub.](https://docs.github.com/en/repositories/releasing-projects-on-github/managing-releases-in-a-repository)
### Publish to NPM
1. Run `npm run buildPackage` to create the distributable files.
2. Run `npm login --scope=@vectara --registry="https://registry.npmjs.org/"` to log into the registry and scope.
3. Run `npm publish --access public` to publish the package to NPM.
## Local development
Use `npm run start` to run the docs site locally and interact with the code you're developing.
To test the package locally, use [`npm link`](https://docs.npmjs.com/cli/v9/commands/npm-link) to consume the distributable files in a sibling project.
If you get an error regarding an ["invalid hook call"](https://iws.io/2022/invalid-hook-multiple-react-instances), you might need to use `npm link` to temporarily link the consumer's React dependencies to Vectara-UI's React dependencies. In this example, we're consuming Vectara-UI in [Vectara-Answer](https://github.com/vectara/vectara-answer):
```bash
npm link ../vectara-answer/node_modules/react ../vectara-answer/node_modules/react-dom ../vectara-answer/node_modules/react-router-dom
```
When you're done testing out the consumer, you can unlink these dependencies:
```bash
npm unlink ../vectara-answer/node_modules/react ../vectara-answer/node_modules/react-dom ../vectara-answer/node_modules/react-router-dom
```
## Licensing and public use
Though the GitHub terms of service grant anybody the right to fork and look through this repository, we haven't yet licensed this code for use by anybody else. This means Vectara reserves all rights to the contents of this repository. You can't reproduce, distribute, or create derivative works from it. For more information on reserved copyright of GitHub repos, see https://choosealicense.com/no-permission/.
For more information on our lack of licensing, see [NO_LICENSE](./NO_LICENSE).