Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README with consumption, publishing, and local development guidelines #57

Merged
merged 3 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,57 @@
# Vectara UI

This is Vectara's design system, codified as a React component library.

## Usage

Import components like this:

```tsx
import { VuiFlexContainer, VuiItem } from "@vectara/vectara-ui";
```

This project assumes you're using Sass. Import the Sass styles from this project into the root-level:

```scss
@import "~@vectara/vectara-ui/src/index";
```

You can consume Vectara UI's Sass variables by placing this import in the files that use the variables:

```scss
@import "~@vectara/vectara-ui/src/vars";
```

## Publishing

Publishing a new version of the package consists of two steps: **versioning the package** and **publishing to NPM**.

### 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
```
13 changes: 0 additions & 13 deletions src/index.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1 @@
@import "./lib/index";
@import "./lib/components/index";

body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans",
"Droid Sans", "Helvetica Neue", sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

code {
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", monospace;
}
2 changes: 1 addition & 1 deletion src/lib/_index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Hard reset to naked selectors
@import "reset";
@import "./styleUtils/index";
@import "./components/index";
1 change: 1 addition & 0 deletions src/vars.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import "./lib/styleUtils/index";