import React from 'react'; import PageHeader from 'react-bootstrap/lib/PageHeader'; import { connect } from 'react-redux'; import pkg from '../../../package.json'; import Button from 'react-bootstrap/lib/Button'; import FormGroup from 'react-bootstrap/lib/FormGroup'; import FormControl from 'react-bootstrap/lib/FormControl'; import ControlLabel from 'react-bootstrap/lib/ControlLabel'; import Form from 'react-bootstrap/lib/Form'; import Col from 'react-bootstrap/lib/Col'; import InputGroup from 'react-bootstrap/lib/InputGroup'; import Combobox from 'react-input-enhancements/lib/Combobox'; import * as base16 from 'base16'; import * as inspectorThemes from '../../../src/themes'; import getOptions from './getOptions'; import { push as pushRoute } from 'react-router-redux'; const styles = { wrapper: { height: '100vh', width: '80%', margin: '0 auto', paddingTop: '1px' }, header: {}, content: { display: 'flex', alignItems: 'center', justifyContent: 'center', height: '50%' }, buttons: { display: 'flex', width: '40rem', justifyContent: 'center', flexWrap: 'wrap' }, muted: { color: '#CCCCCC' }, button: { margin: '0.5rem' }, links: { textAlign: 'center' }, link: { margin: '0 0.5rem', cursor: 'pointer', display: 'block' }, input: { display: 'inline-block', textAlign: 'left', width: '30rem' } }; const themeOptions = [ ...Object.keys(inspectorThemes).map(value => ({ value, label: inspectorThemes[value].scheme })), null, ...Object.keys(base16) .map(value => ({ value, label: base16[value].scheme })) .filter(opt => opt.label) ]; const ROOT = process.env.NODE_ENV === 'production' ? '/redux-devtools-inspector/' : '/'; function buildUrl(options) { return ( `${ROOT}?` + [ options.useExtension ? 'ext' : '', options.supportImmutable ? 'immutable' : '', options.theme ? 'theme=' + options.theme : '', options.dark ? 'dark' : '' ] .filter(s => s) .join('&') ); } class DemoApp extends React.Component { render() { const options = getOptions(); return (
{pkg.name || Package Name}
{pkg.description || ( Package Description )}
Theme: this.setTheme(options, value)} optionFilters={[]} > {props => } {options.dark ? 'Light theme' : 'Dark theme'}
{(options.useExtension ? 'Disable' : 'Enable') + ' Chrome Extension'} {(options.supportImmutable ? 'Disable' : 'Enable') + ' Full Immutable Support'}
); } toggleExtension = () => { const options = getOptions(); this.props.pushRoute( buildUrl({ ...options, useExtension: !options.useExtension }) ); }; toggleImmutableSupport = () => { const options = getOptions(); this.props.pushRoute( buildUrl({ ...options, supportImmutable: !options.supportImmutable }) ); }; toggleTheme = () => { const options = getOptions(); this.props.pushRoute(buildUrl({ ...options, dark: !options.dark })); }; setTheme = (options, theme) => { this.props.pushRoute(buildUrl({ ...options, theme })); }; toggleTimeoutUpdate = () => { const enabled = !this.props.timeoutUpdateEnabled; this.props.toggleTimeoutUpdate(enabled); if (enabled) { this.timeout = setInterval(this.props.timeoutUpdate, 1000); } else { clearTimeout(this.timeout); } }; } export default connect(state => state, { toggleTimeoutUpdate: timeoutUpdateEnabled => ({ type: 'TOGGLE_TIMEOUT_UPDATE', timeoutUpdateEnabled }), timeoutUpdate: () => ({ type: 'TIMEOUT_UPDATE' }), increment: () => ({ type: 'INCREMENT' }), push: () => ({ type: 'PUSH' }), pop: () => ({ type: 'POP' }), replace: () => ({ type: 'REPLACE' }), changeNested: () => ({ type: 'CHANGE_NESTED' }), pushHugeArray: () => ({ type: 'PUSH_HUGE_ARRAY' }), addIterator: () => ({ type: 'ADD_ITERATOR' }), addHugeObect: () => ({ type: 'ADD_HUGE_OBJECT' }), addRecursive: () => ({ type: 'ADD_RECURSIVE' }), addNativeMap: () => ({ type: 'ADD_NATIVE_MAP' }), addImmutableMap: () => ({ type: 'ADD_IMMUTABLE_MAP' }), changeImmutableNested: () => ({ type: 'CHANGE_IMMUTABLE_NESTED' }), hugePayload: () => ({ type: 'HUGE_PAYLOAD', payload: Array.from({ length: 10000 }).map((_, i) => i) }), addFunction: () => ({ type: 'ADD_FUNCTION' }), addSymbol: () => ({ type: 'ADD_SYMBOL' }), shuffleArray: () => ({ type: 'SHUFFLE_ARRAY' }), pushRoute })(DemoApp);