ywana-core8 0.0.191 → 0.0.192

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ywana-core8",
3
- "version": "0.0.191",
3
+ "version": "0.0.192",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
File without changes
@@ -0,0 +1,51 @@
1
+ import React from 'react'
2
+ import { Property } from '../html'
3
+ import { TYPES } from './ContentType'
4
+
5
+ /**
6
+ * Content Viewer
7
+ *
8
+ * @param {*} props
9
+ * @returns
10
+ */
11
+ export const ContentViewer = (props) => {
12
+
13
+ const { content, field } = props
14
+
15
+ if (!content) return <div>No Content...</div>
16
+
17
+ const sections = content.sections()
18
+
19
+ return (
20
+ <div className="content-viewer">
21
+ {sections.map(section => {
22
+ const { title, fields } = section
23
+ return (
24
+ <section key={title}>
25
+ <header>
26
+ {title}
27
+ </header>
28
+ <main>
29
+ { fields.map( field => <FieldViewer key={field.id} field={field} value={content[field.id]} />)}
30
+ </main>
31
+ </section>
32
+ )
33
+ })}
34
+ </div>
35
+ )
36
+ }
37
+
38
+ const FieldViewer = (props) => {
39
+
40
+ const { field, value } = props
41
+ const { id, type, item, label } = field
42
+
43
+ console.log('FieldViewer', field, value)
44
+
45
+ switch(type) {
46
+ case TYPES.STRING:
47
+ return <Property label={label} value={value} />
48
+ default:
49
+ return <div>{label}</div>
50
+ }
51
+ }
@@ -145,7 +145,7 @@ const TableRowEditor = (props) => {
145
145
  <Icon icon="close" clickable action={onClose} />
146
146
  </Header>
147
147
  <main>
148
- { editable ? <ContentEditor content={content} onChange={onChange} filter={filter} /> : <ContentViewer content={content} />
148
+ { editable ? <ContentEditor content={content} onChange={onChange} filter={filter} /> : <ContentViewer content={content} /> }
149
149
  </main>
150
150
  </div>
151
151
  )