add css class name helper functions for blocks
This commit is contained in:
39
web/app/themes/badegg/resources/js/lib/blocks/classNames.js
Normal file
39
web/app/themes/badegg/resources/js/lib/blocks/classNames.js
Normal file
@@ -0,0 +1,39 @@
|
||||
export function containerClassNames(attributes, bgProps)
|
||||
{
|
||||
|
||||
let classNames = [
|
||||
'container',
|
||||
];
|
||||
|
||||
if('container_width' in attributes)
|
||||
classNames.push(`container-${attributes.container_width}`);
|
||||
|
||||
if('alignment' in attributes)
|
||||
classNames.push(`align-${attributes.alignment}`);
|
||||
|
||||
return classNames;
|
||||
}
|
||||
|
||||
export function sectionClassNames(attributes, defaultClasses, extraClasses = [])
|
||||
{
|
||||
defaultClasses = defaultClasses.split(' ');
|
||||
|
||||
let classNames = [
|
||||
'section',
|
||||
];
|
||||
|
||||
if('padding_top'in attributes && !attributes.padding_top)
|
||||
classNames.push('section-zero-top');
|
||||
|
||||
if('padding_bottom'in attributes && !attributes.padding_bottom)
|
||||
classNames.push('section-zero-bottom');
|
||||
|
||||
|
||||
// combine arrays
|
||||
classNames = classNames.concat(defaultClasses).concat(extraClasses);
|
||||
|
||||
// remove duplicate items
|
||||
classNames = [ ...new Set(classNames) ];
|
||||
|
||||
return classNames;
|
||||
}
|
||||
Reference in New Issue
Block a user