-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e9644ba
commit 4913527
Showing
9 changed files
with
299 additions
and
343 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...s/ppcp-settings/resources/css/components/screens/settings/_tab-paylater-configurator.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...-settings/resources/js/Components/Screens/Settings/Components/Styling/LocationSelector.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { SelectControl } from '@wordpress/components'; | ||
import { __, sprintf } from '@wordpress/i18n'; | ||
|
||
import StylingSection from './StylingSection'; | ||
|
||
const LocationSelector = ( { choices = [], location, setLocation } ) => { | ||
// TODO. move to store/hook. | ||
const locationData = choices.find( | ||
( choice ) => choice.value === location | ||
); | ||
const { description, link } = locationData || {}; | ||
const locationDescription = sprintf( description, link ); | ||
|
||
return ( | ||
<StylingSection | ||
className="header-section" | ||
title={ __( 'Button Styling', 'wooocommerce-paypal-payments' ) } | ||
description={ __( | ||
'Customize the appearance of the PayPal smart buttons on your website and choose which payment buttons to display.', | ||
'woocommerce-paypal-payments' | ||
) } | ||
> | ||
<SelectControl | ||
className="ppcp-r-styling__select" | ||
label={ __( 'Locations', 'woocommerce-paypal-payments' ) } | ||
value={ location } | ||
options={ choices } | ||
onChange={ ( choice ) => setLocation( choice ) } | ||
/> | ||
<p dangerouslySetInnerHTML={ { __html: locationDescription } } /> | ||
</StylingSection> | ||
); | ||
}; | ||
|
||
export default LocationSelector; |
11 changes: 11 additions & 0 deletions
11
...ppcp-settings/resources/js/Components/Screens/Settings/Components/Styling/PreviewPanel.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import PaymentButtonPreview from '../PaymentButtonPreview'; | ||
|
||
const PreviewPanel = ( { settings } ) => ( | ||
<div className="preview-panel"> | ||
<div className="preview-panel-inner"> | ||
<PaymentButtonPreview style={ settings } /> | ||
</div> | ||
</div> | ||
); | ||
|
||
export default PreviewPanel; |
184 changes: 184 additions & 0 deletions
184
...pcp-settings/resources/js/Components/Screens/Settings/Components/Styling/SettingsPanel.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
import { __ } from '@wordpress/i18n'; | ||
import { useState } from '@wordpress/element'; | ||
import { RadioControl, SelectControl } from '@wordpress/components'; | ||
|
||
import { STYLING_LOCATIONS } from '../../../../../data'; | ||
import { PayPalCheckboxGroup } from '../../../../ReusableComponents/Fields'; | ||
import LocationSelector from './LocationSelector'; | ||
import StylingSection from './StylingSection'; | ||
|
||
const SettingsPanel = () => { | ||
const { location, setLocation } = useState( 'cart' ); | ||
|
||
const currentLocationSettings = { | ||
settings: { shape: '', label: '', color: '' }, | ||
}; | ||
const handleChange = () => {}; | ||
|
||
return ( | ||
<div className="settings-panel"> | ||
<LocationSelector | ||
choices={ Object.values( STYLING_LOCATIONS ) } | ||
location={ location } | ||
setLocation={ setLocation } | ||
/> | ||
|
||
<SectionPaymentMethods | ||
locationSettings={ currentLocationSettings } | ||
updateButtonSettings={ handleChange } | ||
/> | ||
|
||
<SectionButtonLayout | ||
locationSettings={ currentLocationSettings } | ||
updateButtonStyle={ handleChange } | ||
/> | ||
|
||
<SectionButtonShape | ||
locationSettings={ currentLocationSettings } | ||
updateButtonStyle={ handleChange } | ||
/> | ||
<SectionButtonLabel | ||
locationSettings={ currentLocationSettings } | ||
updateButtonStyle={ handleChange } | ||
/> | ||
<SectionButtonColor | ||
locationSettings={ currentLocationSettings } | ||
updateButtonStyle={ handleChange } | ||
/> | ||
<SectionButtonTagline | ||
locationSettings={ currentLocationSettings } | ||
updateButtonStyle={ handleChange } | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default SettingsPanel; | ||
|
||
// ----- | ||
const SectionPaymentMethods = ( { | ||
locationSettings, | ||
updateButtonSettings, | ||
} ) => { | ||
const paymentMethodOptions = []; | ||
|
||
return ( | ||
<StylingSection | ||
title={ __( 'Payment Methods', 'woocommerce-paypal-payments' ) } | ||
className="ppcp-r-styling__section--rc" | ||
> | ||
<div className="ppcp-r-styling__payment-method-checkboxes"> | ||
<PayPalCheckboxGroup | ||
value={ paymentMethodOptions } | ||
changeCallback={ ( newValue ) => | ||
updateButtonSettings( 'paymentMethods', newValue ) | ||
} | ||
currentValue={ locationSettings.paymentMethods } | ||
/> | ||
</div> | ||
</StylingSection> | ||
); | ||
}; | ||
|
||
const SectionButtonLayout = ( { locationSettings, updateButtonStyle } ) => { | ||
const buttonLayoutIsAllowed = | ||
locationSettings.layout && locationSettings.tagline === false; | ||
return ( | ||
buttonLayoutIsAllowed && ( | ||
<StylingSection | ||
className="ppcp-r-styling__section--rc" | ||
title={ __( 'Button Layout', 'woocommerce-paypal-payments' ) } | ||
> | ||
<RadioControl | ||
className="ppcp-r__horizontal-control" | ||
onChange={ ( newValue ) => | ||
updateButtonStyle( 'layout', newValue ) | ||
} | ||
selected={ locationSettings.layout } | ||
options={ [] } | ||
/> | ||
</StylingSection> | ||
) | ||
); | ||
}; | ||
|
||
const SectionButtonShape = ( { locationSettings, updateButtonStyle } ) => { | ||
return ( | ||
<StylingSection | ||
title={ __( 'Shape', 'woocommerce-paypal-payments' ) } | ||
className="ppcp-r-styling__section--rc" | ||
> | ||
<RadioControl | ||
className="ppcp-r__horizontal-control" | ||
onChange={ ( newValue ) => | ||
updateButtonStyle( 'shape', newValue ) | ||
} | ||
selected={ locationSettings.shape } | ||
options={ [] } | ||
/> | ||
</StylingSection> | ||
); | ||
}; | ||
|
||
const SectionButtonLabel = ( { locationSettings, updateButtonStyle } ) => { | ||
return ( | ||
<StylingSection> | ||
<SelectControl | ||
className="ppcp-r-styling__select" | ||
onChange={ ( newValue ) => | ||
updateButtonStyle( 'label', newValue ) | ||
} | ||
value={ locationSettings.label } | ||
label={ __( 'Button Label', 'woocommerce-paypal-payments' ) } | ||
options={ [] } | ||
/> | ||
</StylingSection> | ||
); | ||
}; | ||
|
||
const SectionButtonColor = ( { locationSettings, updateButtonStyle } ) => { | ||
return ( | ||
<StylingSection> | ||
<SelectControl | ||
className=" ppcp-r-styling__select" | ||
label={ __( 'Button Color', 'woocommerce-paypal-payments' ) } | ||
onChange={ ( newValue ) => | ||
updateButtonStyle( 'color', newValue ) | ||
} | ||
value={ locationSettings.color } | ||
options={ [] } | ||
/> | ||
</StylingSection> | ||
); | ||
}; | ||
|
||
const SectionButtonTagline = ( { locationSettings, updateButtonStyle } ) => { | ||
const taglineIsAllowed = | ||
locationSettings.hasOwnProperty( 'tagline' ) && | ||
locationSettings.layout === 'horizontal'; | ||
|
||
return ( | ||
taglineIsAllowed && ( | ||
<StylingSection | ||
title={ __( 'Tagline', 'woocommerce-paypal-payments' ) } | ||
className="ppcp-r-styling__section--rc" | ||
> | ||
<PayPalCheckboxGroup | ||
value={ [ | ||
{ | ||
value: 'tagline', | ||
label: __( | ||
'Enable Tagline', | ||
'woocommerce-paypal-payments' | ||
), | ||
}, | ||
] } | ||
changeCallback={ ( newValue ) => { | ||
updateButtonStyle( 'tagline', newValue ); | ||
} } | ||
currentValue={ locationSettings.tagline } | ||
/> | ||
</StylingSection> | ||
) | ||
); | ||
}; |
29 changes: 29 additions & 0 deletions
29
...cp-settings/resources/js/Components/Screens/Settings/Components/Styling/StylingSection.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import classnames from 'classnames'; | ||
|
||
const StylingSection = ( { | ||
title, | ||
className = '', | ||
description = '', | ||
children, | ||
} ) => { | ||
const sectionClasses = classnames( 'ppcp-r-styling__section', className ); | ||
|
||
return ( | ||
<div className={ sectionClasses }> | ||
<span className="ppcp-r-styling__title">{ title }</span> | ||
|
||
{ description && ( | ||
<p | ||
className="ppcp-r-styling__description" | ||
dangerouslySetInnerHTML={ { | ||
__html: description, | ||
} } | ||
/> | ||
) } | ||
|
||
{ children } | ||
</div> | ||
); | ||
}; | ||
|
||
export default StylingSection; |
Oops, something went wrong.