Skip to content

Commit

Permalink
Use paragraph selector instead of label for pmme appearance (#9840)
Browse files Browse the repository at this point in the history
  • Loading branch information
gpressutto5 authored Nov 28, 2024
1 parent 0827530 commit 24f3972
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
4 changes: 4 additions & 0 deletions changelog/fix-pmme-appearance-blocks
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Use paragraph selector instead of label for pmme appearance
21 changes: 16 additions & 5 deletions client/checkout/upe-styles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const appearanceSelectors = {
appendTarget: '.woocommerce-billing-fields__field-wrapper',
upeThemeInputSelector: '#billing_first_name',
upeThemeLabelSelector: '.woocommerce-checkout .form-row label',
upeThemeTextSelector: '.woocommerce-checkout .form-row',
rowElement: 'p',
validClasses: [ 'form-row' ],
invalidClasses: [
Expand All @@ -46,6 +47,7 @@ export const appearanceSelectors = {
appendTarget: '#contact-fields',
upeThemeInputSelector: '.wc-block-components-text-input #email',
upeThemeLabelSelector: '.wc-block-components-text-input label',
upeThemeTextSelector: '.wc-block-components-text-input',
rowElement: 'div',
validClasses: [ 'wc-block-components-text-input', 'is-active' ],
invalidClasses: [ 'wc-block-components-text-input', 'has-error' ],
Expand Down Expand Up @@ -73,6 +75,7 @@ export const appearanceSelectors = {
appendTarget: '.product .cart .quantity',
upeThemeInputSelector: '.product .cart .quantity .qty',
upeThemeLabelSelector: '.product .cart .quantity label',
upeThemeTextSelector: '.product .cart .quantity',
rowElement: 'div',
validClasses: [ 'input-text' ],
invalidClasses: [ 'input-text', 'has-error' ],
Expand All @@ -91,6 +94,7 @@ export const appearanceSelectors = {
appendTarget: '.cart .quantity',
upeThemeInputSelector: '.cart .quantity .qty',
upeThemeLabelSelector: '.cart .quantity label',
upeThemeTextSelector: '.cart .quantity',
rowElement: 'div',
validClasses: [ 'input-text' ],
invalidClasses: [ 'input-text', 'has-error' ],
Expand All @@ -111,6 +115,7 @@ export const appearanceSelectors = {
upeThemeInputSelector:
'.wc-block-cart .wc-block-components-quantity-selector .wc-block-components-quantity-selector__input',
upeThemeLabelSelector: '.wc-block-components-text-input',
upeThemeTextSelector: '.wc-block-components-text-input',
rowElement: 'div',
validClasses: [ 'wc-block-components-text-input' ],
invalidClasses: [ 'wc-block-components-text-input', 'has-error' ],
Expand All @@ -133,6 +138,7 @@ export const appearanceSelectors = {
appendTarget: '.woocommerce-billing-fields__field-wrapper',
upeThemeInputSelector: '#billing_first_name',
upeThemeLabelSelector: '.woocommerce-checkout .form-row label',
upeThemeTextSelector: '.woocommerce-checkout .form-row',
rowElement: 'p',
validClasses: [ 'form-row' ],
invalidClasses: [
Expand Down Expand Up @@ -476,6 +482,11 @@ export const getAppearance = ( elementsLocation, forWooPay = false ) => {
'.Label'
);

const paragraphRules = getFieldStyles(
selectors.upeThemeTextSelector,
'.Text'
);

const tabRules = getFieldStyles( selectors.upeThemeInputSelector, '.Tab' );
const selectedTabRules = getFieldStyles(
selectors.hiddenInput,
Expand Down Expand Up @@ -505,9 +516,9 @@ export const getAppearance = ( elementsLocation, forWooPay = false ) => {
);
const globalRules = {
colorBackground: backgroundColor,
colorText: labelRules.color,
fontFamily: labelRules.fontFamily,
fontSizeBase: labelRules.fontSize,
colorText: paragraphRules.color,
fontFamily: paragraphRules.fontFamily,
fontSizeBase: paragraphRules.fontSize,
};

const isFloatingLabel = elementsLocation === 'blocks_checkout';
Expand All @@ -528,8 +539,8 @@ export const getAppearance = ( elementsLocation, forWooPay = false ) => {
'.Tab--selected': selectedTabRules,
'.TabIcon:hover': tabIconHoverRules,
'.TabIcon--selected': selectedTabIconRules,
'.Text': labelRules,
'.Text--redirect': labelRules,
'.Text': paragraphRules,
'.Text--redirect': paragraphRules,
} )
),
};
Expand Down
3 changes: 3 additions & 0 deletions client/checkout/upe-styles/upe-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const borderOutlineBackgroundProps = [
];
const upeSupportedProperties = {
'.Label': [ ...paddingColorProps, ...textFontTransitionProps ],
'.Text': [ ...paddingColorProps, ...textFontTransitionProps ],
'.Input': [
...paddingColorProps,
...textFontTransitionProps,
Expand Down Expand Up @@ -112,4 +113,6 @@ export const upeRestrictedProperties = {
'.TabLabel': upeSupportedProperties[ '.TabLabel' ],
'.Block': upeSupportedProperties[ '.Block' ],
'.Container': upeSupportedProperties[ '.Container' ],
'.Text': upeSupportedProperties[ '.Text' ],
'.Text--redirect': upeSupportedProperties[ '.Text' ],
};

0 comments on commit 24f3972

Please sign in to comment.