.
├── src
│ ├── assets: images, logos, etc.
│ ├── components: jsx UI components
│ ├── lib: static information like team member names and assay lists
│ ├── main.css: Compiled from sass/main.sass
│ ├── sass: source sass styling
│ ├── storybook.test.js: initialize snapshots for storybook tests
│ ├── storybookSnapshotInit.Skiptest.js: rename Skiptest to test to include snapshot testing
│ ├── testData: Mock data used in stories and tests
│ └── [Component/Feature Name]: contains reducers, actions, components, subcomponents, and tests
│ | └── __test__: contains the storybook story and jest tests for the feature.
├── public
├── .storybook: configuration for storybook
├── .eslintrc.js: ESlint configuration
├── .prettierrc.js: Prettier configuration
├── .stylelint.config.js: StyleLint configurations for Sass Linting
- Create [component].jsx file in src/[Component]
- Create storybook snapshots file src/[Component]/__test__/[component].stories.jsx
- Create tests in src/[Component]/__test__/[component].test.jsx
- Integrate required actions and reducers in to the components directory (ex. for upload handling logic that would be src/UploadPage/uploadReducer.js)
- If it is a full page, add routing logic to src/App/App.jsx
-
Preparation:
- Set
node
environment to16.20.x
, or usenvm
to runnvm use v16.20.0
- If
node_modules
directory already exist in your local working copy, runrm -fr node_modules/
andrm -f yarn.lock
. - Create a
.env
file at the root of the local working copy and addESLINT_NO_DEV_ERRORS=true
. - Add additional required environment variables to the
.env
file in root (e.g. the API service address) - Run
yarn install
.
- Set
-
Building CSS: Uses sass in
node_modules/sass/sass.js
yarn sass
- Compiles sass from
src/sass/main.scss
tosrc/main.css
yarn sass-watch
- Compiles sass from
src/sass/main.scss
tosrc/main.css
and watches for changes
-
Running React App:
yarn start
- Runs core React app at localhost:3000
-
Running Storybook:
yarn run storybook
- Runs storybook server at localhost:9009
-
Testing:
yarn test
- Runs tests and storybook snapshots
yarn test --coverage
- Runs all tests and returns table illustrating code coverage
-
Quickly inspect someone's branch:
yarn inspect-branch
- Compiles Scss, rebuilds node_modules if different, and starts react app
-
- Check your version:
node --version
- If the version is not 16, you can
brew install node@16
or use [nvm](https://github. com/creationix/nvm/blob/master/README.md#installation), the Node Version Manager
- Check your version:
-
- Storybook used to visualize individual UI components
-
Style guide:
- localtunnel used to serve react app with command
lt --port 3000
after running the app usingyarn start
in a seperate terminal - url from localtunnel used to test in Twitter Card Validator and the Facebook Sharing Debugger
%PUBLIC_URL%
evaluates to nothing if the application is running on the dev server so the images which require absolute urls may not display
- Components that need to be linked to a redux store in implementation are exported by default as connected functions/containers. They are also exported in pure function form (ex: "import { UploadScreen } from 'path/to/component' " for pure function and "import UploadScreen from 'path/to/component'" for container).
- mapStateToProps used to link the section from the combined reducer to properties required by the container
- mapDispatchtoProps defines required actions and what to send to a reducer.
- redux-thunk middleware used to handle asynchronous requests like for authentication
- Storybook has trouble integrating with react-router, I installed a package called storybook-react-router to make them work together. If you run in to an issue with storybook saying something like "You should not use outside " it has something to do with react-router and storybook-react-router
- React-router is being used to handle routing
- history ( createBrowserHistory ) is used to update location from button clicks and function calls ( history.push('path/to/new/location') )
- < Link > tags from react-router are used in place of < a > tags handle navigation from links. Certain elements return < Redirect to="path/to/new/location" > elements if protected and user not authenticated.
- Analysis page only uses routing to differentiate between human and analysis (/analysis/human or /analysis/animal). After that it acts as a single page application.
- Makes call to backend for a list of uploads (size depending maxRows variable) on a given page. Expects backend to give total count of uploads fitting filters and the uploads for a specific page. (e.g on page 2, with 10 rows per page, expects items 11-20 from backend and a count of all rows that fit current filters)
- Changing filters should also call backend
Cross-browser Testing Platform and Open Source ❤️ provided by Sauce Labs