| 1 |
import getIcon from '../../utils/get-icon'; |
| 2 |
import metadata from './block.json'; |
| 3 |
import edit from './edit'; |
| 4 |
import save from './save'; |
| 5 |
|
| 6 |
const { name } = metadata; |
| 7 |
|
| 8 |
export { metadata, name }; |
| 9 |
|
| 10 |
export const settings = { |
| 11 |
icon: getIcon('block-progress', true), |
| 12 |
ghostkit: { |
| 13 |
previewUrl: 'https://www.ghostkit.io/docs/blocks/progress/', |
| 14 |
customStylesCallback(attributes) { |
| 15 |
const styles = { |
| 16 |
'--gkt-progress__height': undefined, |
| 17 |
'--gkt-progress__border-radius': undefined, |
| 18 |
'--gkt-progress__background-color': |
| 19 |
attributes.backgroundColor || undefined, |
| 20 |
'--gkt-progress--bar__width': undefined, |
| 21 |
'--gkt-progress--bar__background-color': |
| 22 |
attributes.color || undefined, |
| 23 |
'&:hover': { |
| 24 |
'--gkt-progress--bar__background-color': |
| 25 |
attributes.hoverColor || undefined, |
| 26 |
'--gkt-progress__background-color': |
| 27 |
attributes.hoverBackgroundColor || undefined, |
| 28 |
}, |
| 29 |
}; |
| 30 |
|
| 31 |
if ( |
| 32 |
typeof attributes.height !== 'undefined' && |
| 33 |
attributes.height !== '' |
| 34 |
) { |
| 35 |
styles['--gkt-progress__height'] = `${attributes.height}px`; |
| 36 |
} |
| 37 |
if ( |
| 38 |
typeof attributes.borderRadius !== 'undefined' && |
| 39 |
attributes.borderRadius !== '' |
| 40 |
) { |
| 41 |
styles['--gkt-progress__border-radius'] = |
| 42 |
`${attributes.borderRadius}px`; |
| 43 |
} |
| 44 |
if ( |
| 45 |
typeof attributes.percent !== 'undefined' && |
| 46 |
attributes.percent !== '' |
| 47 |
) { |
| 48 |
styles['--gkt-progress--bar__width'] = `${attributes.percent}%`; |
| 49 |
} |
| 50 |
|
| 51 |
return styles; |
| 52 |
}, |
| 53 |
}, |
| 54 |
example: { |
| 55 |
attributes: { |
| 56 |
ghostkit: { |
| 57 |
id: 'example-progress', |
| 58 |
}, |
| 59 |
className: 'ghostkit-custom-example-progress', |
| 60 |
}, |
| 61 |
}, |
| 62 |
edit, |
| 63 |
save, |
| 64 |
}; |
| 65 |
|