/*
 * Generate classes for button
 */

export const generateButtonClasses = ( {
	// Icon Panel
	buttonIconPosition,

	// Background Block Panel
	blockButtonBackgroundMode,
	blockButtonBackgroundImageDesktop, blockButtonBackgroundImageTablet, blockButtonBackgroundImageMobile,
	blockButtonBackgroundImageURLDesktop, blockButtonBackgroundImageURLTablet, blockButtonBackgroundImageURLMobile,
	blockButtonBackgroundFixed,

	// Button Icon Panel
	buttonIconNoverEffect,

	// Button Spacing Panel
	buttonMinHeightDesktop, buttonMinHeightTablet, buttonMinHeightMobile,
	buttonWidthDesktop, buttonWidthTablet, buttonWidthMobile,

	// Button Borders & Shadows Panel
	buttonBorderStyle, buttonBorderColor,

	// Block Border
	blockButtonBorderStyle,

	uniqueBlockButtonClass,
} ) => {
	const blockButtonContentVerticalAlignClass = 'ssmb-block-button-vertical-align';
	const blockButtonContentHorizontalAlignClass = 'ssmb-block-button-horizontal-align';

	const marginBlockButtonClasses = 'ssmb-block-button-margin';

	const buttonIconPositionClass = buttonIconPosition ? `ssmb-button-icon-position-${buttonIconPosition}` : '';

	const blockButtonBackgroundImageClass = ( blockButtonBackgroundImageDesktop || blockButtonBackgroundImageTablet || blockButtonBackgroundImageMobile || blockButtonBackgroundImageURLDesktop || blockButtonBackgroundImageURLTablet || blockButtonBackgroundImageURLMobile ) ? 'ssmb-block-button-background-image' : '';
	const blockButtonBackgroundFixedClass = blockButtonBackgroundFixed ? 'ssmb-block-button-background-fixed' : '';

	const blockButtonBackgroundGradientClass = (
		!blockButtonBackgroundImageDesktop && !blockButtonBackgroundImageTablet && !blockButtonBackgroundImageMobile &&
        !blockButtonBackgroundImageURLDesktop && !blockButtonBackgroundImageURLTablet && !blockButtonBackgroundImageURLMobile &&
        blockButtonBackgroundMode === 'gradient'
	) ? 'ssmb-block-button-background-gradient' : '';

	const ButtonHoverEffectClass = buttonIconNoverEffect ? `ssmb-button-effect-${buttonIconNoverEffect}` : '';

	const buttonMinHeightClass = buttonMinHeightDesktop || buttonMinHeightTablet || buttonMinHeightMobile ? `ssmb-button-min-height` : '';
	const buttonWidthClass = buttonWidthDesktop || buttonWidthTablet || buttonWidthMobile ? `ssmb-button-width` : '';


	const buttonBorderStyleClass = `ssmb-button-border-${buttonBorderStyle}`;
	const buttonBorderColorClass = buttonBorderColor ? 'ssmb-button-border-color' : '';

	const blockButtonBorderStyleClass = `ssmb-block-button-border-${blockButtonBorderStyle}`;

	return {
		blockButtonClasses: `ssmb-block-button ${uniqueBlockButtonClass} ${blockButtonContentVerticalAlignClass} ${blockButtonContentHorizontalAlignClass} ${marginBlockButtonClasses} ${blockButtonBackgroundImageClass} ${blockButtonBackgroundFixedClass} ${blockButtonBackgroundGradientClass} ${blockButtonBorderStyleClass}`,
		buttonIconClasses: `ssmb-icon-button-wrapper ${uniqueBlockButtonClass}`,
		buttonClasses: `ssmb-icon-button ${uniqueBlockButtonClass} ${buttonMinHeightClass} ${buttonWidthClass} ${buttonBorderStyleClass} ${buttonBorderColorClass} ${buttonIconPositionClass} ${ButtonHoverEffectClass}`,
	};
};
