From e9644ba02602af6d100c9ef200b98078e712c629 Mon Sep 17 00:00:00 2001 From: Philipp Stracker Date: Tue, 14 Jan 2025 16:19:18 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Improve=20the=20reducer=20?= =?UTF-8?q?by=20using=20defined=20constants?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/js/data/styling/constants.js | 5 +++ .../resources/js/data/styling/reducer.js | 31 ++++++++++--------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/modules/ppcp-settings/resources/js/data/styling/constants.js b/modules/ppcp-settings/resources/js/data/styling/constants.js index e5e32efab..357fe43a1 100644 --- a/modules/ppcp-settings/resources/js/data/styling/constants.js +++ b/modules/ppcp-settings/resources/js/data/styling/constants.js @@ -33,6 +33,7 @@ export const STYLING_LOCATIONS = { cart: { value: 'cart', label: __( 'Cart', 'woocommerce-paypal-payments' ), + // translators: %s is the URL to a documentation page. description: __( 'Customize the appearance of the PayPal smart buttons on the Cart page and select which additional payment buttons to display in this location.', 'wooocommerce-paypal-payments' @@ -42,6 +43,7 @@ export const STYLING_LOCATIONS = { 'classic-checkout': { value: 'classic-checkout', label: __( 'Classic Checkout', 'woocommerce-paypal-payments' ), + // translators: %s is the URL to a documentation page. description: __( 'Customize the appearance of the PayPal smart buttons on the Classic Checkout page and choose which additional payment buttons to display in this location.', 'wooocommerce-paypal-payments' @@ -51,6 +53,7 @@ export const STYLING_LOCATIONS = { 'express-checkout': { value: 'express-checkout', label: __( 'Express Checkout', 'woocommerce-paypal-payments' ), + // translators: %s is the URL to a documentation page. description: __( 'Customize the appearance of the PayPal smart buttons on the Express Checkout location and choose which additional payment buttons to display in this location.', 'wooocommerce-paypal-payments' @@ -60,6 +63,7 @@ export const STYLING_LOCATIONS = { 'mini-cart': { value: 'mini-cart', label: __( 'Mini Cart', 'woocommerce-paypel-payements' ), + // translators: %s is the URL to a documentation page. description: __( 'Customize the appearance of the PayPal smart buttons on the Mini Cart and choose which additional payment buttons to display in this location.', 'wooocommerce-paypal-payments' @@ -69,6 +73,7 @@ export const STYLING_LOCATIONS = { 'product-page': { value: 'product-page', label: __( 'Product Page', 'woocommerce-paypal-payments' ), + // translators: %s is the URL to a documentation page. description: __( 'Customize the appearance of the PayPal smart buttons on the Product Page and choose which additional payment buttons to display in this location.', 'wooocommerce-paypal-payments' diff --git a/modules/ppcp-settings/resources/js/data/styling/reducer.js b/modules/ppcp-settings/resources/js/data/styling/reducer.js index 3ac82ab6d..b28c3f265 100644 --- a/modules/ppcp-settings/resources/js/data/styling/reducer.js +++ b/modules/ppcp-settings/resources/js/data/styling/reducer.js @@ -9,6 +9,7 @@ import { createReducer, createSetters } from '../utils'; import ACTION_TYPES from './action-types'; +import { STYLING_COLORS, STYLING_SHAPES } from './constants'; // Store structure. @@ -21,38 +22,38 @@ const defaultTransient = Object.freeze( { const defaultPersistent = Object.freeze( { cart: { enabled: true, - methods: [ 'venmo', 'applepay', 'googlepay', 'credit card' ], - shape: 'rect', + methods: [], label: 'Pay', - color: 'gold', + shape: STYLING_SHAPES.rect.value, + color: STYLING_COLORS.gold.value, }, 'classic-checkout': { enabled: true, - methods: [ 'venmo', 'applepay', 'googlepay', 'credit card' ], - shape: 'rect', + methods: [], label: 'Checkout', - color: 'gold', + shape: STYLING_SHAPES.rect.value, + color: STYLING_COLORS.gold.value, }, 'express-checkout': { enabled: true, - methods: [ 'venmo', 'applepay', 'googlepay', 'credit card' ], - shape: 'rect', + methods: [], label: 'Checkout', - color: 'gold', + shape: STYLING_SHAPES.rect.value, + color: STYLING_COLORS.gold.value, }, 'mini-cart': { enabled: true, - methods: [ 'venmo', 'applepay', 'googlepay', 'credit card' ], - shape: 'rect', + methods: [], label: 'Pay', - color: 'gold', + shape: STYLING_SHAPES.rect.value, + color: STYLING_COLORS.gold.value, }, product: { enabled: true, - methods: [ 'venmo', 'applepay', 'googlepay', 'credit card' ], - shape: 'rect', + methods: [], label: 'Buy', - color: 'gold', + shape: STYLING_SHAPES.rect.value, + color: STYLING_COLORS.gold.value, }, } );