@televet/kibble-ui 0.1.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,44 +1,204 @@
1
- [![Build Status](https://travis-ci.com/morewings/cra-template-npm-library.svg?branch=master)](https://travis-ci.com/morewings/cra-template-npm-library)
2
- [![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=morewings/cra-template-npm-library)](https://dependabot.com)
3
- [![dependencies Status](https://david-dm.org/morewings/cra-template-npm-library/status.svg)](https://david-dm.org/morewings/cra-template-npm-library)
4
- [![Netlify Status](https://api.netlify.com/api/v1/badges/7448a6f6-8be5-4d26-b886-f59db21ebb4e/deploy-status)](https://app.netlify.com/sites/cra-template-npm-library/deploys)
5
- [![npm version](https://badge.fury.io/js/cra-template-npm-library.svg)](https://www.npmjs.com/package/cra-template-npm-library)
6
- [![npm](https://img.shields.io/npm/dm/cra-template-npm-library)](https://www.npmjs.com/package/cra-template-npm-library)
1
+ # Kibble
7
2
 
8
- # NPM library Create React App template
3
+ Kibble is a React component library for use at TeleVet.
9
4
 
10
- [Create React App](https://github.com/facebook/create-react-app) (CRA) template to build and publish NPM libraries with **rollup**, **eslint** and **stylelint** configurations. See [full documentation](https://cra-template-npm-library.netlify.com/).
5
+ https://televet.github.io/kibble-ui/
11
6
 
12
- ## Usage
7
+ ## Usage within a Televet Project
8
+
9
+ ### New Project Setup
10
+
11
+ If your project does not include a `.npmrc`, create it and add the following:
12
+
13
+ `//registry.npmjs.org/:_authToken=${NPM_TOKEN}`
14
+
15
+ Then add the NPM_TOKEN environment variable to your .bash_profile or .zshrc
16
+
17
+ `export NPM_TOKEN=${SOME_TOKEN}`
18
+
19
+ Note: The NPM token can be found here in our [shared accounts table](https://www.notion.so/televet/Shared-Accounts-c691ae4e0dc8482c876aa0f4a56d8ea7)
20
+
21
+ ### Install in project
22
+
23
+ `npm i --save @televet/kibble-ui`
24
+
25
+ ```
26
+ import {
27
+ ThemeProvider,
28
+ theme,
29
+ Button,
30
+ .... and all other components
31
+ } from 'kibble-ui';
32
+ ```
33
+
34
+ ## Development Setup
35
+
36
+ ### Linking Projects for Local Development
37
+
38
+ ```
39
+ $ cd kibble-ui # navigate into the package directory
40
+ $ rm -rf node_modules # remove existing node_modules
41
+ $ npm run build # ensure there are build files available for the package to reference
42
+
43
+ # Update your library's package.json so that react and react-dom are pointing to your projects node_modules versions of these two packages. See reference to mutliple versions of react error here for more info on why this is necessary: https://reactjs.org/warnings/invalid-hook-call-warning.html#duplicate-react
44
+
45
+ # "react": "../clinic-web/node_modules/react"
46
+ # "react-dom": "../clinic-web/node_modules/react-dom"
47
+
48
+ $ npm i # install packages
49
+ $ npm run start # start the development server
50
+
51
+ # Navigate to project directory and update package.json to point to your local copy of your library
52
+ # "@televet/kibble-ui": "./../kibble-ui"
53
+
54
+ $ cd clinic-web # go into a project directory
55
+ $ rm -rf node_modules # remove existing node_modules
56
+ $ npm install # fresh install with local version of kibble ui
57
+ $ npm run start # start the development server
58
+
59
+ # When linking local packages like this your text editor may display errors saying the package cannot be found, however, if you restart your editor these errors should dissapear.
60
+ ```
61
+
62
+ ### Unlinking Projects after Local Development is Complete
63
+
64
+ ```
65
+ # Inside of library
66
+ $ git checkout package.json
67
+ $ rm -rf node_modules
68
+ $ npm install
69
+
70
+ # Inside of project
71
+ $ git checkout package.json
72
+ $ rm -rf node_modules
73
+ $ npm install
74
+ ```
75
+
76
+ ### `src` directory structure
77
+
78
+ Development takes place inside `src` directory. This is where your library code should live, this code will be bundled with rollup and published to NPM. Exports from `src/index.js` will be included in the library. Files with the `.stories.*` extension will be compiled and built to the `docs` folder and deployed with github pages.
79
+
80
+ ```bash
81
+ |-- src # library code
82
+ | |-- components
83
+ | | |-- ComponentName # Component will be exposed as a part of library
84
+ | | | |-- Component.spec.js # test file
85
+ | | | |-- __snapshots__
86
+ | | | | └── Component.spec.js.snap # test snapshot
87
+ | | | |-- Component.stories.tsx # storybook file
88
+ | | | └── index.tsx
89
+ | |-- providers
90
+ | | |-- ThemeProvider
91
+ | |-- theme
92
+ | | |-- blur.ts
93
+ | | |-- borders.ts
94
+ | | |-- breakpoints.ts
95
+ | | |-- colors.ts
96
+ | | |-- fonts.ts
97
+ | | |-- fontSizes.ts
98
+ | | |-- fontWeights.ts
99
+ | | |-- index.ts
100
+ | | |-- letterSpacings.ts
101
+ | | |-- lineHeights.ts
102
+ | | |-- radii.ts
103
+ | | |-- shadows.ts
104
+ | | |-- sizes.ts
105
+ | | |-- space.ts
106
+ | | |-- transitions.ts
107
+ | | |-- zIndeces.ts
108
+ | └── index.js # entry point for rollup build
109
+ └── setupTests.js
110
+ ```
111
+
112
+ ## Build
113
+
114
+ This site uses [Storybook](https://storybook.js.org/) configuration to handle documentation and examples.
115
+
116
+ ```bash
117
+ npm run build # bundles library code to `build` folder, and documentation code to `docs` folder in the root of project.
118
+ ```
119
+
120
+ You can view live documentation here after deploying: https://televet.github.io/kibble-ui/
121
+
122
+ ## Deploy and Publish
123
+
124
+ 1. Update npm version number with `npm version <patch, major, or minor>`. Read more about [the version options](https://docs.npmjs.com/updating-your-published-package-version-number) here.
125
+ 2. Run `npm run build`
126
+ 3. Commit changes to git.
127
+ 4. When pushing to master, GitHub will publish the package to npm with latest changes.
128
+
129
+ This repository is using a [GitHub Worflow](https://docs.github.com/en/actions/using-workflows). See the `.github` folder for more information.
130
+
131
+ ## Test
132
+
133
+ Please include tests next to the file you are testing.
134
+ `npm run test` - Run all tests
135
+ `npm run test:watch` - Watch tests
136
+
137
+ ## Lint
138
+
139
+ On commit, [husky](https://github.com/typicode/husky) will run [lint-staged](https://github.com/okonet/lint-staged) with `eslint --fix` command on staged files, preventing you from committing badly formatted code. You can change or disable this behavior inside `.linstagedrc` config file. Before each push tests will run in the same manner.
140
+
141
+ ### Caveats
142
+
143
+ - If pre-commit hooks not work (e. g. your code is not linted after commit), run `yarn add husky` in your project folder.
144
+
145
+ #### eslint
13
146
 
14
147
  ```shell script
15
- npx create-react-app %PROJECT_NAME% --template npm-library
16
- ```
17
- Or
18
- ```shell script
19
- yarn create react-app %PROJECT_NAME% --template npm-library
148
+ yarn lint:js # runs eslint in src directory
149
+ yarn fix:js # runs eslint in src directory with --fix parameter
20
150
  ```
21
151
 
22
- Then
152
+ Template extends [CRA eslint rules](https://github.com/facebook/create-react-app/tree/master/packages/eslint-config-react-app) with custom set, tailored for reasonable and clean development process. I added `prettier` to force consistent formatting and `eslint-plugin-fp` to avoid accidental mutations. Don't like trailing semicolons? Feel free to [tweak prettier rules](https://prettier.io/docs/en/configuration.html) inside `.prettierrc` file to match your code style.
153
+
154
+ #### stylelint
23
155
 
24
156
  ```shell script
25
- cd %PROJECT_NAME%
26
- yarn start
157
+ yarn lint:style # runs stylelint in src directory
158
+ yarn fix:style # runs stylelint in src directory with --fix parameter
27
159
  ```
28
160
 
29
- ## Features
161
+ Template includes [stylelint](https://stylelint.io/), to check CSS/SASS/LESS files. We are using [`stylelint-config-standard`](https://github.com/stylelint/stylelint-config-standard) rule set extended with:
30
162
 
31
- - Handles all modern JS features.
32
- - Bundles `commonjs` and `es` module formats.
33
- - [Husky](https://github.com/typicode/husky) for git hooks.
34
- - [Eslint](https://eslint.org/) and [stylelint](https://stylelint.io/).
35
- - [Rollup](https://rollupjs.org/guide/en/) for bundling.
36
- - [Babel](https://babeljs.io/) for transpiling.
37
- - [Jest](https://jestjs.io/) and [react-testing-library](https://testing-library.com/docs/react-testing-library/intro) for testing.
38
- - Supports CSS modules, SASS/SCSS, Less and PostCSS.
39
- - [Storybook](https://storybook.js.org/) for documentation and demo.
40
- - And [much more](https://cra-template-npm-library.netlify.com/).
163
+ ```js
164
+ // Check `calc` functions formatting, required for `calc` to work in IE11
165
+ "function-calc-no-unspaced-operator": true,
166
+ // Custom rules (aka CSS vars) should go first
167
+ "order/order": [
168
+ "custom-properties",
169
+ "declarations"
170
+ ],
171
+ // Require rules to be in alphabetical order
172
+ "order/properties-alphabetical-order": true,
173
+ // Disallow vendor prefixes, since CRA has autoprefixer enabled
174
+ "property-no-vendor-prefix": true,
175
+ "media-feature-name-no-vendor-prefix": true,
176
+ "at-rule-no-vendor-prefix": true,
177
+ "selector-no-vendor-prefix": true,
178
+ // Limit rules nesting for readablity purposes
179
+ "max-nesting-depth": 3,
180
+ // Limit selector complexity for readablity purposes
181
+ "selector-max-compound-selectors": 5
182
+ ```
183
+
184
+ Stylelint errors don't prevent build of application in development mode.
185
+
186
+ ## Peer Dependencies
187
+
188
+ Please see below. These must be dependencies in your project to use this library
189
+
190
+ ```
191
+ "react": ">=16.8.0",
192
+ "react-dom": ">=16.8.0",
193
+ "prop-types": ">=15.0.0"
194
+ ```
41
195
 
42
- ## Contributors
196
+ ## Technologies Used
43
197
 
44
- @morewings, @sky0matic
198
+ - [Create React App](https://github.com/facebook/create-react-app) - (CRA) template to build and publish NPM libraries with **rollup**, **eslint** and **stylelint** configurations.
199
+ - [Chakra UI](https://chakra-ui.com/) - Chakra UI is a simple, modular and accessible component library that gives you the building blocks you need to build your React applications.
200
+ - [Styled Components](https://styled-components.com/docs) - Visual primitives for the component age.
201
+ - [rollup.js](https://rollupjs.org/guide/en/) - Rollup is a module bundler for JavaScript which compiles small pieces of code into something larger and more complex, such as a library or application.
202
+ - [Storybook](https://storybook.js.org/docs/basics/introduction/) - Build bulletproof UI components faster.
203
+ - [Storybook DocsPage](https://github.com/storybookjs/storybook/tree/master/addons/docs#docspage) - DocsPage pulls information from your stories, components, source code, and story metadata to construct a sensible, zero-config default.
204
+ - [React Testing Library](https://testing-library.com/docs/intro) - Simple and complete testing utilities that encourage good testing practices
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const Banner: () => JSX.Element;
3
+ export default Banner;
@@ -0,0 +1,5 @@
1
+ import { ReactNode } from 'react';
2
+ declare const Button: ({ children }: {
3
+ children: ReactNode;
4
+ }) => JSX.Element;
5
+ export default Button;
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const KInput: () => JSX.Element;
3
+ export default KInput;
package/build/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
- import theme from './theme/theme';
2
- import ThemeProvider from './providers/ThemeProvider/ThemeProvider';
3
- export { theme, ThemeProvider };
1
+ import theme, { ITheme } from './theme';
2
+ import KibbleThemeProvider from './providers/ThemeProvider';
3
+ import Button from './components/Button';
4
+ import Banner from './components/Banner';
5
+ export { theme, ITheme, KibbleThemeProvider, Button, Banner };