UNPKG

@kiwicom/orbit-components

Version:

<div align="center"> <a href="https://orbit.kiwi" target="_blank"> <img alt="orbit-components" src="https://orbit.kiwi/wp-content/uploads/2018/08/orbit-components.png" srcset="https://orbit.kiwi/wp-content/uploads/2018/08/orbit-components@2x.png 2x"

52 lines (43 loc) 1.64 kB
// @flow import * as React from "react"; import styled from "styled-components"; import defaultTokens from "../defaultTokens"; import TYPE_OPTIONS from "./consts"; import type { Props } from "./index"; const StyledFormFeedback = styled(({ theme, type, ...props }) => <div {...props} />)` color: ${({ theme, type }) => type === TYPE_OPTIONS.ERROR ? theme.orbit.colorTextError : theme.orbit.colorTextSecondary}; font-family: ${({ theme }) => theme.orbit.fontFamily}; font-size: ${({ theme }) => theme.orbit.fontSizeFormFeedback}; font-weight: ${({ theme, type }) => type === TYPE_OPTIONS.ERROR ? theme.orbit.fontWeightMedium : theme.orbit.fontWeightNormal}; line-height: ${({ theme }) => theme.orbit.lineHeightText}; width: 100%; margin-top: 2px; position: absolute; bottom: -${({ theme }) => Math.floor(theme.orbit.lineHeightText * parseInt(theme.orbit.fontSizeFormFeedback, 10)) + 2}px; & a { color: ${({ theme, type }) => type === TYPE_OPTIONS.ERROR ? theme.orbit.colorTextError : theme.orbit.colorTextAttention}; font-weight: ${({ theme }) => theme.orbit.fontWeightMedium}; text-decoration: underline; cursor: pointer; } strong, b { font-weight: ${({ theme }) => theme.fontWeightMedium}; color: ${({ theme }) => theme.paletteInkNormal}; } `; StyledFormFeedback.defaultProps = { theme: defaultTokens, }; const FormFeedback = (props: Props) => { const { children, type = TYPE_OPTIONS.HELP, dataTest } = props; return ( <StyledFormFeedback type={type} data-test={dataTest}> {children} </StyledFormFeedback> ); }; export default FormFeedback;