react-native-paypal-buttons
Version:
React native implementation of PayPal Buttons
70 lines (69 loc) • 2.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PaymentButton = void 0;
var _reactNative = require("react-native");
var _react = require("react");
var _types = require("./types");
var _utils = require("./utils");
var _logo = require("./logo");
var _label = require("./label");
var _jsxRuntime = require("react/jsx-runtime");
const PaymentButton = ({
fundingSource,
color: backgroundColor,
edges,
label,
size,
...props
}) => {
const [height, setHeight] = (0, _react.useState)(0);
const logo = (0, _logo.getLogoInfo)(fundingSource, size, backgroundColor);
const labelMode = (0, _label.getLabelMode)(label, size);
const borderColor = backgroundColor === _types.PaymentButtonColor.WHITE ? 'black' : backgroundColor;
const opacity = height === 0 ? 0 : 1;
const flexDirection = labelMode === 'suffix' ? 'row' : 'row-reverse';
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Pressable, {
...props,
onLayout: event => {
setHeight(event.nativeEvent.layout.height);
props.onLayout?.(event);
},
style: [styles.button, {
opacity,
flexDirection,
backgroundColor,
...(0, _utils.getDefaultPadding)(size),
borderRadius: (0, _utils.getDefaultBorderRadius)(edges, height),
borderColor
}],
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
source: logo.uri,
resizeMode: "contain",
style: {
height: logo.height,
width: logo.width,
marginHorizontal: (0, _utils.getDefaultSpacing)(size)
}
}), labelMode !== 'none' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
style: [styles.label, {
color: (0, _label.getLabelColor)(backgroundColor)
}],
children: label
})]
});
};
exports.PaymentButton = PaymentButton;
const styles = _reactNative.StyleSheet.create({
button: {
justifyContent: 'center',
alignItems: 'center',
borderWidth: 1
},
label: {
fontSize: 14,
fontFamily: 'PayPalOpen-Regular'
}
});
//# sourceMappingURL=PaymentButton.js.map