@razorpay/blade
Version:
The Design System that powers Razorpay
87 lines (84 loc) • 4.01 kB
JavaScript
import _defineProperty from '@babel/runtime/helpers/defineProperty';
import '../../../utils/index.js';
import '../../../utils/getFocusRingStyles/index.js';
import { makeSpace } from '../../../utils/makeSpace/makeSpace.js';
import { isReactNative } from '../../../utils/platform/isReactNative.js';
import { castWebType } from '../../../utils/platform/castUtils.js';
import { makeMotionTime } from '../../../utils/makeMotionTime/makeMotionTime.web.js';
import { getFocusRingStyles } from '../../../utils/getFocusRingStyles/getFocusRingStyles.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 getNavigationButtonStyles = function getNavigationButtonStyles(props) {
var theme = props.theme,
_props$isPressed = props.isPressed,
isPressed = _props$isPressed === void 0 ? false : _props$isPressed,
_props$variant = props.variant,
variant = _props$variant === void 0 ? 'filled' : _props$variant;
var motionToken = theme.motion;
var iconColor = {
filled: {
"default": theme.colors.interactive.icon.staticBlack.muted,
highlighted: theme.colors.interactive.icon.staticBlack.muted
},
stroked: {
"default": theme.colors.interactive.icon.gray.normal,
highlighted: theme.colors.interactive.icon.gray.normal
}
};
var backgroundColor = {
filled: {
"default": theme.colors.interactive.background.staticWhite["default"],
highlighted: theme.colors.interactive.background.staticWhite.highlighted
},
stroked: {
"default": theme.colors.interactive.background.staticWhite.faded,
highlighted: theme.colors.interactive.background.staticWhite.fadedHighlighted
}
};
var borderColors = {
filled: theme.colors.transparent,
stroked: theme.colors.interactive.border.gray.faded
};
var borderColor = borderColors[variant];
var borderWidth = theme.border.width.thin;
var borderRadius = theme.border.radius.max;
// on react-native isPressed will be passed
var state = isPressed ? 'highlighted' : 'default';
return _objectSpread({
cursor: 'pointer',
background: 'transparent',
border: 'none',
borderStyle: 'solid',
borderWidth: borderWidth,
borderRadius: borderRadius,
borderColor: borderColor,
backgroundColor: backgroundColor[variant][state],
color: iconColor[variant][state],
padding: makeSpace(theme.spacing[3]),
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
alignSelf: 'center'
}, isReactNative() ? {} : {
transitionProperty: 'color, box-shadow',
transitionDuration: castWebType(makeMotionTime(motionToken.duration.xquick)),
transitionTimingFunction: castWebType(motionToken.easing.standard),
boxShadow: variant === 'filled' ? castWebType(theme.elevation.midRaised) : undefined,
'&:hover': {
color: iconColor[variant].highlighted,
backgroundColor: backgroundColor[variant].highlighted
},
'&:focus-visible': _objectSpread(_objectSpread({}, getFocusRingStyles({
theme: theme
})), {}, {
color: iconColor[variant].highlighted,
backgroundColor: backgroundColor[variant].highlighted
}),
'&:active': {
color: iconColor[variant].highlighted,
backgroundColor: backgroundColor[variant].highlighted
}
});
};
export { getNavigationButtonStyles };
//# sourceMappingURL=getNavigationButtonStyles.js.map