diff --git a/src/lib/components/FormModel/children/Viewer/UI/BoolLine/bool-line.component.js b/src/lib/components/FormModel/children/Viewer/UI/BoolLine/bool-line.component.js
index 1675e48a..a5e3e388 100644
--- a/src/lib/components/FormModel/children/Viewer/UI/BoolLine/bool-line.component.js
+++ b/src/lib/components/FormModel/children/Viewer/UI/BoolLine/bool-line.component.js
@@ -2,28 +2,30 @@ import React from 'react';
import { FormModelConfig } from '@context';
import { Label } from './bool-line.style';
+import { FormModelUI } from '@constants';
+
type Props = {
value: Object
};
const BoolLine = ({ value, ...rest }: Props) => {
- return value ? (
+ return (
{({ theme }) => (
-
- ) : null;
+ );
};
export default BoolLine;
diff --git a/src/lib/components/FormModel/children/Viewer/UI/ColorLine/color-line.component.js b/src/lib/components/FormModel/children/Viewer/UI/ColorLine/color-line.component.js
new file mode 100644
index 00000000..8249825b
--- /dev/null
+++ b/src/lib/components/FormModel/children/Viewer/UI/ColorLine/color-line.component.js
@@ -0,0 +1,24 @@
+import React from 'react';
+
+import { Wrapper, Label, Value, ColorSwatch } from './color-line.style';
+
+import { FormModelConfig } from '@context';
+import { FormModelUI } from '@constants';
+
+const ColorLine = ({ value, ...rest }: { value: String }) => {
+ return (
+
+ {({ theme }) => (
+
+ {rest[FormModelUI.UI_LABEL]}
+
+ {value}
+
+
+
+ )}
+
+ );
+};
+
+export default ColorLine;
diff --git a/src/lib/components/FormModel/children/Viewer/UI/ColorLine/color-line.style.js b/src/lib/components/FormModel/children/Viewer/UI/ColorLine/color-line.style.js
new file mode 100644
index 00000000..fc5c212f
--- /dev/null
+++ b/src/lib/components/FormModel/children/Viewer/UI/ColorLine/color-line.style.js
@@ -0,0 +1,28 @@
+import styled from 'styled-components';
+
+export const Wrapper = styled.div`
+ //display: flex;
+ padding: 8px 0;
+ flex-direction: column;
+`;
+
+export const Label = styled.span`
+ font-weight: bold;
+ font-size: 16px;
+ letter-spacing: 0.4px;
+`;
+
+export const Value = styled.span`
+ display: inline-flex;
+`;
+
+export const ColorSwatch = styled.div`
+ width: 36px;
+ height: 14px;
+ padding: 5px;
+ background: ${props => props.color};
+ border-radius: 1px;
+ box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
+ display: inline-block;
+ cursor: pointer;
+`;
diff --git a/src/lib/components/FormModel/children/Viewer/UI/ColorLine/index.js b/src/lib/components/FormModel/children/Viewer/UI/ColorLine/index.js
new file mode 100644
index 00000000..65a38556
--- /dev/null
+++ b/src/lib/components/FormModel/children/Viewer/UI/ColorLine/index.js
@@ -0,0 +1 @@
+export { default } from './color-line.component';
diff --git a/src/lib/components/FormModel/children/Viewer/UI/DateLine/date-line.component.js b/src/lib/components/FormModel/children/Viewer/UI/DateLine/date-line.component.js
index 40651da3..f54d9390 100644
--- a/src/lib/components/FormModel/children/Viewer/UI/DateLine/date-line.component.js
+++ b/src/lib/components/FormModel/children/Viewer/UI/DateLine/date-line.component.js
@@ -1,18 +1,35 @@
import React from 'react';
+import { format } from 'date-fns';
+
import { FormModelConfig } from '@context';
+import { UITypes, FormModelUI } from '@constants';
+
import { Wrapper, Label, Value } from './date-line.style';
const DateLine = ({ value, ...rest }: { value: String }) => {
- return value ? (
+ const type = rest[FormModelUI.RDF_TYPE];
+
+ let renderValue;
+ if (value) {
+ if (type === UITypes.DateTimeField) {
+ renderValue = format(new Date(value), 'Pp');
+ } else {
+ renderValue = value;
+ }
+ } else {
+ renderValue = '';
+ }
+
+ return (
{({ theme }) => (
- {rest['ui:label']}
- {new Date(value)}
+ {rest[FormModelUI.UI_LABEL]}
+ {renderValue}
)}
- ) : null;
+ );
};
export default DateLine;
diff --git a/src/lib/components/FormModel/children/Viewer/UI/DateLine/date-line.style.js b/src/lib/components/FormModel/children/Viewer/UI/DateLine/date-line.style.js
index b1560c02..911e87b6 100644
--- a/src/lib/components/FormModel/children/Viewer/UI/DateLine/date-line.style.js
+++ b/src/lib/components/FormModel/children/Viewer/UI/DateLine/date-line.style.js
@@ -1,7 +1,7 @@
import styled from 'styled-components';
export const Wrapper = styled.div`
- display: flex;
+ //display: flex;
padding: 8px 0;
flex-direction: column;
`;
diff --git a/src/lib/components/FormModel/children/Viewer/UI/MultiLine/multi-line.component.js b/src/lib/components/FormModel/children/Viewer/UI/MultiLine/multi-line.component.js
index 338667ea..76728eba 100644
--- a/src/lib/components/FormModel/children/Viewer/UI/MultiLine/multi-line.component.js
+++ b/src/lib/components/FormModel/children/Viewer/UI/MultiLine/multi-line.component.js
@@ -1,18 +1,20 @@
import React from 'react';
-import { FormModelConfig } from '@context';
import { Wrapper, Label, Value } from './multi-line.style';
+import { FormModelConfig } from '@context';
+import { FormModelUI } from '@constants';
+
const MultiLine = ({ value, ...rest }: { value: String }) => {
- return value ? (
+ return (
{({ theme }) => (
- {rest['ui:label']}
- {value}
+ {rest[FormModelUI.UI_LABEL]}
+ {value || ''}
)}
- ) : null;
+ );
};
export default MultiLine;
diff --git a/src/lib/components/FormModel/children/Viewer/UI/SingleLine/single-line.component.js b/src/lib/components/FormModel/children/Viewer/UI/SingleLine/single-line.component.js
index 7ebda29d..974156b7 100644
--- a/src/lib/components/FormModel/children/Viewer/UI/SingleLine/single-line.component.js
+++ b/src/lib/components/FormModel/children/Viewer/UI/SingleLine/single-line.component.js
@@ -2,17 +2,19 @@ import React from 'react';
import { FormModelConfig } from '@context';
import { Wrapper, Label, Value } from './single-line.style';
+import { FormModelUI } from '@constants';
+
const SingleLine = ({ value, ...rest }: { value: String }) => {
- return value ? (
+ return (
{({ theme }) => (
- {rest['ui:label']}
- {value}
+ {rest[FormModelUI.UI_LABEL]}
+ {value || ''}
)}
- ) : null;
+ );
};
export default SingleLine;
diff --git a/src/lib/components/FormModel/children/Viewer/UI/ui-mapping.js b/src/lib/components/FormModel/children/Viewer/UI/ui-mapping.js
index 46065ee8..0d5cf282 100644
--- a/src/lib/components/FormModel/children/Viewer/UI/ui-mapping.js
+++ b/src/lib/components/FormModel/children/Viewer/UI/ui-mapping.js
@@ -5,6 +5,7 @@ import SingleLine from './SingleLine';
import MultiLine from './MultiLine';
import DateLine from './DateLine';
import BoolLine from './BoolLine';
+import ColorLine from './ColorLine';
const UIMapping = type => {
let component;
@@ -37,16 +38,16 @@ const UIMapping = type => {
component = BoolLine;
break;
case UITypes.ColorField:
- component = SingleLine;
+ component = ColorLine;
break;
case UITypes.DateField:
- component = props => ;
+ component = props => ;
break;
case UITypes.DateTimeField:
- component = props => ;
+ component = props => ;
break;
case UITypes.TimeField:
- component = props => ;
+ component = props => ;
break;
case UITypes.Classifier:
component = SingleLine;
diff --git a/src/lib/components/FormModel/children/Viewer/viewer.component.js b/src/lib/components/FormModel/children/Viewer/viewer.component.js
index 6c119112..c9e30ecf 100644
--- a/src/lib/components/FormModel/children/Viewer/viewer.component.js
+++ b/src/lib/components/FormModel/children/Viewer/viewer.component.js
@@ -3,6 +3,8 @@ import ControlGroup from '../control-group.component';
import UIMapping from './UI/ui-mapping';
import { Group, Label } from './viewer.style';
+import { FormModelConfig } from '@context';
+
const UI_PARTS = 'ui:parts';
type Props = {
@@ -17,6 +19,7 @@ const ParentLabel = ({ formModel }: { formModel: Object }) =>
const Viewer = ({ formModel, parent }: Props) => {
const [formFields, setFormFields] = useState([]);
+
const parts = formModel[UI_PARTS];
const getArrayFields = () => {
@@ -30,41 +33,45 @@ const Viewer = ({ formModel, parent }: Props) => {
}, [formModel]);
return (
-
- {formModel['dc:title'] && {formModel['dc:title']}
}
-
- {formFields.length > 0 &&
- formFields.map(item => {
- const field = parts[item];
- const fieldParts = field && field[UI_PARTS];
- const component = field && UIMapping(field['rdf:type']);
- const id = (field && field['ui:name']) || item;
- /**
- * Return null when field doesn't exists
- * this avoid to crash app using recursive component
- */
- if (!field) return null;
- /* eslint no-useless-computed-key: "off" */
- const { ['ui:parts']: deleted, ...updatedField } = field;
+
+ {({ theme }) => (
+
+ {formModel['dc:title'] && {formModel['dc:title']}
}
+
+ {formFields.length > 0 &&
+ formFields.map(item => {
+ const field = parts[item];
+ const fieldParts = field && field[UI_PARTS];
+ const component = field && UIMapping(field['rdf:type']);
+ const id = (field && field['ui:name']) || item;
+ /**
+ * Return null when field doesn't exists
+ * this avoid to crash app using recursive component
+ */
+ if (!field) return null;
+ /* eslint no-useless-computed-key: "off" */
+ const { ['ui:parts']: deleted, ...updatedField } = field;
- return fieldParts ? (
-
- ) : (
-
- );
- })}
-
+ return fieldParts ? (
+
+ ) : (
+
+ );
+ })}
+
+ )}
+
);
};
diff --git a/src/lib/components/FormModel/children/Viewer/viewer.style.js b/src/lib/components/FormModel/children/Viewer/viewer.style.js
index da4aa4a4..f57dfc2a 100644
--- a/src/lib/components/FormModel/children/Viewer/viewer.style.js
+++ b/src/lib/components/FormModel/children/Viewer/viewer.style.js
@@ -6,9 +6,11 @@ export const Group = styled.div`
!parent
? `
- display: grid;
- grid-template-columns: 1fr 1fr;
- grid-template-rows: auto;
+ // display: grid;
+ // grid-template-columns: 1fr 1fr;
+ // grid-template-rows: auto;
+ display: flex;
+ flex-direction: column;
`
: `
display: flex;