@opentrons/components 0.0.0-alpha.10

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/Makefile ADDED
@@ -0,0 +1,42 @@
1
+ # opentrons component library makefile
2
+
3
+ # dev server port
4
+ port ?= 6060
5
+
6
+ # These variables can be overriden when make is invoked to customize the
7
+ # behavior of jest
8
+ tests ?=
9
+ cov_opts ?= --coverage=true --ci=true --collectCoverageFrom='components/src/**/*.(js|ts|tsx)'
10
+ test_opts ?=
11
+
12
+ # standard targets
13
+ #####################################################################
14
+
15
+ .PHONY: all
16
+ all: clean dist
17
+
18
+ .PHONY: clean
19
+ clean:
20
+ yarn --cwd .. shx rm -rf storybook-static
21
+
22
+ # artifacts
23
+ #####################################################################
24
+
25
+ .PHONY: dist
26
+ dist:
27
+ yarn --cwd .. build-storybook
28
+
29
+ # development
30
+ #####################################################################
31
+
32
+ .PHONY: dev
33
+ dev:
34
+ yarn --cwd .. start-storybook --port $(port)
35
+
36
+ .PHONY: test
37
+ test:
38
+ $(MAKE) -C .. test-js-components tests="$(tests)" test_opts="$(test_opts)"
39
+
40
+ .PHONY: test-cov
41
+ test-cov:
42
+ make -C .. test-js-components tests=$(tests) test_opts="$(test_opts)" cov_opts="$(cov_opts)"
package/README.md ADDED
@@ -0,0 +1,87 @@
1
+ # opentrons components library
2
+
3
+ React components for Opentrons' applications. Visit the [Opentrons Components Library][components-library] to see available components.
4
+
5
+ [components-library]: https://s3-us-west-2.amazonaws.com/opentrons-components/edge/index.html
6
+
7
+ ## example usage
8
+
9
+ ```javascript
10
+ import { PrimaryButton } from '@opentrons/components'
11
+
12
+ export default function CowButton(props) {
13
+ return <PrimaryButton onClick={() => console.log('🐄')} />
14
+ }
15
+ ```
16
+
17
+ ## setup
18
+
19
+ Usage requirements for dependent projects:
20
+
21
+ - Node v12 and yarn
22
+ - The following `dependencies` (peer dependencies of `@opentrons/components`)
23
+ - `react`: `17.0.1`,
24
+ - `react-router-dom`: `^4.2.2`,
25
+ - `classnames`: `^2.2.5`,
26
+ - `lodash`: `^4.17.4`
27
+
28
+ ### new project setup (optional)
29
+
30
+ If you ever need to set up a new project in the monorepo that depends on the components library:
31
+
32
+ 1. Add the new project to `workspaces` in the repository's `package.json`
33
+ 2. Ensure the required peer dependencies (listed above) are also in `dependencies`
34
+ ```shell
35
+ yarn workspace new-project add react@17.0.1 react-router-dom@^4.2.2 classnames@^2.2.5 lodash@^4.17.4
36
+ ```
37
+ 3. Add `@opentrons/components` at the current version to `dependencies` in the new project's `package.json`
38
+ 4. Run `yarn`
39
+
40
+ If you use the base webpack config in `@opentrons/webpack-config`, the project should import and bundle components from the components library correctly.
41
+
42
+ ## contributing
43
+
44
+ Make sure you have read the top-level [Contributing Guide][contributing].
45
+
46
+ ### unit tests
47
+
48
+ Unit tests are run with the rest of the repositories unit tests from the top level of the project.
49
+
50
+ ```shell
51
+ make test-js
52
+ ```
53
+
54
+ Unit tests live in a `__tests__` directory in the same directory as the module under test. When writing unit tests for components, we've found the following tests to be the most useful:
55
+
56
+ - DOM tests
57
+ - Make sure the component renders the correct node type
58
+ - Make sure DOM attributes are mapped correctly
59
+ - Make sure handlers fire correctly
60
+ - Render tests
61
+
62
+ - Snapshot tests using [jest's snapshot functionality][jest-snapshots]
63
+ - To regenerate snapshots after an intentional rendering change, run:
64
+
65
+ ```shell
66
+ make test-js updateSnapshot=true
67
+ ```
68
+
69
+ [jest-snapshots]: https://facebook.github.io/jest/docs/en/snapshot-testing.html
70
+ [contributing]: ../CONTRIBUTING.md
71
+
72
+ ### Flow definitions
73
+
74
+ While the components library is written in TypeScript, some dependents of the components library are not yet converted. To ease the conversion effort, `components/flow-types` contains automatically generated Flow type definitions from the TypeScript typings generated by `tsc`.
75
+
76
+ To generate these definitions
77
+
78
+ ```shell
79
+ # ensure all TypeScript definitions are built
80
+ make build-ts
81
+
82
+ # build flow definitions (this may take a while!)
83
+ make -C components flow-types
84
+
85
+ # you can also build individual files if you're testing out small changes
86
+ make -C components flow-types/buttons/Button.js.flow
87
+ ```
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@opentrons/components",
3
+ "version": "0.0.0-alpha.10",
4
+ "description": "React components library for Opentrons' projects",
5
+ "source": "src/index.ts",
6
+ "types": "lib/index.d.ts",
7
+ "style": "src/index.css",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/Opentrons/opentrons.git"
11
+ },
12
+ "author": "Opentrons Labworks <engineering@opentrons.com> (https://opentrons.com)",
13
+ "license": "Apache-2.0",
14
+ "bugs": {
15
+ "url": "https://github.com/Opentrons/opentrons/issues"
16
+ },
17
+ "homepage": "https://github.com/Opentrons/opentrons#readme",
18
+ "peerDependencies": {
19
+ "react": "17.0.1",
20
+ "react-router-dom": "5.1.1"
21
+ },
22
+ "dependencies": {
23
+ "@opentrons/shared-data": "link:../shared-data",
24
+ "@popperjs/core": "2.1.1",
25
+ "@react-spring/types": "9.6.1",
26
+ "@react-spring/web": "9.6.1",
27
+ "@types/classnames": "2.2.5",
28
+ "@types/lodash": "^4.14.191",
29
+ "@types/react": "^17.0.1",
30
+ "@types/react-router-dom": "^5.1.7",
31
+ "@types/styled-components": "^5.1.26",
32
+ "@types/webpack-env": "^1.16.0",
33
+ "classnames": "2.2.5",
34
+ "interactjs": "^1.10.17",
35
+ "lodash": "4.17.21",
36
+ "react-popper": "1.0.0",
37
+ "react-remove-scroll": "2.4.3",
38
+ "react-select": "5.4.0",
39
+ "styled-components": "5.3.6"
40
+ },
41
+ "browser": {
42
+ "jest-when": false
43
+ }
44
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "extends": "../tsconfig-base.json",
3
+ "references": [
4
+ {
5
+ "path": "../shared-data"
6
+ }
7
+ ],
8
+ "compilerOptions": {
9
+ "composite": true,
10
+ "rootDir": "src",
11
+ "outDir": "lib"
12
+ },
13
+ "include": ["typings", "src"],
14
+ "exclude": ["**/*.stories.tsx"]
15
+ }
@@ -0,0 +1,5 @@
1
+ declare module '*.css' {
2
+ const styles: { [key: string]: string }
3
+ // eslint-disable-next-line import/no-default-export
4
+ export default styles
5
+ }
@@ -0,0 +1,2 @@
1
+ import 'jest-styled-components'
2
+ import 'styled-components/cssprop'
@@ -0,0 +1,10 @@
1
+ declare module '*.png' {
2
+ const image: string
3
+ // eslint-disable-next-line import/no-default-export
4
+ export default image
5
+ }
6
+ declare module '*.svg' {
7
+ const image: string
8
+ // eslint-disable-next-line import/no-default-export
9
+ export default image
10
+ }