From 1ee6ef7c2b5db64d56f0ae9c71c664edcced108f Mon Sep 17 00:00:00 2001 From: Yanbing Zhao Date: Mon, 5 Feb 2018 14:28:51 +0800 Subject: [PATCH] Add render config (read only now) --- src/component/Config.js | 65 +++++++++++++++++++++++++++++++++++++++++ src/component/Header.js | 10 ++++++- src/index.css | 12 ++++++-- src/index.js | 24 ++++++++++++++- 4 files changed, 106 insertions(+), 5 deletions(-) create mode 100644 src/component/Config.js diff --git a/src/component/Config.js b/src/component/Config.js new file mode 100644 index 0000000..e7db9ce --- /dev/null +++ b/src/component/Config.js @@ -0,0 +1,65 @@ +import React from 'react' +import Dialog from 'material-ui/Dialog' +import FontIcon from 'material-ui/FontIcon' +import IconButton from 'material-ui/IconButton' +import FlatButton from 'material-ui/FlatButton' +import { GridList, GridTile } from 'material-ui/GridList' + +class Config extends React.Component { + constructor (props) { + super(props) + this.state = {open: false} + } + + collectRendererConfig = () => this.props.configCollector()['renderer'] + + handleOpen = () => { + this.setState({open: true}); + } + + handleClose = () => { + this.setState({open: false}); + } + + generateRenderConfigList = () => { + let result = [] + let rendererConfig = this.collectRendererConfig() + for (let key in rendererConfig) { + let {prefix, suffix} = rendererConfig[key] + result.push( +
+

{key}

+
{prefix + '`' + suffix + '`'}
+
+ ) + } + return result + } + + render() { + console.log(this.collectRendererConfig()) + const actions = [ +// , + + ] + return ( +
+ + settings + + + {this.generateRenderConfigList()} + +
+ ); + } +} + +export default Config diff --git a/src/component/Header.js b/src/component/Header.js index 288ade5..5ff3b3d 100644 --- a/src/component/Header.js +++ b/src/component/Header.js @@ -2,11 +2,19 @@ import React from 'react' import AppBar from 'material-ui/AppBar' import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider' +import Config from './Config' + class Header extends React.Component { + constructor (props) { + super(props) + } render () { return ( - + } + title='MCBBS Markdown To BBCode Converter' /> ) } diff --git a/src/index.css b/src/index.css index e8ac1a9..ecc008e 100644 --- a/src/index.css +++ b/src/index.css @@ -1,13 +1,19 @@ html, body { - overflow-x: hidden; height: 100%; width: 100%; margin: 0; } +main { + overflow-x: hidden; + position: fixed; + height: 100%; + width: 100%; +} + .main-left { position: absolute; - top: 96px; + top: 32px; bottom: 96px; padding: 4px 16px; overflow-y: auto; @@ -16,7 +22,7 @@ html, body { .main-right { position: absolute; - top: 96px; + top: 32px; bottom: 96px; padding: 0 16px; overflow-y: auto; diff --git a/src/index.js b/src/index.js index ee78688..7b12d5b 100644 --- a/src/index.js +++ b/src/index.js @@ -45,6 +45,28 @@ function setRenderer () { } } +function collectConfig () { + let rendererConfigResult = {} + let rendererConfigFromLocalStorage = (() => { + try { + return JSON.parse(localStorage.rendererConfig) + } catch (e) { + return {} + } + })() + for (let key in rendererConfig) { + let {prefix, suffix} = rendererConfig[key] + suffix = rendererConfigFromLocalStorage[key] || suffix + rendererConfigResult[key] = { + prefix: prefix, + suffix: suffix + } + rendererConfigFromLocalStorage[key] = suffix + } + localStorage.rendererConfig = JSON.stringify(rendererConfigFromLocalStorage) + return {renderer: rendererConfigResult} +} + setRenderer() function onTransform (markdownText) { @@ -54,5 +76,5 @@ function onTransform (markdownText) { })) } -ReactDOM.render(
, document.getElementsByTagName('header')[0]) +ReactDOM.render(
, document.getElementsByTagName('header')[0]) ReactDOM.render(
, document.getElementsByTagName('main')[0])