UNPKG

react-native-paypal-buttons

Version:
112 lines (111 loc) 3.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getLogoInfo = void 0; var _types = require("./types"); const paypalLogos = [{ type: 'credit', variant: 'color', uri: require('./assets/logos/credit_color.png'), width: 262, height: 88 }, { type: 'credit', variant: 'monochrome', uri: require('./assets/logos/credit_monochrome.png'), width: 262, height: 88 }, { type: 'paypal_monogram', variant: 'blue', uri: require('./assets/logos/paypal_monogram_blue.png'), width: 34, height: 38 }, { type: 'paypal_monogram', variant: 'color', uri: require('./assets/logos/paypal_monogram_color.png'), width: 34, height: 38 }, { type: 'paypal_monogram', variant: 'monochrome', uri: require('./assets/logos/paypal_monogram_monochrome.png'), width: 34, height: 38 }, { type: 'paypal', variant: 'blue', uri: require('./assets/logos/paypal_blue.png'), width: 206, height: 52 }, { type: 'paypal', variant: 'color', uri: require('./assets/logos/paypal_color.png'), width: 206, height: 52 }, { type: 'paypal', variant: 'monochrome', uri: require('./assets/logos/paypal_monochrome.png'), width: 206, height: 52 }]; const getLogoType = (fundingSource, size) => { switch (fundingSource) { case _types.PaymentButtonFundingSource.CREDIT: return 'credit'; case _types.PaymentButtonFundingSource.PAY_LATER: return 'paypal_monogram'; case _types.PaymentButtonFundingSource.PAYPAL: if (size === _types.PaymentButtonSize.MINI) { return 'paypal_monogram'; } return 'paypal'; } }; const getLogoVariant = backgroundColor => { switch (backgroundColor) { case _types.PaymentButtonColor.BLUE: return 'blue'; case _types.PaymentButtonColor.GOLD: case _types.PaymentButtonColor.WHITE: case _types.PaymentButtonColor.SILVER: return 'color'; case _types.PaymentButtonColor.BLACK: case _types.PaymentButtonColor.BLACK: case _types.PaymentButtonColor.DARK_BLUE: return 'monochrome'; } }; const getLogoDefaultHeight = (fundingSource, size) => { switch (size) { case _types.PaymentButtonSize.MINI: return [_types.PaymentButtonFundingSource.PAY_LATER, _types.PaymentButtonFundingSource.CREDIT].includes(fundingSource) ? 12 : 24; case _types.PaymentButtonSize.COLLAPSED: return 15; case _types.PaymentButtonSize.EXPANDED: return 20; case _types.PaymentButtonSize.FULL: return 26; } }; const getLogoInfo = (fundingSource, size, backgroundColor) => { const type = getLogoType(fundingSource, size); const variant = getLogoVariant(backgroundColor); const info = paypalLogos.find(logo => logo.type === type && logo.variant === variant); if (!info) { throw 'Unable to find logo infos'; } const ratio = info.width / info.height; const height = getLogoDefaultHeight(fundingSource, size); return { ...info, height, width: height * ratio }; }; exports.getLogoInfo = getLogoInfo; //# sourceMappingURL=logo.js.map