-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(labware-library): Scaffold out project (#3206)
- Loading branch information
Showing
20 changed files
with
641 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# opentrons labware-library makefile | ||
|
||
SHELL := /bin/bash | ||
|
||
# add node_modules/.bin to PATH | ||
PATH := $(shell cd .. && yarn bin):$(PATH) | ||
|
||
.PHONY: all | ||
all: clean dist | ||
|
||
.PHONY: clean | ||
clean: | ||
shx rm -rf dist | ||
|
||
# production assets | ||
.PHONY: dist | ||
dist: export NODE_ENV := production | ||
dist: | ||
webpack --profile | ||
|
||
# development assets server | ||
.PHONY: dev | ||
dev: export NODE_ENV := development | ||
dev: | ||
webpack-dev-server --hot | ||
|
||
# production assets server | ||
.PHONY: serve | ||
serve: all | ||
node ../scripts/serve-static dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# labware library | ||
|
||
<https://labware.opentrons.com> | ||
|
||
> Library of standard labware for use with your OT-2 | ||
The Labware Library is an app for OT-2 users to discover, learn about, and use the labware the OT-2 supports. | ||
|
||
## development setup | ||
|
||
### setup | ||
|
||
Follow the top-level [contributing guide][contributing] to set your repository up for development. | ||
|
||
```shell | ||
cd opentrons | ||
make install | ||
``` | ||
|
||
### common tasks | ||
|
||
Unit tests, linting, and typechecking are all run from the repository level Makefile. The contributing guide has more details. | ||
|
||
```shell | ||
# run unit-tests, lints, and typechecks | ||
make test-js lint-js check-js | ||
|
||
# run unit-tests in watch mode | ||
make test-js watch=true | ||
``` | ||
|
||
[contributing]: ../CONTRIBUTING.md | ||
|
||
### labware-library tasks | ||
|
||
This directory's Makefile has the following set of labware-library specific development tasks defined. | ||
|
||
```shell | ||
# default task: build production artifacts | ||
# these three commands are identical | ||
make -C labware-library | ||
make -C labware-library all | ||
make -C labware-library clean dist | ||
|
||
# start a hot-reloading development server | ||
# (optional) specify port with PORT; default is 8080 | ||
make -C labware-library dev | ||
make -C labware-library dev PORT=8081 | ||
|
||
# build production assets and serve them | ||
# (optional) specify port with PORT; default is 9090 | ||
make -C labware-library serve | ||
make -C labware-library serve PORT=9091 | ||
``` | ||
|
||
### webpack setup | ||
|
||
This project (along with our other front-end projects) uses [webpack][] to generate artifacts. | ||
|
||
- Extends our [base webpack config][base-config] | ||
- Entry point is [`labware-library/src/index.js`][entry] | ||
- [Handlebars][] HTML template is [`labware-library/src/index.hbs`][template] | ||
- At template build time, JS entry is run via [prerender-loader][] | ||
- DOM output from JS is then inserted into HTML output | ||
- Global CSS is [`labware-library/src/global.css`][global-style] | ||
- All other CSS is used via [CSS Modules][] | ||
- All artifacts will be output to `labware-library/dist` | ||
|
||
[handlebars]: https://handlebarsjs.com/ | ||
[css modules]: https://github.com/css-modules/css-modules | ||
[prerender-loader]: https://github.com/GoogleChromeLabs/prerender-loader | ||
[base-config]: ../webpack-config | ||
[entry]: ./src/index.js | ||
[template]: ./src/index.hbs | ||
[global-style]: ./src/global.css | ||
|
||
### environment variables | ||
|
||
Certain environment variables, when set, will affect the artifact output. | ||
|
||
| variable | value | description | | ||
| -------- | ----------------------------- | ------------------------------------------- | | ||
| NODE_ENV | production, development, test | Optimizes output for a specific environment | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "@opentrons/labware-library", | ||
"productName": "Labware Library", | ||
"version": "3.7.0", | ||
"description": "Opentrons standard labware library", | ||
"main": "src/index.js", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Opentrons/opentrons.git", | ||
"directory": "labware-library" | ||
}, | ||
"author": { | ||
"name": "Opentrons Labworks", | ||
"email": "[email protected]" | ||
}, | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"@opentrons/components": "3.7.0", | ||
"react-hot-loader": "^4.8.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// app tests | ||
import React from 'react' | ||
import Renderer from 'react-test-renderer' | ||
|
||
import {App} from '..' | ||
|
||
describe('App', () => { | ||
test('component renders', () => { | ||
const tree = Renderer.create(<App />).toJSON() | ||
expect(tree).toMatchSnapshot() | ||
}) | ||
}) |
9 changes: 9 additions & 0 deletions
9
labware-library/src/components/App/__tests__/__snapshots__/App.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`App component renders 1`] = ` | ||
<h1 | ||
className="title" | ||
> | ||
Opentrons Labware Library | ||
</h1> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// @flow | ||
// main application wrapper component | ||
import * as React from 'react' | ||
import {hot} from 'react-hot-loader/root' | ||
|
||
import styles from './styles.css' | ||
|
||
export function App () { | ||
return <h1 className={styles.title}>Opentrons Labware Library</h1> | ||
} | ||
|
||
export default hot(App) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* app styles */ | ||
@import '@opentrons/components'; | ||
|
||
.title { | ||
@apply --font-huge-dark; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
* global styles | ||
*/ | ||
|
||
@import url('https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,800'); | ||
@import './styles/reset.css'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width,initial-scale=1" /> | ||
<meta name='description' content='{{htmlWebpackPlugin.options.description}}'> | ||
<meta name='author' content='{{htmlWebpackPlugin.options.author}}'> | ||
<title>{{htmlWebpackPlugin.options.title}}</title> | ||
</head> | ||
|
||
<body> | ||
<div id="root"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// @flow | ||
// labware library entry | ||
import * as React from 'react' | ||
|
||
import './global.css' | ||
import App from './components/App' | ||
|
||
render() | ||
|
||
export default function render () { | ||
const $root = document.getElementById('root') | ||
|
||
if (!$root) { | ||
throw new Error('fatal: #root not found') | ||
} | ||
|
||
return Promise.all([import('react-dom')]).then(([{default: ReactDom}]) => { | ||
ReactDom.hydrate(<App />, $root) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* basic CSS reset | ||
* TODO(mc, 2019-03-12): copied from Opentrons/opentrons-website; merge somehow | ||
*/ | ||
|
||
/* use border-box because it's more sane */ | ||
*, | ||
*::before, | ||
*::after { | ||
box-sizing: border-box; | ||
} | ||
|
||
/* prevent adjustments of font size after mobile orientation changes */ | ||
html { | ||
text-size-adjust: 100%; | ||
} | ||
|
||
/* remove margin from body and set sane font-size + line-height */ | ||
body { | ||
margin: 0; | ||
font-size: 16px; | ||
line-height: 1; | ||
font-family: 'Open Sans', sans-serif; | ||
} | ||
|
||
/* ensure <main> works in IE 9, 10, and 11 */ | ||
main { | ||
display: block; | ||
} | ||
|
||
/* make images responsive */ | ||
img { | ||
max-width: 100%; | ||
border-style: none; | ||
} | ||
|
||
/* strip margin and padding from text elements */ | ||
h1, | ||
h2, | ||
h3, | ||
h4, | ||
h5, | ||
h6, | ||
p, | ||
ul, | ||
ol { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
/* no list style by default */ | ||
ul, | ||
ol { | ||
list-style: none; | ||
} | ||
|
||
/* no underline on links by default */ | ||
a { | ||
text-decoration: none; | ||
} |
Oops, something went wrong.