| 1 |
/** |
| 2 |
* Internal dependencies. |
| 3 |
*/ |
| 4 |
import RenderSettingControl from '../../utils/components/settings/renderSettingControl'; |
| 5 |
|
| 6 |
const { __ } = wp.i18n; |
| 7 |
const { Fragment } = wp.element; |
| 8 |
const { SelectControl, ToggleControl } = wp.components; |
| 9 |
const { PanelColorSettings } = wp.blockEditor; |
| 10 |
|
| 11 |
export default function ButtonSettings(props) { |
| 12 |
const { |
| 13 |
enableButtonBackgroundColor, |
| 14 |
buttonBackgroundColor, |
| 15 |
onChangeButtonColor = () => {}, |
| 16 |
enableButtonTextColor, |
| 17 |
buttonTextColor, |
| 18 |
onChangeButtonTextColor = () => {}, |
| 19 |
enableButtonSize, |
| 20 |
buttonSize, |
| 21 |
onChangeButtonSize = () => {}, |
| 22 |
enableButtonShape, |
| 23 |
buttonShape, |
| 24 |
onChangeButtonShape = () => {}, |
| 25 |
enableButtonTarget, |
| 26 |
buttonTarget, |
| 27 |
onChangeButtonTarget = () => {}, |
| 28 |
} = props; |
| 29 |
|
| 30 |
// Button size values |
| 31 |
const buttonSizeOptions = [ |
| 32 |
{ |
| 33 |
value: 'gb-button-size-small', |
| 34 |
label: __('Small', 'genesis-blocks'), |
| 35 |
}, |
| 36 |
{ |
| 37 |
value: 'gb-button-size-medium', |
| 38 |
label: __('Medium', 'genesis-blocks'), |
| 39 |
}, |
| 40 |
{ |
| 41 |
value: 'gb-button-size-large', |
| 42 |
label: __('Large', 'genesis-blocks'), |
| 43 |
}, |
| 44 |
{ |
| 45 |
value: 'gb-button-size-extralarge', |
| 46 |
label: __('Extra Large', 'genesis-blocks'), |
| 47 |
}, |
| 48 |
]; |
| 49 |
|
| 50 |
// Button shape |
| 51 |
const buttonShapeOptions = [ |
| 52 |
{ |
| 53 |
value: 'gb-button-shape-square', |
| 54 |
label: __('Square', 'genesis-blocks'), |
| 55 |
}, |
| 56 |
{ |
| 57 |
value: 'gb-button-shape-rounded', |
| 58 |
label: __('Rounded Square', 'genesis-blocks'), |
| 59 |
}, |
| 60 |
{ |
| 61 |
value: 'gb-button-shape-circular', |
| 62 |
label: __('Circular', 'genesis-blocks'), |
| 63 |
}, |
| 64 |
]; |
| 65 |
|
| 66 |
return ( |
| 67 |
<Fragment> |
| 68 |
<RenderSettingControl id="gb_button_buttonOptions"> |
| 69 |
{false !== enableButtonTarget && ( |
| 70 |
<ToggleControl |
| 71 |
__nextHasNoMarginBottom |
| 72 |
label={__('Open link in new window', 'genesis-blocks')} |
| 73 |
checked={buttonTarget} |
| 74 |
onChange={onChangeButtonTarget} |
| 75 |
/> |
| 76 |
)} |
| 77 |
{false !== enableButtonSize && ( |
| 78 |
<SelectControl |
| 79 |
__next40pxDefaultSize |
| 80 |
__nextHasNoMarginBottom |
| 81 |
selected={buttonSize} |
| 82 |
label={__('Button Size', 'genesis-blocks')} |
| 83 |
value={buttonSize} |
| 84 |
options={buttonSizeOptions.map(({ value, label }) => ({ |
| 85 |
value, |
| 86 |
label, |
| 87 |
}))} |
| 88 |
onChange={onChangeButtonSize} |
| 89 |
/> |
| 90 |
)} |
| 91 |
{false !== enableButtonShape && ( |
| 92 |
<SelectControl |
| 93 |
__next40pxDefaultSize |
| 94 |
__nextHasNoMarginBottom |
| 95 |
label={__('Button Shape', 'genesis-blocks')} |
| 96 |
value={buttonShape} |
| 97 |
options={buttonShapeOptions.map(({ value, label }) => ({ |
| 98 |
value, |
| 99 |
label, |
| 100 |
}))} |
| 101 |
onChange={onChangeButtonShape} |
| 102 |
/> |
| 103 |
)} |
| 104 |
{false !== enableButtonBackgroundColor && ( |
| 105 |
<PanelColorSettings |
| 106 |
title={__('Button Color', 'genesis-blocks')} |
| 107 |
initialOpen={false} |
| 108 |
colorSettings={[ |
| 109 |
{ |
| 110 |
value: buttonBackgroundColor, |
| 111 |
onChange: onChangeButtonColor, |
| 112 |
label: __('Button Color', 'genesis-blocks'), |
| 113 |
}, |
| 114 |
]} |
| 115 |
></PanelColorSettings> |
| 116 |
)} |
| 117 |
{false !== enableButtonTextColor && ( |
| 118 |
<PanelColorSettings |
| 119 |
title={__('Button Text Color', 'genesis-blocks')} |
| 120 |
initialOpen={false} |
| 121 |
colorSettings={[ |
| 122 |
{ |
| 123 |
value: buttonTextColor, |
| 124 |
onChange: onChangeButtonTextColor, |
| 125 |
label: __( |
| 126 |
'Button Text Color', |
| 127 |
'genesis-blocks' |
| 128 |
), |
| 129 |
}, |
| 130 |
]} |
| 131 |
></PanelColorSettings> |
| 132 |
)} |
| 133 |
</RenderSettingControl> |
| 134 |
</Fragment> |
| 135 |
); |
| 136 |
} |
| 137 |
|