@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.
52 lines • 1.79 kB
JavaScript
import * as React from "react";
import styled from "styled-components";
import defaultTheme from "../../defaultTheme";
import TYPE_OPTIONS from "./consts";
export const StyledFormFeedback = styled(({
theme,
type,
...props
}) => /*#__PURE__*/React.createElement("div", props)).withConfig({
displayName: "FormFeedback__StyledFormFeedback",
componentId: "sc-pnr557-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.paletteInkDark);
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;