UNPKG

@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.

67 lines (65 loc) 2.54 kB
import * as React from "react"; import styled from "styled-components"; import KEY_CODE_MAP from "../common/keyMaps"; import defaultTheme from "../defaultTheme"; var StyledNavigation = styled.nav.withConfig({ displayName: "SkipLink__StyledNavigation", componentId: "sc-1hg3afm-0" })([""]); var StyledLink = styled.a.withConfig({ displayName: "SkipLink__StyledLink", componentId: "sc-1hg3afm-1" })(["position:absolute;width:0;height:0;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0;font-family:", ";text-decoration:", ";font-size:", ";border-radius:", ";color:", ";&:focus{top:1rem;left:1rem;clip:auto;height:auto;width:auto;margin:0;overflow:visible;padding:", ";background-color:", ";z-index:", ";}"], function (_ref) { var theme = _ref.theme; return theme.orbit.fontFamily; }, function (_ref2) { var theme = _ref2.theme; return theme.orbit.textDecorationTextLinkPrimary; }, function (_ref3) { var theme = _ref3.theme; return theme.orbit.fontSizeTextLarge; }, function (_ref4) { var theme = _ref4.theme; return theme.orbit.borderRadiusNormal; }, function (_ref5) { var theme = _ref5.theme; return theme.orbit.paletteInkNormal; }, function (_ref6) { var theme = _ref6.theme; return theme.orbit.spaceMedium; }, function (_ref7) { var theme = _ref7.theme; return theme.orbit.paletteWhite; }, function (_ref8) { var theme = _ref8.theme; return theme.orbit.zIndexOnTheTop; }); StyledLink.defaultProps = { theme: defaultTheme }; var StyledLabel = styled.p.withConfig({ displayName: "SkipLink__StyledLabel", componentId: "sc-1hg3afm-2" })(["background-color:red;visibility:none;position:absolute;width:0;height:0;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0;"]); var SkipLink = function SkipLink(_ref9) { var links = _ref9.links, buttonLabel = _ref9.buttonLabel; return /*#__PURE__*/React.createElement(StyledNavigation, null, buttonLabel && /*#__PURE__*/React.createElement(StyledLabel, null, buttonLabel), links && links.map(function (_ref10, index) { var href = _ref10.href, name = _ref10.name, onClick = _ref10.onClick; return /*#__PURE__*/React.createElement(StyledLink, { key: encodeURIComponent(name + index), href: href, tabIndex: href ? "" : "0", role: href ? "" : "Button", onClick: onClick, onKeyDown: function onKeyDown(ev) { if (ev.keyCode === KEY_CODE_MAP.ENTER && onClick) { onClick(); } } }, name); })); }; export default SkipLink;