@confi/conflux-react-ui-test-package
Version:
Modern and minimalist React UI library.
50 lines (47 loc) • 2.99 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
import _JSXStyle from "styled-jsx/style";
import React from 'react';
import withDefaults from '../utils/with-defaults';
import useTheme from '../styles/use-theme';
import useWarning from '../utils/use-warning';
import LinkIcon from './icon';
var defaultProps = {
href: '',
color: false,
pure: false,
icon: false,
underline: false,
block: false,
className: ''
};
var Link = 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, ["href", "color", "underline", "pure", "children", "className", "block", "icon"]);
var theme = useTheme();
var linkColor = color || block ? theme.palette.link : 'inherit';
var hoverColor = color || block ? theme.palette.successLight : 'inherit';
var padding = block ? theme.layout.gapQuarter : '0';
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
}, props, {
ref: ref,
className: _JSXStyle.dynamic([["2682630561", [linkColor, padding, padding, block ? theme.layout.radius : 0, decoration, block ? '#0076ff1a' : 'unset', hoverColor]]]) + " " + (props && props.className != null && props.className || "link ".concat(className))
}), children, icon && /*#__PURE__*/React.createElement(LinkIcon, null), /*#__PURE__*/React.createElement(_JSXStyle, {
id: "2682630561",
dynamic: [linkColor, padding, padding, block ? theme.layout.radius : 0, decoration, block ? '#0076ff1a' : '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;padding:calc(").concat(padding, " * 0.8) calc(").concat(padding, " * 1.7);border-radius:").concat(block ? theme.layout.radius : 0, ";width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;-webkit-transition:color 200ms ease 0ms;transition:color 200ms ease 0ms;}.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 ? '#0076ff1a' : 'unset', ";color:").concat(hoverColor, ";}")));
});
var MemoLink = React.memo(Link);
export default withDefaults(MemoLink, defaultProps);