@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 +190 -30
- package/build/components/Banner/index.d.ts +3 -0
- package/build/components/Button/index.d.ts +5 -0
- package/build/components/Input/index.d.ts +3 -0
- package/build/index.d.ts +5 -3
- package/build/index.js +335 -12575
- package/build/index.js.map +1 -1
- package/build/providers/ThemeProvider/index.d.ts +5 -0
- package/build/theme/index.d.ts +33 -0
- package/build/theme/tokens/blur.d.ts +12 -0
- package/build/theme/tokens/borders.d.ts +15 -0
- package/build/theme/tokens/colors.d.ts +194 -0
- package/build/theme/tokens/fontSizes.d.ts +17 -0
- package/build/theme/tokens/fontWeights.d.ts +13 -0
- package/build/theme/tokens/fonts.d.ts +7 -0
- package/build/theme/tokens/letterSpacings.d.ts +17 -0
- package/build/theme/tokens/lineHeights.d.ts +19 -0
- package/build/theme/tokens/radii.d.ts +13 -0
- package/build/theme/tokens/shadows.d.ts +27 -0
- package/build/theme/tokens/sizes.d.ts +27 -0
- package/build/theme/tokens/space.d.ts +37 -0
- package/build/theme/tokens/transition.d.ts +28 -0
- package/build/theme/tokens/zIndeces.d.ts +17 -0
- package/package.json +33 -29
- package/build/index.es.js +0 -12692
- package/build/index.es.js.map +0 -1
- package/build/providers/ThemeProvider/ThemeProvider.d.ts +0 -5
- package/build/theme/theme.d.ts +0 -2
- package/build/theme/tokens/colors/colors.d.ts +0 -190
package/README.md
CHANGED
|
@@ -1,44 +1,204 @@
|
|
|
1
|
-
|
|
2
|
-
[](https://dependabot.com)
|
|
3
|
-
[](https://david-dm.org/morewings/cra-template-npm-library)
|
|
4
|
-
[](https://app.netlify.com/sites/cra-template-npm-library/deploys)
|
|
5
|
-
[](https://www.npmjs.com/package/cra-template-npm-library)
|
|
6
|
-
[](https://www.npmjs.com/package/cra-template-npm-library)
|
|
1
|
+
# Kibble
|
|
7
2
|
|
|
8
|
-
|
|
3
|
+
Kibble is a React component library for use at TeleVet.
|
|
9
4
|
|
|
10
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
26
|
-
yarn
|
|
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
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
-
|
|
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
|
-
##
|
|
196
|
+
## Technologies Used
|
|
43
197
|
|
|
44
|
-
|
|
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
|
package/build/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import theme from './theme
|
|
2
|
-
import
|
|
3
|
-
|
|
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 };
|