@txstate-mws/txstate-react
v2.0.12
Published
[![Build Status](https://travis-ci.org/txstate-etc/txstate-components.svg?branch=master)](https://travis-ci.org/txstate-etc/txstate-components) ![npm (scoped)](https://img.shields.io/npm/v/@txstate-mws/txstate-react) [![Storybook](https://camo.githubuserc
Downloads
777
Readme
Texas State University - React Components
Local Development Server
Run this command:
docker-compose up --build
The server will be live on localhost:9009
Adding A Component (React)
- Create a new folder:
src/React/MyComponent
- Add two files to the folder
index.js
andMyComponent.js
- Add
export * from './MyComponent'
to your newindex.js
- Write your sweet new React component
- Add
- Make your component available to import from the library by adding and entry to
src/index.js
export { MyComponent } from './MyComponent'
- When you're really done with the component, create some type defs in
src/React/index.d.ts
- This lets people using your component see what props are available, and get auto completion on enum type props. For an example, check the variant prop of Button.
Adding SVG componenet
- Create
.svg
file insrc/assets/svg
- run
npx @svgr/cli --template src/utils/svgr.js -d src/components/Svg src/assets/svg
in terminal - Make your component available to import from the library by adding and entry to
src/Svg/index.js
export * from './Component'
- Component will be available to import with
Svg
prefiximport { SvgComponent } from @txstate-mws/txstate-react
Using Storybook to Develop
Storybook is a framework that allows us to develop components in an isolated environment. It acts as a living set of documentation and is extremely useful for development since you don't have to link this library with another project in order to develop with it. When you've written your component and ready to test it using Storybook, do the following:
- Add a file to
src/stories
calledMyComponent.stories.jsx
- Add an entry to
src/stories/index.js
to import your component's stories. - Write a story.
Versioning
Patch (1.0.X)
Increment the minor version if you changed anything and you want other people to have it.
Minor (1.X.0)
If you've added a new component the major version should be incremented.
Major (X.0.0)
If you've changed the way a component is used increment the major version and explain to the rest of the team why this change is needed (cookies help).
The easiest way to communicate changes is to update CHANGELOG.md
Location
The version number is in package.json
Build A New Version
- Run
yarn build
ornpm run build
- You can either publish the new version, or use it locally:
- To use locally, run
npm pack
and install the.tgz
file it generates as a dependency in your project. - To publish the package, learn how to publish a package and then write these instructions.
- To use locally, run
- When making a commit to the master branch, travis CI will automatically build the library and deploy it to https://txstate-etc.github.io/txstate-components/