in bedrock/contentful/api.py [0:0]
def get_split_data(self, entry_obj):
fields = entry_obj.fields()
# Checking if the split component is being used on the contentful homepage
# If so, we will add a class to the body which will match the style of the depreciated hero component
is_home_page = self.page.content_type.id == "pageHome"
def get_split_class():
block_classes = [
"mzp-l-split-reversed" if fields.get("image_side") == "Left" else "",
self.SPLIT_LAYOUT_CLASS.get(fields.get("body_width"), ""),
self.SPLIT_POP_CLASS.get(fields.get("image_pop"), ""),
]
return " ".join(block_classes)
def get_body_class():
body_classes = [
self.SPLIT_V_ALIGN_CLASS.get(fields.get("body_vertical_alignment"), ""),
self.SPLIT_H_ALIGN_CLASS.get(fields.get("body_horizontal_alignment"), ""),
"c-home-body" if is_home_page else "",
]
return " ".join(body_classes)
def get_media_class():
media_classes = [
self.SPLIT_MEDIA_WIDTH_CLASS.get(fields.get("image_width"), ""),
self.SPLIT_V_ALIGN_CLASS.get(fields.get("image_vertical_alignment"), ""), # this field doesn't appear in Contentful Content Model
self.SPLIT_H_ALIGN_CLASS.get(fields.get("image_horizontal_alignment"), ""), # this field doesn't appear in Contentful Content Model
]
return " ".join(media_classes)
def get_mobile_class():
mobile_display = fields.get("mobile_display")
if not mobile_display:
return ""
mobile_classes = [
"mzp-l-split-center-on-sm-md" if "Center content" in mobile_display else "",
"mzp-l-split-hide-media-on-sm-md" if "Hide image" in mobile_display else "",
]
return " ".join(mobile_classes)
split_image_url = _get_image_url(fields["image"], 800)
data = {
"component": "split",
"block_class": get_split_class(),
"theme_class": _get_theme_class(fields.get("theme")),
"body_class": get_body_class(),
"body": self.render_rich_text(fields.get("body")),
"media_class": get_media_class(),
"media_after": fields.get("mobile_media_after"),
"image": split_image_url,
"mobile_class": get_mobile_class(),
}
return data