Class BackgroundCssHelper

java.lang.Object
dev.jcputney.mjml.util.BackgroundCssHelper

public final class BackgroundCssHelper extends Object
Builds CSS background-related style maps for sections and wrappers. Eliminates duplication between MjSection and MjWrapper.
  • Method Details

    • buildBackgroundCss

      public static String buildBackgroundCss(String bgColor, String bgUrl, String bgPosition, String bgSize, String bgRepeat)
      Builds the CSS background shorthand for a component with background image. Format: "#color url('...') position / size repeat"
      Parameters:
      bgColor - the background color value, or null/empty if none
      bgUrl - the background image URL
      bgPosition - the background position value (e.g. "center top")
      bgSize - the background size value (e.g. "auto", "cover")
      bgRepeat - the background repeat value (e.g. "repeat", "no-repeat")
      Returns:
      the CSS background shorthand string
    • buildBgImageDivStyleMap

      public static Map<String,String> buildBgImageDivStyleMap(String bgCss, String bgPosition, String bgRepeat, String bgSize, int containerWidth)
      Builds style map for outer div of a section/wrapper with background image.
      Parameters:
      bgCss - the CSS background shorthand value
      bgPosition - the background position value
      bgRepeat - the background repeat value
      bgSize - the background size value
      containerWidth - the container width in pixels
      Returns:
      a map of CSS property names to values for the background image div
    • buildBgImageTableStyleMap

      public static Map<String,String> buildBgImageTableStyleMap(String bgCss, String bgPosition, String bgRepeat, String bgSize)
      Builds style map for inner table of a section/wrapper with background image.
      Parameters:
      bgCss - the CSS background shorthand value
      bgPosition - the background position value
      bgRepeat - the background repeat value
      bgSize - the background size value
      Returns:
      a map of CSS property names to values for the background image table