mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Refactor: extract logic to corresponding modules
This commit is contained in:
parent
c4232e3957
commit
9f18f2e899
13 changed files with 2549 additions and 451 deletions
50
modules/ppcp-card-fields/resources/js/CardFieldsHelper.js
Normal file
50
modules/ppcp-card-fields/resources/js/CardFieldsHelper.js
Normal file
|
@ -0,0 +1,50 @@
|
|||
export const cardFieldStyles = ( field ) => {
|
||||
const allowedProperties = [
|
||||
'appearance',
|
||||
'color',
|
||||
'direction',
|
||||
'font',
|
||||
'font-family',
|
||||
'font-size',
|
||||
'font-size-adjust',
|
||||
'font-stretch',
|
||||
'font-style',
|
||||
'font-variant',
|
||||
'font-variant-alternates',
|
||||
'font-variant-caps',
|
||||
'font-variant-east-asian',
|
||||
'font-variant-ligatures',
|
||||
'font-variant-numeric',
|
||||
'font-weight',
|
||||
'letter-spacing',
|
||||
'line-height',
|
||||
'opacity',
|
||||
'outline',
|
||||
'padding',
|
||||
'padding-bottom',
|
||||
'padding-left',
|
||||
'padding-right',
|
||||
'padding-top',
|
||||
'text-shadow',
|
||||
'transition',
|
||||
'-moz-appearance',
|
||||
'-moz-osx-font-smoothing',
|
||||
'-moz-tap-highlight-color',
|
||||
'-moz-transition',
|
||||
'-webkit-appearance',
|
||||
'-webkit-osx-font-smoothing',
|
||||
'-webkit-tap-highlight-color',
|
||||
'-webkit-transition',
|
||||
];
|
||||
|
||||
const stylesRaw = window.getComputedStyle( field );
|
||||
const styles = {};
|
||||
Object.values( stylesRaw ).forEach( ( prop ) => {
|
||||
if ( ! stylesRaw[ prop ] || ! allowedProperties.includes( prop ) ) {
|
||||
return;
|
||||
}
|
||||
styles[ prop ] = '' + stylesRaw[ prop ];
|
||||
} );
|
||||
|
||||
return styles;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue