From 6698a8eacbb27a98b34faedb2d8e12e66aa07115 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Moreira?= Date: Wed, 30 May 2018 13:44:22 +0100 Subject: [PATCH] feat(ui-toolkit): key-value responsive --- .../resource-widgets/src/key-value/index.js | 88 +++++++++++++------ 1 file changed, 61 insertions(+), 27 deletions(-) diff --git a/packages/resource-widgets/src/key-value/index.js b/packages/resource-widgets/src/key-value/index.js index abc05f5b..6b33b8d8 100644 --- a/packages/resource-widgets/src/key-value/index.js +++ b/packages/resource-widgets/src/key-value/index.js @@ -2,7 +2,7 @@ import React, { Fragment } from 'react'; import { Margin, Padding } from 'styled-components-spacing'; import PropTypes from 'prop-types'; import styled from 'styled-components'; -import { Row, Col } from 'joyent-react-styled-flexboxgrid'; +import { Row, Col as BaseCol } from 'joyent-react-styled-flexboxgrid'; import { Field } from 'redux-form'; import remcalc from 'remcalc'; import titleCase from 'title-case'; @@ -70,6 +70,13 @@ const Bold = styled.span` font-weight: ${props => props.theme.font.weight.semibold}; `; +const Col = styled(BaseCol)` + ${is('mobile')` + display: flex; + flex-direction: column-reverse; + `}; +`; + const TextareaKeyValue = ({ id = null, type, @@ -138,10 +145,11 @@ const InputKeyValue = ({ submitting, typeLabel, onlyName, - onlyValue + onlyValue, + fluid = false }) => ( - - {onlyValue ? null : ( + + {!onlyValue ? ( {titleCase(type)} {typeLabel} - - + + @@ -162,26 +170,28 @@ const InputKeyValue = ({ - )} + ) : null} {onlyName ? null : ( - - {titleCase(type)} value - - - - - - - - - + + + {titleCase(type)} value + + + + + + + + + + )} @@ -216,6 +226,7 @@ export const KeyValue = ({ noActions = false }) => { const handleHeaderClick = method === 'edit' && onToggleExpanded; + const mobile = theme.screen === 'mobile'; return ( ) : null} {input === 'textarea' ? ( @@ -309,16 +321,38 @@ export const KeyValue = ({ {input !== 'textarea' && input !== 'input' ? input(submitting) : null} - {noActions ? null : ( - - - + + + + + Cancel + + + + + {!noRemove && ( + +