@kiwicom/orbit-components
Version:
Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com’s products.
61 lines (57 loc) • 2.1 kB
JavaScript
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
const _excluded = ["theme", "type"];
import * as React from "react";
import styled from "styled-components";
import defaultTheme from "../../defaultTheme";
import TYPE_OPTIONS from "./consts";
export const StyledFormFeedback = styled(_ref => {
let {
theme,
type
} = _ref,
props = _objectWithoutProperties(_ref, _excluded);
return /*#__PURE__*/React.createElement("div", props);
}).withConfig({
displayName: "FormFeedback__StyledFormFeedback",
componentId: "sc-3o9cve-0"
})(["color:", ";font-family:", ";font-size:", ";font-weight:", ";line-height:", ";width:100%;margin-top:2px;position:absolute;top:100%;max-height:", ";overflow:hidden;white-space:nowrap;text-overflow:ellipsis;& a{color:", ";font-weight:", ";text-decoration:underline;cursor:pointer;}strong,b{font-weight:", ";color:", ";}"], ({
theme,
type
}) => type === TYPE_OPTIONS.ERROR ? theme.orbit.paletteRedNormal : theme.orbit.paletteBlueNormal, ({
theme
}) => theme.orbit.fontFamily, ({
theme
}) => theme.orbit.fontSizeTextSmall, ({
theme,
type
}) => type === TYPE_OPTIONS.ERROR ? theme.orbit.fontWeightMedium : theme.orbit.fontWeightNormal, ({
theme
}) => theme.orbit.lineHeightSmall, ({
theme
}) => theme.orbit.lineHeightSmall, ({
theme,
type
}) => type === TYPE_OPTIONS.ERROR ? theme.orbit.textCriticalForeground : theme.orbit.textPrimaryForeground, ({
theme
}) => theme.orbit.fontWeightMedium, ({
theme
}) => theme.fontWeightMedium, ({
theme
}) => theme.paletteInkNormal); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198
StyledFormFeedback.defaultProps = {
theme: defaultTheme
};
const FormFeedback = ({
error,
help,
dataTest
}) => {
const isHelp = help && !error;
if (!error && !help) return null;
return /*#__PURE__*/React.createElement(StyledFormFeedback, {
type: isHelp ? "help" : error && "error",
"data-test": dataTest,
"aria-live": "polite"
}, isHelp ? help : error && error);
};
export default FormFeedback;