UNPKG

vcc-ui

Version:

VCC UI is a collection of React UI Components that can be used for developing front-end applications at Volvo Car Corporation.

106 lines (99 loc) 3.67 kB
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } import React from "react"; import PropTypes from "prop-types"; import { useFela } from "react-fela"; import { Block } from "../block"; import { Inline } from "../inline"; import { Arrow } from "../arrow"; import { getThemeStyle } from "../../get-theme-style"; var arrowTransform = { up: "translateY(-3px)", down: "translateY(3px)", right: "translateX(5px)", left: "translateX(-5px)" }; var link = function link(_ref) { var intent = _ref.intent, arrow = _ref.arrow, theme = _ref.theme; return { whiteSpace: "nowrap", fontWeight: 400, fontSize: 15, textDecoration: "none", transition: "all 0.3s ease-out", transitionProperty: "background, fill, stroke, color, border-color", ":focus": { textDecoration: "underline", outline: "none" }, extend: [{ condition: intent === "primary", style: { color: theme.colors.grey1, fill: theme.colors.primary, ":hover": { color: theme.colors.grey3 } } }, { condition: intent === "primary-light", style: { color: theme.colors.white, fill: theme.colors.white, ":hover": { color: theme.colors.grey5, fill: theme.colors.grey5 } } }, { condition: arrow, style: { ":hover": { "& svg": { transform: arrowTransform[arrow] } } } }] }; }; export function Link(_ref2) { var arrow = _ref2.arrow, _ref2$intent = _ref2.intent, intent = _ref2$intent === void 0 ? "primary" : _ref2$intent, children = _ref2.children, props = _objectWithoutProperties(_ref2, ["arrow", "intent", "children"]); var _useFela = useFela(), theme = _useFela.theme; var styleProps = { arrow: arrow, intent: intent, theme: theme }; return React.createElement(Block, _extends({}, props, { as: "a", extend: [link(styleProps), getThemeStyle("link", theme, styleProps)] }), arrow && arrow === "left" && React.createElement(Inline, { extend: { marginRight: 8 } }, React.createElement(Arrow, { direction: arrow })), children, arrow && arrow !== "left" && React.createElement(Inline, { extend: { marginLeft: 8 } }, React.createElement(Arrow, { direction: arrow }))); } Link.propTypes = { /** A JSX node */ children: PropTypes.node, intent: PropTypes.oneOf(["primary", "primary-light"]), arrow: PropTypes.oneOf(["up", "down", "right", "left"]), href: PropTypes.string };