@razorpay/blade
Version:
The Design System that powers Razorpay
79 lines (76 loc) • 4.29 kB
JavaScript
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import styled from 'styled-components';
import getBaseButtonStyles from './getStyledBaseButtonStyles.js';
import getIn from '../../../utils/lodashButBetter/get.js';
import '../../Box/styledProps/index.js';
import '../../../utils/makeMotionTime/index.web.js';
import { omitPropsFromHTML } from '../../../utils/omitPropsFromHTML/index.js';
import '../../../utils/index.js';
import { useStyledProps } from '../../Box/styledProps/useStyledProps.js';
import { castWebType } from '../../../utils/platform/castUtils.js';
import { makeMotionTime } from '../../../utils/makeMotionTime/makeMotionTime.web.js';
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var StyledBaseButton = /*#__PURE__*/styled.button.withConfig({
shouldForwardProp: omitPropsFromHTML,
displayName: 'StyledBaseButton'
}).attrs(function (props) {
return _objectSpread({}, props.accessibilityProps);
}).withConfig({
displayName: "StyledBaseButtonweb__StyledBaseButton",
componentId: "sc-26bt38-0"
})(function (props) {
var _props$size;
var styledPropsCSSObject = useStyledProps(props);
var gradientSizeMap = {
large: 72,
medium: 64,
small: 56,
xsmall: 48
};
var gradientSize = gradientSizeMap[(_props$size = props.size) !== null && _props$size !== void 0 ? _props$size : 'medium'];
var mouseGradient = props.variant === 'primary' && !props.disabled ? "radial-gradient(".concat(gradientSize, "px ").concat(gradientSize, "px at var(--mouse-x, 0%) var(--mouse-y, 0%), ").concat(props.theme.colors.interactive.background.staticWhite.faded, " 0%, transparent 100%)") : 'none';
return _objectSpread(_objectSpread({}, getBaseButtonStyles(props)), {}, {
display: 'inline-flex',
backgroundImage: mouseGradient,
transitionProperty: 'background-color, background-image, box-shadow',
transitionTimingFunction: getIn(props.theme.motion, props.motionEasing),
transitionDuration: castWebType(makeMotionTime(getIn(props.theme.motion, props.motionDuration))),
position: 'relative',
'&:hover': _objectSpread({
backgroundColor: props.hoverBackgroundColor,
boxShadow: props.hoverBoxShadow,
backgroundImage: 'none'
}, props.variant === 'tertiary' && props.color === 'transparent' && {
'&& [data-blade-component="svg-path"]': {
fill: props.hoverIconColor
}
}),
'&:active': _objectSpread({
backgroundColor: props.focusBackgroundColor,
boxShadow: props.focusBoxShadow,
backgroundImage: 'none'
}, props.variant === 'tertiary' && props.color === 'transparent' && {
'&& [data-blade-component="svg-path"]': {
fill: props.hoverIconColor
}
}),
'&:focus-visible': _objectSpread({
backgroundColor: props.focusBackgroundColor,
outline: "1px solid ".concat(props.theme.colors.surface.background.primary.subtle),
backgroundImage: 'none',
boxShadow: props.focusBoxShadow ? "0px 0px 0px 4px ".concat(props.focusRingColor, ", ").concat(props.focusBoxShadow) : "0px 0px 0px 4px ".concat(props.focusRingColor)
}, props.variant === 'tertiary' && props.color === 'transparent' && {
'&& [data-blade-component="svg-path"]': {
fill: props.hoverIconColor
}
}),
'*': {
transitionProperty: 'color, fill, opacity',
transitionDuration: castWebType(makeMotionTime(getIn(props.theme.motion, props.motionDuration))),
transitionTimingFunction: getIn(props.theme.motion, props.motionEasing)
}
}, styledPropsCSSObject);
});
export { StyledBaseButton as default };
//# sourceMappingURL=StyledBaseButton.web.js.map