ywana-core8 0.0.193 → 0.0.197

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.193",
3
+ "version": "0.0.197",
4
4
  "description": "ywana-core8",
5
5
  "author": "Ernesto Roldan Garcia",
6
6
  "license": "MIT",
@@ -0,0 +1,8 @@
1
+ .content-viewer main>.property {
2
+ border-bottom: solid 1px var(--divider-color);
3
+ }
4
+
5
+ .entity-viewer>header {
6
+ padding: .5rem;
7
+ background-color: rgba(240,240,240,.5);
8
+ }
@@ -1,6 +1,6 @@
1
1
  import React from 'react'
2
2
  import { Property } from '../html'
3
- import { TYPES } from './ContentType'
3
+ import { Content, TYPES } from './ContentType'
4
4
 
5
5
  /**
6
6
  * Content Viewer
@@ -10,23 +10,24 @@ import { TYPES } from './ContentType'
10
10
  */
11
11
  export const ContentViewer = (props) => {
12
12
 
13
- const { content, field } = props
13
+ const { content } = props
14
14
 
15
15
  if (!content) return <div>No Content...</div>
16
16
 
17
17
  const sections = content.sections()
18
-
18
+ const value = content.value()
19
+ console.log(value)
19
20
  return (
20
21
  <div className="content-viewer">
21
22
  {sections.map(section => {
22
23
  const { title, fields } = section
23
24
  return (
24
- <section key={title}>
25
+ <section key={title} className="content-viewer">
25
26
  <header>
26
27
  {title}
27
28
  </header>
28
29
  <main>
29
- { fields.map( field => <FieldViewer key={field.id} field={field} value={content[field.id]} />)}
30
+ { fields.map( field => <FieldViewer key={field.id} field={field} value={value[field.id]} />)}
30
31
  </main>
31
32
  </section>
32
33
  )
@@ -35,17 +36,46 @@ export const ContentViewer = (props) => {
35
36
  )
36
37
  }
37
38
 
39
+ /**
40
+ * Field Viewer
41
+ *
42
+ * @param {} props
43
+ * @returns
44
+ */
38
45
  const FieldViewer = (props) => {
39
46
 
40
47
  const { field, value } = props
41
48
  const { id, type, item, label } = field
42
49
 
43
50
  console.log('FieldViewer', field, value)
44
-
51
+
45
52
  switch(type) {
46
53
  case TYPES.STRING:
47
54
  return <Property label={label} value={value} />
55
+ case TYPES.ENTITY:
56
+ return <EntityViewer field={field} value={value} />
48
57
  default:
49
58
  return <div>{label}</div>
50
59
  }
60
+ }
61
+
62
+ /**
63
+ * EntityViewer
64
+ */
65
+ const EntityViewer = (props) => {
66
+ const { field, value } = props
67
+ const { item, label } = field
68
+ const content = new Content(item, value)
69
+ const form = content.form()
70
+ const fields = Object.keys(form).map(key => form[key])
71
+ return (
72
+ <div className='entity-viewer'>
73
+ <header>
74
+ {label}
75
+ </header>
76
+ <main>
77
+ { fields.map( field => <FieldViewer field={field} value={value[field.id]} /> )}
78
+ </main>
79
+ </div>
80
+ )
51
81
  }