Commit 5d003817 authored by Jure's avatar Jure

Initial working version of Substance components.

parent 33bbdf10
node_modules/
import React from 'react'
import LensReader from 'lens/ReactLensReader'
// Styles
import './styles/reader.scss'
export default class Reader extends React.Component {
render () {
const { content } = this.props
return (
<div className='blogpost'>
<LensReader content={content} />
</div>
)
}
}
Reader.propTypes = {
// Data
content: React.PropTypes.string,
}
export default Reader
import React from 'react'
import './styles/summary'
import { Row, Col } from 'react-bootstrap'
import { LinkContainer } from 'react-router-bootstrap'
export default class Summary extends React.Component {
render () {
const { fragment } = this.props
let summary = fragment.presentation.match(/<abstract>(.*?)<\/abstract>/)
summary = summary[1]
return (
<div className='blogpost'>
<Row key={fragment._id}>
<Col xs={12} md={8} mdOffset={2}>
<h2>{fragment.title}</h2>
<div dangerouslySetInnerHTML={{__html: summary}}></div>
<LinkContainer to={`/${fragment._id}`}><a>Read more</a></LinkContainer>&nbsp;
</Col>
</Row>
</div>
)
}
}
Summary.propTypes = {
blogpost: React.PropTypes.object
}
import React from 'react'
import LensWriter from 'lens/ReactLensWriter'
// Styles
import './node_modules/lens/styles/lens-writer.scss'
import './styles/writer.scss'
class Writer extends React.Component {
constructor (props) {
super(props)
this.save = this.save.bind(this)
}
save (content, callback) {
let fragment = Object.assign(this.props.fragment, {
source: content,
presentation: content
})
this.props.save(fragment)
callback(null, content)
}
fileUpload (file, callback) {
console.log(this.props.fileUpload)
return callback(null, null)
}
render () {
let editor
let content
if (this.props.fragment) {
if (this.props.fragment.source === '') {
content = '<article xmlns="http://substance.io/science-article/0.1.0" lang="en"><metadata><title>' +
this.props.fragment.title + '</title><abstract>hello</abstract></metadata><resources></resources>' +
'<body><p id="p1">test</p></body></article>'
} else {
content = this.props.fragment.source
}
editor = <LensWriter
content={content}
onSave={this.save}
onFileUpload={this.fileUpload}
/>
} else {
editor = <p>Loading</p>
}
return (
<div>{editor}</div>
)
}
}
Writer.propTypes = {
fragment: React.PropTypes.object,
save: React.PropTypes.func,
fileUpload: React.PropTypes.func
}
export default Writer
{
"name": "pubsweet-substance-components",
"version": "0.0.0",
"private": true,
"dependencies": {
"lens": "substance/lens#969d3f0f1c1b13361317986ea91cc5dfc1073748",
"react-router-bootstrap": "^0.19.0",
"node-sass": "^3.1.2",
"react": "^0.14.0",
"webpack": "^1.12.2"
},
"devDependencies": {
"babel-eslint": "^4.1.1",
"babel-plugin-object-assign": "^1.2.1",
"config": "^1.16.0",
"eslint": "^1.3.1",
"eslint-config-standard": "^4.3.2",
"eslint-config-standard-react": "^1.0.5",
"eslint-loader": "^1.0.0",
"eslint-plugin-react": "^3.3.2"
},
"standard": {
"parser": "babel-eslint"
}
}
.blogpost {
padding-bottom: 2em;
}
// .content-tools-component, .le-main, .le-workspace, .lc-writer {
// top: 52px;
// }
// .content-panel-component {
// top: 92px;
// }
// .panel-content-inner {
// z-index: 2;
// }
// .toc-panel-component, .le-resource {
// top: 92px;
// }
.lc-writer {
top: 52px;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment