@geist-ui/react
Version:
Modern and minimalist React UI library.
57 lines (52 loc) • 4.17 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["href", "color", "underline", "pure", "children", "className", "block", "icon"];
import _JSXStyle from "../styled-jsx.es.js";
import React from 'react';
import useTheme from '../use-theme';
import useWarning from '../utils/use-warning';
import LinkIcon from './icon';
import { addColorAlpha } from '../utils/color';
import useScaleable, { withPureProps, withScaleable } from '../use-scaleable';
var defaultProps = {
href: '',
color: false,
pure: false,
icon: false,
underline: false,
block: false,
className: ''
};
var LinkComponent = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
var href = _ref.href,
color = _ref.color,
underline = _ref.underline,
pure = _ref.pure,
children = _ref.children,
className = _ref.className,
block = _ref.block,
icon = _ref.icon,
props = _objectWithoutProperties(_ref, _excluded);
var theme = useTheme();
var _useScaleable = useScaleable(),
SCALES = _useScaleable.SCALES;
var linkColor = color || block ? theme.palette.link : 'inherit';
var hoverColor = color || block ? theme.palette.successLight : 'inherit';
var decoration = underline ? 'underline' : 'none';
if (pure) {
useWarning('Props "pure" is deprecated, now the default Link is pure.');
}
return /*#__PURE__*/React.createElement("a", _extends({
href: href
}, withPureProps(props), {
ref: ref,
className: _JSXStyle.dynamic([["3960817863", [linkColor, block ? theme.layout.radius : 0, SCALES.font(1, 'inherit'), SCALES.width(1, 'fit-content'), SCALES.height(1, 'auto'), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.pt(0.268), SCALES.pr(0.5625), SCALES.pb(0.268), SCALES.pl(0.5625), decoration, block ? addColorAlpha(theme.palette.link, 0.1) : 'unset', hoverColor]]]) + " " + "link ".concat(block ? 'block' : '', " ").concat(className)
}), children, icon && /*#__PURE__*/React.createElement(LinkIcon, null), /*#__PURE__*/React.createElement(_JSXStyle, {
id: "3960817863",
dynamic: [linkColor, block ? theme.layout.radius : 0, SCALES.font(1, 'inherit'), SCALES.width(1, 'fit-content'), SCALES.height(1, 'auto'), SCALES.mt(0), SCALES.mr(0), SCALES.mb(0), SCALES.ml(0), SCALES.pt(0), SCALES.pr(0), SCALES.pb(0), SCALES.pl(0), SCALES.pt(0.268), SCALES.pr(0.5625), SCALES.pb(0.268), SCALES.pl(0.5625), decoration, block ? addColorAlpha(theme.palette.link, 0.1) : 'unset', hoverColor]
}, ".link.__jsx-style-dynamic-selector{display:-webkit-inline-box;display:-webkit-inline-flex;display:-ms-inline-flexbox;display:inline-flex;-webkit-align-items:baseline;-webkit-box-align:baseline;-ms-flex-align:baseline;align-items:baseline;line-height:inherit;color:".concat(linkColor, ";-webkit-text-decoration:none;text-decoration:none;border-radius:").concat(block ? theme.layout.radius : 0, ";-webkit-transition:color 200ms ease 0ms;transition:color 200ms ease 0ms;font-size:").concat(SCALES.font(1, 'inherit'), ";width:").concat(SCALES.width(1, 'fit-content'), ";height:").concat(SCALES.height(1, 'auto'), ";margin:").concat(SCALES.mt(0), " ").concat(SCALES.mr(0), " ").concat(SCALES.mb(0), " ").concat(SCALES.ml(0), ";padding:").concat(SCALES.pt(0), " ").concat(SCALES.pr(0), " ").concat(SCALES.pb(0), " ").concat(SCALES.pl(0), ";}.block.__jsx-style-dynamic-selector{padding:").concat(SCALES.pt(0.268), " ").concat(SCALES.pr(0.5625), " ").concat(SCALES.pb(0.268), " ").concat(SCALES.pl(0.5625), ";}.link.__jsx-style-dynamic-selector:hover,.link.__jsx-style-dynamic-selector:active,.link.__jsx-style-dynamic-selector:focus{-webkit-text-decoration:").concat(decoration, ";text-decoration:").concat(decoration, ";}.link.__jsx-style-dynamic-selector:hover{background-color:").concat(block ? addColorAlpha(theme.palette.link, 0.1) : 'unset', ";color:").concat(hoverColor, ";}")));
});
LinkComponent.defaultProps = defaultProps;
LinkComponent.displayName = 'GeistLink';
var Link = withScaleable(LinkComponent);
export default Link;