Class: Coco::Book::Blocks::Slides::EditableSlide

Inherits:
Component
  • Object
show all
Includes:
Concerns::AcceptsOptions, FormatHelper, TagHelper
Defined in:
app/components/coco/book/blocks/slides/editable_slide/editable_slide.rb

Constant Summary

Constants included from Concerns::AcceptsTagAttributes

Concerns::AcceptsTagAttributes::TAG_ATTRIBUTE_NAMES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FormatHelper

#format_css_hex_color

Methods included from TagHelper

#prefix_attr_keys, #random_id, #style_str

Methods included from Concerns::AcceptsOptions

#accepted_options, #get_option_group

Methods inherited from Component

#accepts_options?, after_initialize, before_initialize, before_render, new

Methods included from AlpineHelper

#x_attrs, #x_data

Methods included from ComponentHelper

#coco_component, #resolve_component

Methods included from AppHelper

#coco_button, #coco_button_group, #coco_color_picker_button, #coco_confirm_button, #coco_dropdown_button, #coco_fields, #coco_form_button, #coco_form_for, #coco_form_with, #coco_image_picker_button, #coco_layout_picker_button, #coco_link, #coco_menu_button, #coco_notice, #coco_seamless_textarea, #coco_snackbar, #coco_system_banner, #coco_toast, #coco_toolbar

Methods included from Coco::BookHelper

#coco_editable_slide, #coco_media_slide

Methods included from Coco::BaseHelper

#coco_embed, #coco_icon, #coco_image, #coco_placeholder, #coco_svg, #coco_tag

Methods included from Concerns::Translatable

#tt

Methods included from Concerns::HasName

#component_name

Methods included from Concerns::AcceptsTagAttributes

#tag_attrs

Constructor Details

#initialize(bg_image: nil, bg_color_hex: nil, text_color_hex: nil, render_empty: false, **kwargs) ⇒ EditableSlide

Returns a new instance of EditableSlide.



53
54
55
56
57
58
59
# File 'app/components/coco/book/blocks/slides/editable_slide/editable_slide.rb', line 53

def initialize(bg_image: nil, bg_color_hex: nil, text_color_hex: nil, render_empty: false, **kwargs)
  @bg_image = bg_image
  @bg_color_hex = bg_color_hex
  @text_color_hex = text_color_hex
  @has_content = false
  @render_empty = render_empty
end

Instance Attribute Details

#bg_color_hexObject (readonly)

Returns the value of attribute bg_color_hex.



51
52
53
# File 'app/components/coco/book/blocks/slides/editable_slide/editable_slide.rb', line 51

def bg_color_hex
  @bg_color_hex
end

#bg_imageObject (readonly)

Returns the value of attribute bg_image.



51
52
53
# File 'app/components/coco/book/blocks/slides/editable_slide/editable_slide.rb', line 51

def bg_image
  @bg_image
end

#text_color_hexObject (readonly)

Returns the value of attribute text_color_hex.



51
52
53
# File 'app/components/coco/book/blocks/slides/editable_slide/editable_slide.rb', line 51

def text_color_hex
  @text_color_hex
end

Instance Method Details

#render?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'app/components/coco/book/blocks/slides/editable_slide/editable_slide.rb', line 61

def render?
  @has_content || bg_image.present? || @render_empty == true
end

#slide_stylesObject



65
66
67
68
69
70
71
# File 'app/components/coco/book/blocks/slides/editable_slide/editable_slide.rb', line 65

def slide_styles
  style_str({
    background_color: format_css_hex_color(bg_color_hex),
    color: format_css_hex_color(text_color_hex),
    background_image: ("url('#{bg_image}')" if bg_image)
  })
end