Browse Source

refactor: rename FormFieldMessage to Message

renovate/lint-staged-8.x
Tom Kirkpatrick 6 years ago
parent
commit
16a7567f45
No known key found for this signature in database GPG Key ID: 72203A8EC5967EA8
  1. 10
      app/components/Pay/Pay.js
  2. 7
      app/components/UI/Button.js
  3. 10
      app/components/UI/Input.js
  4. 6
      app/components/UI/LightningInvoiceInput.js
  5. 16
      app/components/UI/Message.js
  6. 10
      app/components/UI/TextArea.js
  7. 2
      app/components/UI/index.js

10
app/components/Pay/Pay.js

@ -11,7 +11,7 @@ import {
Dropdown, Dropdown,
FiatAmountInput, FiatAmountInput,
Form, Form,
FormFieldMessage, Message,
Label, Label,
LightningInvoiceInput, LightningInvoiceInput,
Panel, Panel,
@ -699,16 +699,16 @@ class Pay extends React.Component {
{currentStep === 'summary' && {currentStep === 'summary' &&
!isQueryingRoutes && !isQueryingRoutes &&
!hasRoute && ( !hasRoute && (
<FormFieldMessage variant="error" justifyContent="center" mb={2}> <Message variant="error" justifyContent="center" mb={2}>
<FormattedMessage {...messages.error_no_route} /> <FormattedMessage {...messages.error_no_route} />
</FormFieldMessage> </Message>
)} )}
{currentStep === 'summary' && {currentStep === 'summary' &&
!hasEnoughFunds && ( !hasEnoughFunds && (
<FormFieldMessage variant="error" justifyContent="center" mb={2}> <Message variant="error" justifyContent="center" mb={2}>
<FormattedMessage {...messages.error_not_enough_funds} /> <FormattedMessage {...messages.error_not_enough_funds} />
</FormFieldMessage> </Message>
)} )}
<PayButtons <PayButtons

7
app/components/UI/Button.js

@ -39,7 +39,7 @@ class Button extends React.PureComponent {
} }
render() { render() {
let { children, processing, size, ...rest } = this.props let { children, processing, size, variant, ...rest } = this.props
const sizes = { const sizes = {
small: { small: {
x: 3, x: 3,
@ -52,9 +52,12 @@ class Button extends React.PureComponent {
} }
size = sizes[size] || sizes['medium'] size = sizes[size] || sizes['medium']
if (variant === 'secondary') {
size.x = 0
}
return ( return (
<Wrapper px={size['x']} py={size['y']} {...rest}> <Wrapper px={size['x']} py={size['y']} variant={variant} {...rest}>
{processing ? ( {processing ? (
<Flex alignItems="center"> <Flex alignItems="center">
{processing && <Spinner />} {processing && <Spinner />}

10
app/components/UI/Input.js

@ -4,7 +4,7 @@ import { withTheme } from 'styled-components'
import system from '@rebass/components' import system from '@rebass/components'
import { styles } from 'styled-system' import { styles } from 'styled-system'
import { Flex } from 'rebass' import { Flex } from 'rebass'
import { FormFieldMessage } from 'components/UI' import { Message } from 'components/UI'
// Create an html input element that accepts all style props from styled-system. // Create an html input element that accepts all style props from styled-system.
const SystemInput = system( const SystemInput = system(
@ -120,13 +120,9 @@ class Input extends React.Component {
error={fieldState.error} error={fieldState.error}
/> />
{fieldState.error && ( {fieldState.error && (
<FormFieldMessage <Message variant={hasFocus ? 'warning' : 'error'} justifyContent={justifyContent} mt={2}>
variant={hasFocus ? 'warning' : 'error'}
justifyContent={justifyContent}
mt={2}
>
{fieldState.error} {fieldState.error}
</FormFieldMessage> </Message>
)} )}
</Flex> </Flex>
) )

6
app/components/UI/LightningInvoiceInput.js

@ -4,7 +4,7 @@ import { FormattedMessage, injectIntl } from 'react-intl'
import { asField } from 'informed' import { asField } from 'informed'
import { isOnchain, isLn } from 'lib/utils/crypto' import { isOnchain, isLn } from 'lib/utils/crypto'
import TextArea from 'components/UI/TextArea' import TextArea from 'components/UI/TextArea'
import FormFieldMessage from 'components/UI/FormFieldMessage' import Message from 'components/UI/Message'
import messages from './messages' import messages from './messages'
/** /**
@ -76,14 +76,14 @@ const InformedTextArea = asField(({ fieldState, fieldApi, ...props }) => {
<TextArea {...rest} /> <TextArea {...rest} />
{value && {value &&
!fieldState.error && ( !fieldState.error && (
<FormFieldMessage variant="success" mt={2}> <Message variant="success" mt={2}>
<FormattedMessage <FormattedMessage
{...messages.valid_request} {...messages.valid_request}
values={{ values={{
chain: chainName chain: chainName
}} }}
/> />
</FormFieldMessage> </Message>
)} )}
</React.Fragment> </React.Fragment>
) )

16
app/components/UI/FormFieldMessage.js → app/components/UI/Message.js

@ -9,16 +9,16 @@ import styled from 'styled-components'
import { variant } from 'styled-system' import { variant } from 'styled-system'
const messageStyle = variant({ key: 'messages' }) const messageStyle = variant({ key: 'messages' })
const Message = styled(Flex)(messageStyle) const StyledMessage = styled(Flex)(messageStyle)
/** /**
* @render react * @render react
* @name FormFieldMessage * @name Message
* @example * @example
* <FormFieldMessage message="Error message" /> * <Message message="Error message" />
*/ */
class FormFieldMessage extends React.Component { class Message extends React.Component {
static displayName = 'FormFieldMessage' static displayName = 'Message'
static propTypes = { static propTypes = {
variant: PropTypes.string, variant: PropTypes.string,
@ -28,7 +28,7 @@ class FormFieldMessage extends React.Component {
render() { render() {
const { children, variant, ...rest } = this.props const { children, variant, ...rest } = this.props
return ( return (
<Message {...rest} variant={variant} alignItems="center"> <StyledMessage {...rest} variant={variant} alignItems="center">
<Box mr={1}> <Box mr={1}>
{variant === 'success' && <Success />} {variant === 'success' && <Success />}
{variant === 'warning' && <Warning />} {variant === 'warning' && <Warning />}
@ -37,9 +37,9 @@ class FormFieldMessage extends React.Component {
<Text fontSize="s" fontWeight="normal"> <Text fontSize="s" fontWeight="normal">
{children} {children}
</Text> </Text>
</Message> </StyledMessage>
) )
} }
} }
export default FormFieldMessage export default Message

10
app/components/UI/TextArea.js

@ -4,7 +4,7 @@ import system from '@rebass/components'
import { styles } from 'styled-system' import { styles } from 'styled-system'
import { withTheme } from 'styled-components' import { withTheme } from 'styled-components'
import { Flex } from 'rebass' import { Flex } from 'rebass'
import { FormFieldMessage } from 'components/UI' import { Message } from 'components/UI'
// Create an html textarea element that accepts all style props from styled-system. // Create an html textarea element that accepts all style props from styled-system.
const SystemTextArea = system( const SystemTextArea = system(
@ -122,13 +122,9 @@ class TextArea extends React.PureComponent {
error={fieldState.error} error={fieldState.error}
/> />
{fieldState.error && ( {fieldState.error && (
<FormFieldMessage <Message variant={hasFocus ? 'warning' : 'error'} justifyContent={justifyContent} mt={2}>
variant={hasFocus ? 'warning' : 'error'}
justifyContent={justifyContent}
mt={2}
>
{fieldState.error} {fieldState.error}
</FormFieldMessage> </Message>
)} )}
</Flex> </Flex>
) )

2
app/components/UI/index.js

@ -10,7 +10,7 @@ export DataRow from './DataRow'
export Dropdown from './Dropdown' export Dropdown from './Dropdown'
export FiatAmountInput from './FiatAmountInput' export FiatAmountInput from './FiatAmountInput'
export Form from './Form' export Form from './Form'
export FormFieldMessage from './FormFieldMessage' export Message from './Message'
export GlobalStyle from './GlobalStyle' export GlobalStyle from './GlobalStyle'
export Header from './Header' export Header from './Header'
export Heading from './Heading' export Heading from './Heading'

Loading…
Cancel
Save