2017-11-15 15:13:49 +01:00
|
|
|
// import polyfill
|
|
|
|
import 'babel-polyfill';
|
|
|
|
|
|
|
|
// inject tap event plugin
|
|
|
|
import injectTapEventPlugin from 'react-tap-event-plugin';
|
|
|
|
injectTapEventPlugin();
|
|
|
|
|
|
|
|
// create store
|
|
|
|
import { createStore, combineReducers, compose, applyMiddleware } from 'redux';
|
|
|
|
import thunkMiddleware from 'redux-thunk';
|
|
|
|
import promiseMiddleware from 'redux-promise-middleware';
|
|
|
|
import { createLogger } from 'redux-logger';
|
|
|
|
const reducer = combineReducers({ sketcher: sketcherReducer });
|
|
|
|
const enhancer = compose(applyMiddleware(thunkMiddleware, promiseMiddleware(), createLogger({ collapsed: true })));
|
|
|
|
const store = createStore(reducer, enhancer);
|
|
|
|
|
|
|
|
// prepare html (SHOULDN'T BE DONE LIKE THIS)
|
|
|
|
document.body.style.margin = 0;
|
|
|
|
document.body.style.padding = 0;
|
|
|
|
document.body.style.height = '100%';
|
|
|
|
document.documentElement.style.height = '100%';
|
|
|
|
document.documentElement.style.overflow = 'hidden';
|
|
|
|
document.getElementById('app').style.height = '100%';
|
|
|
|
|
2017-11-17 23:34:20 +01:00
|
|
|
import actionWrapper from 'redux-action-wrapper';
|
2017-11-17 22:22:36 +01:00
|
|
|
import * as actions from './src/actions/index.js';
|
2017-11-17 23:34:20 +01:00
|
|
|
window.actions = actionWrapper(actions, store.dispatch);
|
2017-11-17 22:22:36 +01:00
|
|
|
|
2017-11-23 15:56:04 +01:00
|
|
|
// add inital shapes
|
2017-11-18 21:21:16 +01:00
|
|
|
import * as CAL from 'cal';
|
|
|
|
store.dispatch(actions.addObject({
|
2017-11-28 15:47:26 +01:00
|
|
|
type: 'FREE_HAND',
|
|
|
|
fill: false,
|
2017-11-18 21:21:16 +01:00
|
|
|
solid: false,
|
2017-11-28 15:47:26 +01:00
|
|
|
points: [new CAL.Vector(-20, 0), new CAL.Vector(10, 1)],
|
|
|
|
transform: new CAL.Matrix({ x: 0, y: 0 })
|
2017-11-18 21:21:16 +01:00
|
|
|
}));
|
|
|
|
store.dispatch(actions.addObject({
|
|
|
|
type: 'RECT',
|
|
|
|
fill: true,
|
|
|
|
rectSize: new CAL.Vector(20, 20),
|
|
|
|
height: 40,
|
|
|
|
transform: new CAL.Matrix({ x: -10, y: -10 })
|
|
|
|
}));
|
|
|
|
|
2017-11-15 15:13:49 +01:00
|
|
|
// render dom
|
|
|
|
import React from 'react';
|
|
|
|
import { Provider } from 'react-redux';
|
|
|
|
import { render } from 'react-dom';
|
|
|
|
import App from './src/components/App.js';
|
|
|
|
import sketcherReducer from './src/reducer/index.js';
|
|
|
|
|
|
|
|
render((
|
|
|
|
<Provider store={store}>
|
2017-11-15 15:37:11 +01:00
|
|
|
<App />
|
2017-11-15 15:13:49 +01:00
|
|
|
</Provider>
|
|
|
|
), document.getElementById('app'));
|