|
@@ -0,0 +1,119 @@
|
|
|
+import React from 'react'
|
|
|
+
|
|
|
+class MetaInformationForm extends React.Component {
|
|
|
+ constructor () {
|
|
|
+ super()
|
|
|
+ this.changeType = this.changeType.bind(this)
|
|
|
+ }
|
|
|
+
|
|
|
+ changeType (event) {
|
|
|
+ this.type = this.sali
|
|
|
+ }
|
|
|
+
|
|
|
+ render () {
|
|
|
+ const { data } = this.props
|
|
|
+ const metaElements = {
|
|
|
+ text: (
|
|
|
+ <fieldset>
|
|
|
+ <input type='text' placeholder='Key Name' />
|
|
|
+ <input type='text' placeholder='Value' />
|
|
|
+ </fieldset>
|
|
|
+ ),
|
|
|
+ image: (
|
|
|
+ <fieldset>
|
|
|
+ <input type='text' placeholder='Image URL' />
|
|
|
+ <button>Select from Gallery</button>
|
|
|
+ <input type='file' placeholder='Upload file' />
|
|
|
+ <input type='text' placeholder='Name' />
|
|
|
+ <input type='text' placeholder='Description' />
|
|
|
+ </fieldset>
|
|
|
+ ),
|
|
|
+ link: (
|
|
|
+ <fieldset>
|
|
|
+ <input type='text' placeholder='URL' />
|
|
|
+ <input type='text' placeholder='Description' />
|
|
|
+ </fieldset>
|
|
|
+ ),
|
|
|
+ file: (
|
|
|
+ <fieldset>
|
|
|
+ <input type='file' placeholder='URL' />
|
|
|
+ <input type='text' placeholder='Description' />
|
|
|
+ </fieldset>
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ return (
|
|
|
+ <form>
|
|
|
+ <select value={data.type} ref={(input) => { this.sali = input }} onChange={changeType}>
|
|
|
+ <option value='text'>Text</option>
|
|
|
+ <option value='image'>Image</option>
|
|
|
+ <option value='link'>Link</option>
|
|
|
+ <option value='file'>File</option>
|
|
|
+ </select>
|
|
|
+ {metaElements[type]}
|
|
|
+ </form>
|
|
|
+ )
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+class MetaInformationDisplay extends React.Component {
|
|
|
+ render () {
|
|
|
+ const { data } = this.props
|
|
|
+ const metaElements = {
|
|
|
+ text: (
|
|
|
+ <p>
|
|
|
+ <em>{data.key}</em> <span>{data.value}</span>
|
|
|
+ </p>
|
|
|
+ ),
|
|
|
+ image: (
|
|
|
+ <fieldset>
|
|
|
+ <input type='text' placeholder='Image URL' />
|
|
|
+ <button>Select from Gallery</button>
|
|
|
+ <input type='file' placeholder='Upload file' />
|
|
|
+ <input type='text' placeholder='Name' />
|
|
|
+ <input type='text' placeholder='Description' />
|
|
|
+ </fieldset>
|
|
|
+ ),
|
|
|
+ link: (
|
|
|
+ <fieldset>
|
|
|
+ <input type='text' placeholder='URL' />
|
|
|
+ <input type='text' placeholder='Description' />
|
|
|
+ </fieldset>
|
|
|
+ ),
|
|
|
+ file: (
|
|
|
+ <fieldset>
|
|
|
+ <input type='file' placeholder='URL' />
|
|
|
+ <input type='text' placeholder='Description' />
|
|
|
+ </fieldset>
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ return (
|
|
|
+ <form>
|
|
|
+ <select value={data.type} ref={(input) => { this.sali = input }} onChange={changeType}>
|
|
|
+ <option value='text'>Text</option>
|
|
|
+ <option value='image'>Image</option>
|
|
|
+ <option value='link'>Link</option>
|
|
|
+ <option value='file'>File</option>
|
|
|
+ </select>
|
|
|
+ {metaElements[data.type]}
|
|
|
+ </form>
|
|
|
+ )
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+class MetaInformation extends React.Component {
|
|
|
+ render () {
|
|
|
+ const { method, data } = this.props
|
|
|
+ if (method === 'form') {
|
|
|
+ return (
|
|
|
+ <MetaInformationForm method={method} data={data} />
|
|
|
+ )
|
|
|
+ }
|
|
|
+ return (
|
|
|
+ <MetaInformationDisplay method={method} data={data} />
|
|
|
+ )
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export default MetaInformation
|