| 1 |
import getIcon from '../../utils/get-icon'; |
| 2 |
import metadata from './block.json'; |
| 3 |
import edit from './edit'; |
| 4 |
import save from './save'; |
| 5 |
import transforms from './transforms'; |
| 6 |
|
| 7 |
const { name } = metadata; |
| 8 |
|
| 9 |
export { metadata, name }; |
| 10 |
|
| 11 |
export const settings = { |
| 12 |
icon: getIcon('block-buttons', true), |
| 13 |
ghostkit: { |
| 14 |
previewUrl: 'https://www.ghostkit.io/docs/blocks/button/', |
| 15 |
customStylesCallback(attributes) { |
| 16 |
const { gap, gapCustom, gapVerticalCustom } = attributes; |
| 17 |
|
| 18 |
const styles = { |
| 19 |
'--gkt-button__gap': undefined, |
| 20 |
'--gkt-button__gap-vertical': undefined, |
| 21 |
}; |
| 22 |
|
| 23 |
// Custom Gap. |
| 24 |
if (gap === 'custom') { |
| 25 |
if (typeof gapCustom !== 'undefined') { |
| 26 |
// we need to use `%` unit because of conflict with complex calc() and 0 value. |
| 27 |
const unit = gapCustom ? 'px' : '%'; |
| 28 |
|
| 29 |
styles['--gkt-button__gap'] = `${gapCustom}${unit}`; |
| 30 |
} |
| 31 |
|
| 32 |
if (typeof gapVerticalCustom !== 'undefined') { |
| 33 |
// we need to use `%` unit because of conflict with complex calc() and 0 value. |
| 34 |
const unit = gapVerticalCustom ? 'px' : '%'; |
| 35 |
|
| 36 |
styles['--gkt-button__gap-vertical'] = |
| 37 |
`${gapVerticalCustom}${unit}`; |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
return styles; |
| 42 |
}, |
| 43 |
}, |
| 44 |
example: { |
| 45 |
attributes: { |
| 46 |
count: 2, |
| 47 |
align: 'center', |
| 48 |
gap: 'lg', |
| 49 |
}, |
| 50 |
innerBlocks: [ |
| 51 |
{ |
| 52 |
name: 'ghostkit/button-single', |
| 53 |
attributes: { |
| 54 |
text: 'Button 1', |
| 55 |
size: 'xl', |
| 56 |
color: '#0366d6', |
| 57 |
ghostkit: { |
| 58 |
id: 'example-button-1', |
| 59 |
}, |
| 60 |
className: 'ghostkit-custom-example-button-1', |
| 61 |
}, |
| 62 |
}, |
| 63 |
{ |
| 64 |
name: 'ghostkit/button-single', |
| 65 |
attributes: { |
| 66 |
text: 'Button 2', |
| 67 |
size: 'xl', |
| 68 |
color: '#2F1747', |
| 69 |
icon: '<svg class="ghostkit-svg-icon" width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M16.7813 9.75C16.7813 7.10939 14.6406 4.96875 12 4.96875C9.35939 4.96875 7.21875 7.10939 7.21875 9.75C7.21875 12.3906 9.35939 14.5312 12 14.5312C14.6406 14.5312 16.7813 12.3906 16.7813 9.75Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/><path d="M8.15625 18C10.6023 19.25 13.3977 19.25 15.8437 18" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>', |
| 70 |
borderRadius: 50, |
| 71 |
ghostkit: { |
| 72 |
id: 'example-button-2', |
| 73 |
}, |
| 74 |
className: 'ghostkit-custom-example-button-2', |
| 75 |
}, |
| 76 |
}, |
| 77 |
], |
| 78 |
}, |
| 79 |
edit, |
| 80 |
save, |
| 81 |
transforms, |
| 82 |
}; |
| 83 |
|