Class: Spree::PageSections::ImageWithText

Inherits:
Spree::PageSection show all
Includes:
HasImageAltText
Defined in:
app/models/spree/page_sections/image_with_text.rb

Constant Summary collapse

TOP_PADDING_DEFAULT =
16
BOTTOM_PADDING_DEFAULT =
16

Constants inherited from Spree::PageSection

Spree::PageSection::BACKGROUND_COLOR_DEFAULT, Spree::PageSection::BORDER_COLOR_DEFAULT, Spree::PageSection::BOTTOM_BORDER_WIDTH_DEFAULT, Spree::PageSection::TEXT_COLOR_DEFAULT, Spree::PageSection::TOP_BORDER_WIDTH_DEFAULT

Instance Method Summary collapse

Methods included from HasImageAltText

#image_alt

Methods inherited from Spree::PageSection

#can_be_deleted?, #can_be_sorted?, #copy_rich_text_fields_from, #deep_clone, #deep_clone_links, #display_name, #dup, #lazy?, #lazy_path, #restore_design_settings_to_defaults, #rich_text_fields, role, #role, #theme, #to_partial_path

Instance Method Details

#available_blocks_to_addObject



33
34
35
36
37
38
39
# File 'app/models/spree/page_sections/image_with_text.rb', line 33

def available_blocks_to_add
  [
    Spree::PageBlocks::Buttons,
    Spree::PageBlocks::Heading,
    Spree::PageBlocks::Text
  ]
end

#blocks_available?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'app/models/spree/page_sections/image_with_text.rb', line 50

def blocks_available?
  true
end

#can_sort_blocks?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'app/models/spree/page_sections/image_with_text.rb', line 54

def can_sort_blocks?
  true
end

#default_blocksObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/models/spree/page_sections/image_with_text.rb', line 16

def default_blocks
  @default_blocks.presence || [
    Spree::PageBlocks::Heading.new(
      text: Spree.t('page_sections.image_with_text.heading_default'),
      preferred_text_alignment: 'left',
      preferred_bottom_padding: 8,
      preferred_top_padding: 24
    ),
    Spree::PageBlocks::Text.new(
      text: Spree.t('page_sections.image_with_text.text_default', store_name: store.name),
      preferred_text_alignment: 'left',
      preferred_bottom_padding: 16
    ),
    Spree::PageBlocks::Buttons.new(preferred_text_alignment: 'left')
  ]
end


41
42
43
44
45
46
47
48
# File 'app/models/spree/page_sections/image_with_text.rb', line 41

def default_links
  @default_links.presence || [
    Spree::PageLink.new(
      label: Spree.t(:shop_all),
      linkable: theme.pages.find_by(type: 'Spree::Pages::ShopAll')
    )
  ]
end

#icon_nameObject



58
59
60
# File 'app/models/spree/page_sections/image_with_text.rb', line 58

def icon_name
  'photo'
end