0.0.19-17 • Published 7 years ago
@workbench-stack/client-layout-react v0.0.19-17
React-PanelGroup
Examples
/// <reference path='../../../typings/index.d.ts' />
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { createStore, Store, applyMiddleware, Middleware, GenericStoreEnhancer, compose, combineReducers } from 'redux';
import { Provider as ReduxProvider } from 'react-redux';
import thunk from 'redux-thunk';
import { persistStore, autoRehydrate } from 'redux-persist';
// import { addPersistedQueries } from 'persistgraphql';
import { SubscriptionClient, addGraphQLSubscriptions } from 'subscriptions-transport-ws';
import { Provider as FelaProvider } from 'react-fela';
import { createRenderer as createFelaRenderer } from 'fela';
import { app as settings } from '../../../app.json';
// const queryMap = require('persisted_queries.json');
require('backend_reload');
import { ApolloClient, createNetworkInterface, ApolloProvider, NetworkInterface } from 'react-apollo';
// import {
// reducers,
// Store as StoreState,
// } from '@workbench-stack/client-redux';
import {
themeReducer,
sideMenuReducer,
resizeReducer,
consolePanelReducer,
} from '@workbench-stack/client-layout-redux';
import {
IconPanelEnhanced,
TreePanelEnhanced,
RightLayout,
} from '@workbench-stack/client-layout-react';
import './index.css';
const rootEl = document.getElementById('content');
const networkInterface = createNetworkInterface({
uri: __EXTERNAL_BACKEND_URL__ || '/graphql',
});
const wsClient = new SubscriptionClient((__EXTERNAL_BACKEND_URL__ || (window.location.origin + '/graphql'))
.replace(/^http/, 'ws')
.replace(':' + settings.webpackDevPort, ':' + settings.apiPort), {
reconnect: true,
});
// Extend the network interface with the WebSocket
let networkInterfaceWithSubscriptions = addGraphQLSubscriptions(
networkInterface,
wsClient,
);
// if (__PERSIST_GQL__) {
// networkInterfaceWithSubscriptions = addPersistedQueries(networkInterfaceWithSubscriptions, queryMap);
// }
const client = new ApolloClient({
networkInterface,
reduxRootSelector: state => state.apollo,
});
const middlewares: Middleware[] = [
thunk,
client.middleware(),
];
const enhancers: GenericStoreEnhancer[] = [
applyMiddleware(...middlewares),
autoRehydrate(),
];
const REDUX_EXTENSION_COMPOSE_NAME: string = '__REDUX_DEVTOOLS_EXTENSION_COMPOSE__';
const composeEnhancers =
window[REDUX_EXTENSION_COMPOSE_NAME] ?
window[REDUX_EXTENSION_COMPOSE_NAME] : compose;
const store = createStore(
combineReducers({
// ...reducers,
theme: themeReducer,
sideMenu: sideMenuReducer,
consolePanel: consolePanelReducer,
resize: resizeReducer,
apollo: client.reducer(),
}),
// {} as StoreState.Panel,
composeEnhancers(...enhancers),
);
persistStore(store, { whitelist: ['resize', 'sideMenu', 'theme', 'consolePanel'] });
// const felaRenderer = createFelaRenderer();
// Commented out ("let HTML app be HTML app!")
const renderer = createFelaRenderer();
window.addEventListener('DOMContentLoaded', () => {
if (rootEl) {
ReactDOM.render(
<FelaProvider renderer={renderer}>
<ApolloProvider store={store} client={client}>
<ReduxProvider store={store} >
<div style={{ display: 'flex', height: '100%' }}>
<IconPanelEnhanced />
<TreePanelEnhanced />
<RightLayout />
</div>
</ReduxProvider>
</ApolloProvider>
</FelaProvider>
, rootEl);
}
});
0.0.19-17
7 years ago
0.0.19-16
7 years ago
0.0.19-15
7 years ago
0.0.19-14
7 years ago
0.0.19-13
7 years ago
0.0.19-12
7 years ago
0.0.19-11
7 years ago
0.0.19-10
7 years ago
0.0.19-8
7 years ago
0.0.19-6
7 years ago
0.0.19-3
7 years ago
0.0.19-2
7 years ago
0.0.19-1
7 years ago
0.0.19-0
7 years ago
0.0.18-35
7 years ago
0.0.18-33
7 years ago
0.0.18-31
7 years ago
0.0.18-29
7 years ago
0.0.18-27
7 years ago
0.0.18-26
7 years ago
0.0.18-25
7 years ago
0.0.18-24
7 years ago
0.0.18-23
7 years ago
0.0.18-22
7 years ago
0.0.18-20
7 years ago
0.0.18-19
7 years ago
0.0.18-18
7 years ago
0.0.18-y.0
7 years ago
0.0.18-17
7 years ago
0.0.18-15
7 years ago
0.0.18-14
7 years ago
0.0.21-0
7 years ago
0.0.18-13
7 years ago
0.0.18-12
7 years ago
0.0.18-11
7 years ago
0.0.18-10
7 years ago
0.0.18-6
7 years ago
0.0.18-5
7 years ago
0.0.18
7 years ago
0.0.21
7 years ago
0.0.20
7 years ago
0.0.17-50
7 years ago
0.0.17-45
7 years ago
0.0.19
7 years ago
0.0.17-41
7 years ago
0.0.17-40
7 years ago
0.0.17-35
8 years ago
0.0.17-30
8 years ago
0.0.17-25
8 years ago
0.0.17-15
8 years ago
0.0.17-5
8 years ago
0.0.17
8 years ago
0.0.16
8 years ago
0.0.15-3
8 years ago
0.0.15-2
8 years ago
0.0.15
8 years ago
0.0.13-3
8 years ago
0.0.13-2
8 years ago
0.0.13-1
8 years ago
0.0.12
8 years ago
0.0.10
8 years ago