This is the start of a new implementation of headstart using the React and MobX libraries to to improve software sustainability, event and state management.
The project is still in an very early phase and will change quickly.
Since this app was bootstrapped with Create React App
you will need to have node
installed with a version >=6
.
To install the necessary dependencies, issue the command npm install
after cloning the repo.
To start a development server, just type npm start
. A browser window will open at http://localhost:3000
and you can play around with the app.
You can run the test suite by running npm test
.
To build a production build run npm run build
.
The bundled html
/css
/js
files can be found in the build
subdirectory.
To deploy the application, serve the build
-directory's contents via
a server of your choice.
Since there is no integration with the backend yet the site is just static files so far.
TODO: Update deployment instructions once backend is integrated.
Main Entry point to the execution is the src/index.js
file.
All React components. Main entry point is found in src/components/App.js
component.
Eventhandling functions, named after the general area they are bound to.
Helper functions, e.g. the force simulation that calculates the layout.
MobX stores and their members, e.g. the UIStore, various classes modeling state of Bubbles/Papers.
Static assets and mock data from the backend.
Sass stylesheets. Have to be recompiled manually for now and have
to end up in src/stylesheets/main.css
.
Files to be picked up by the testing suite. Have to have the file extension *.test.js. Currently not passing.
The root <svg>
tag can be found in src/components/Chart.js
. To add a new
element to the svg:
-
Come up with the state the element needs (coordinates, dimensions) and add it to the UIStore (
src/models/UIStore.js
), possibly creating a class to manage the element's state if needed. -
Create a React component in
src/components/
, passing the UIStore to it as a prop and getting the necessary state from it. Depending on the state, parts of the component can be rendered one way or the other by conditionally adding styling, adding/substracting markup within the component's render method. -
Import the
observer
function frommobx-react
and wrap your component class/function in it. This connects the component to the UI store and will update the component everytime the UI Store's observables change.
To add new events to existing elements of the frontend:
- Look through the existing event-handling functions in
eventhandlers
to see whether an event-handler already exists. If it does, use it. - If no event handler exists, create a new one and think of a good name. The event handler should modify the UIStore to achieve the desired effect.