@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.
81 lines (72 loc) • 3.24 kB
JavaScript
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import * as React from "react";
import styled, { css } from "styled-components";
import { left, rtlSpacing } from "../utils/rtl";
import mq from "../utils/mediaQuery";
import { StyledTextLink } from "../TextLink";
import defaultTheme from "../defaultTheme";
import { SPACINGS } from "../utils/layout/consts";
import getSpacing from "../Stack/helpers/getSpacing";
import getDirectionSpacingTemplate from "../Stack/helpers/getDirectionSpacingTemplate";
var StyledLinkList = styled.ul.withConfig({
displayName: "LinkList__StyledLinkList",
componentId: "wz7xd9-0"
})(["display:flex;flex-direction:", ";width:100%;margin:0;padding:0;padding-", ":", ";list-style:none;font-size:", ";"], function (_ref) {
var direction = _ref.direction;
return direction;
}, left, function (_ref2) {
var indent = _ref2.indent,
theme = _ref2.theme;
return indent && theme.orbit.spaceXXSmall;
}, function (_ref3) {
var theme = _ref3.theme;
return theme.orbit.fontSizeTextNormal;
}); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198
StyledLinkList.defaultProps = {
theme: defaultTheme
};
var resolveSpacings = function resolveSpacings(_ref4) {
var spacing = _ref4.spacing,
direction = _ref4.direction,
props = _objectWithoutProperties(_ref4, ["spacing", "direction"]);
var margin = spacing && direction && String(getDirectionSpacingTemplate(direction)).replace("__spacing__", getSpacing(props)[spacing]);
return css(["margin:", ";&:last-child{margin:0;}"], margin && rtlSpacing(margin));
};
var StyledNavigationLinkListChild = styled(function (_ref5) {
var theme = _ref5.theme,
direction = _ref5.direction,
props = _objectWithoutProperties(_ref5, ["theme", "direction"]);
return /*#__PURE__*/React.createElement("li", props);
}).withConfig({
displayName: "LinkList__StyledNavigationLinkListChild",
componentId: "wz7xd9-1"
})(["", "{text-decoration:none;}", ";", ";"], StyledTextLink, resolveSpacings, function (_ref6) {
var direction = _ref6.direction;
return direction === "column" && css(["width:100%;", "{width:100%;", ";}"], StyledTextLink, mq.tablet(css(["width:auto;"])));
}); // $FlowFixMe: https://github.com/flow-typed/flow-typed/issues/3653#issuecomment-568539198
StyledNavigationLinkListChild.defaultProps = {
theme: defaultTheme
};
var LinkList = function LinkList(_ref7) {
var _ref7$direction = _ref7.direction,
direction = _ref7$direction === void 0 ? "column" : _ref7$direction,
indent = _ref7.indent,
_ref7$spacing = _ref7.spacing,
spacing = _ref7$spacing === void 0 ? SPACINGS.MEDIUM : _ref7$spacing,
children = _ref7.children,
dataTest = _ref7.dataTest;
return /*#__PURE__*/React.createElement(StyledLinkList, {
indent: indent,
direction: direction,
"data-test": dataTest
}, React.Children.map(children, function (item) {
if ( /*#__PURE__*/React.isValidElement(item)) {
return /*#__PURE__*/React.createElement(StyledNavigationLinkListChild, {
direction: direction,
spacing: spacing
}, item);
}
return null;
}));
};
export default LinkList;