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"

89 lines (71 loc) 3.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _react = require("react"); var React = _interopRequireWildcard(_react); var _styledComponents = require("styled-components"); var _styledComponents2 = _interopRequireDefault(_styledComponents); var _defaultTokens = require("../defaultTokens"); var _defaultTokens2 = _interopRequireDefault(_defaultTokens); var _consts = require("./consts"); var _consts2 = _interopRequireDefault(_consts); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } var StyledFormFeedback = (0, _styledComponents2.default)(function (_ref) { var theme = _ref.theme, type = _ref.type, props = _objectWithoutProperties(_ref, ["theme", "type"]); return React.createElement("div", props); }).withConfig({ displayName: "FormFeedback__StyledFormFeedback" })(["color:", ";font-family:", ";font-size:", ";font-weight:", ";line-height:", ";width:100%;margin-top:2px;position:absolute;bottom:-", "px;& a{color:", ";font-weight:", ";text-decoration:underline;cursor:pointer;}strong,b{font-weight:", ";color:", ";}"], function (_ref2) { var theme = _ref2.theme, type = _ref2.type; return type === _consts2.default.ERROR ? theme.orbit.colorTextError : theme.orbit.colorTextSecondary; }, function (_ref3) { var theme = _ref3.theme; return theme.orbit.fontFamily; }, function (_ref4) { var theme = _ref4.theme; return theme.orbit.fontSizeFormFeedback; }, function (_ref5) { var theme = _ref5.theme, type = _ref5.type; return type === _consts2.default.ERROR ? theme.orbit.fontWeightMedium : theme.orbit.fontWeightNormal; }, function (_ref6) { var theme = _ref6.theme; return theme.orbit.lineHeightText; }, function (_ref7) { var theme = _ref7.theme; return Math.floor(theme.orbit.lineHeightText * parseInt(theme.orbit.fontSizeFormFeedback, 10)) + 2; }, function (_ref8) { var theme = _ref8.theme, type = _ref8.type; return type === _consts2.default.ERROR ? theme.orbit.colorTextError : theme.orbit.colorTextAttention; }, function (_ref9) { var theme = _ref9.theme; return theme.orbit.fontWeightMedium; }, function (_ref10) { var theme = _ref10.theme; return theme.fontWeightMedium; }, function (_ref11) { var theme = _ref11.theme; return theme.paletteInkNormal; }); StyledFormFeedback.defaultProps = { theme: _defaultTokens2.default }; var FormFeedback = function FormFeedback(props) { var children = props.children, _props$type = props.type, type = _props$type === undefined ? _consts2.default.HELP : _props$type, dataTest = props.dataTest; return React.createElement( StyledFormFeedback, { type: type, "data-test": dataTest }, children ); }; exports.default = FormFeedback;