Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use paragraph selector instead of label for pmme appearance #9840

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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' ],
};
Loading