Skip to content

Commit

Permalink
refactor: hasMessageSpacer prop for Inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton authored and korhaliv committed Oct 10, 2019
1 parent 16c90ae commit 7cb7076
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 9 additions & 1 deletion renderer/components/Form/Field.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import PropTypes from 'prop-types'
import { Flex } from 'rebass/styled-components'
import { Box, Flex } from 'rebass/styled-components'
import { Message, Text } from 'components/UI'
import Label from './Label'

Expand All @@ -10,6 +10,7 @@ const Field = ({
error,
field,
hasFocus,
hasMessageSpacer,
isDisabled,
isReadOnly,
isRequired,
Expand Down Expand Up @@ -40,6 +41,12 @@ const Field = ({
{error}
</Message>
)}

{hasMessageSpacer && !error && (
<Box fontSize="s" fontWeight="normal" height="16px" mt={1}>
&nbsp;
</Box>
)}
</Flex>
)

Expand All @@ -49,6 +56,7 @@ Field.propTypes = {
error: PropTypes.node,
field: PropTypes.string.isRequired,
hasFocus: PropTypes.bool,
hasMessageSpacer: PropTypes.bool,
isDisabled: PropTypes.bool,
isReadOnly: PropTypes.bool,
isRequired: PropTypes.bool,
Expand Down
3 changes: 3 additions & 0 deletions renderer/components/Form/Input.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const Input = props => {
fieldState,
forwardedRef,
hasMessage,
hasMessageSpacer,
initialValue,
isDisabled,
isReadOnly,
Expand Down Expand Up @@ -67,6 +68,7 @@ const Input = props => {
error={fieldError}
field={field}
hasFocus={hasFocus}
hasMessageSpacer={hasMessageSpacer}
isDisabled={isDisabled}
isReadOnly={isReadOnly}
isRequired={isRequired}
Expand Down Expand Up @@ -132,6 +134,7 @@ Input.propTypes = {
fieldState: PropTypes.object.isRequired,
forwardedRef: PropTypes.object,
hasMessage: PropTypes.bool,
hasMessageSpacer: PropTypes.bool,
highlightOnValid: PropTypes.bool,
initialValue: PropTypes.string,
isDisabled: PropTypes.bool,
Expand Down

0 comments on commit 7cb7076

Please sign in to comment.