From 3f1a94545b50fdde6cca95e0e1953befcb84439f Mon Sep 17 00:00:00 2001 From: cha0s Date: Thu, 18 Jun 2020 03:55:46 -0500 Subject: [PATCH] refactor: rendering --- src/client/components/properties/actions.jsx | 53 +++++++++++++++++-- .../components/properties/actions.raw.scss | 25 +++++++++ .../components/properties/condition.raw.scss | 3 -- 3 files changed, 75 insertions(+), 6 deletions(-) diff --git a/src/client/components/properties/actions.jsx b/src/client/components/properties/actions.jsx index 10434b7..3a91a13 100644 --- a/src/client/components/properties/actions.jsx +++ b/src/client/components/properties/actions.jsx @@ -1,4 +1,5 @@ import {compose} from '@avocado/core'; +import classnames from 'classnames'; import contempo from 'contempo'; import PropTypes from 'prop-types'; import React from 'react'; @@ -12,10 +13,36 @@ const reduceStep = (r, step) => { case 'invoke': return ( - {r} + (
- {step.args.map(renderValue).map((element) =>
{element}
)} + { + step.args.length > 0 && ( + step.args.slice(1).map(renderValue).reduce( + (r2, element, i) => ( + <> + {r2} +
+ {element} +
+ + ), +
+ {renderValue(step.args[0])} +
, + ) + ) + }
)
@@ -41,7 +68,27 @@ const renderValue = (value) => { ); } case 'literal': - return ; + if ( + null === value.value + || 'string' === typeof value.value + || 'number' === typeof value.value + ) { + return ; + } + return ( + <> +
+ {'{'} +
+              
+                {'  '}
+                {JSON.stringify(value.value, null, 2).slice(1).slice(0, -1).trim('\n')}
+              
+            
+ {'}'} +
+ + ); default: return null; } diff --git a/src/client/components/properties/actions.raw.scss b/src/client/components/properties/actions.raw.scss index 6698c48..904f60b 100644 --- a/src/client/components/properties/actions.raw.scss +++ b/src/client/components/properties/actions.raw.scss @@ -1,3 +1,28 @@ .args { margin-left: 2em; } + +.arg { + margin-top: 0.125em; + > :first-child::after { + color: #999999; + content: ', '; + } +} + +.bracket, .paren { + color: #999999; +} + +.object { + background-color: #333333; + border: 1px solid black; + padding: 0.25em; +} + +li { + margin-bottom: 0.5em; + &:last-child { + margin-bottom: 0; + } +} \ No newline at end of file diff --git a/src/client/components/properties/condition.raw.scss b/src/client/components/properties/condition.raw.scss index aa7ee6e..32f1d24 100644 --- a/src/client/components/properties/condition.raw.scss +++ b/src/client/components/properties/condition.raw.scss @@ -1,10 +1,7 @@ .condition { - // flex-grow: 1; display: flex; justify-content: flex-end; align-items: center; - border: 1px solid rgba(0, 0, 0, 0.2); - padding: 0.25em; } .operator {