Class: Coco::Book::EditableSlide

Inherits:
Component
  • Object
show all
Includes:
Concerns::AcceptsOptions, FormatHelper, TagHelper
Defined in:
app/components/coco/book/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 CoreComponentsHelper

#coco_avatar, #coco_badge, #coco_button, #coco_button_group, #coco_button_to, #coco_color_picker_button, #coco_component, #coco_confirm_button, #coco_embed, #coco_fields, #coco_form_for, #coco_form_with, #coco_icon, #coco_image, #coco_image_picker_button, #coco_layout_picker_button, #coco_link, #coco_link_to, #coco_menu_button, #coco_menu_item, #coco_modal, #coco_modal_dialog, #coco_modal_lightbox, #coco_notice, #coco_option_bar, #coco_page, #coco_pager_button, #coco_panel, #coco_placeholder, #coco_prose, #coco_seamless_textarea, #coco_snackbar, #coco_spacer, #coco_stack, #coco_stamp, #coco_svg, #coco_system_banner, #coco_tag, #coco_toast, #coco_toolbar, #resolve_component

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.



51
52
53
54
55
56
57
# File 'app/components/coco/book/editable_slide/editable_slide.rb', line 51

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_hex ⇒ Object (readonly)

Returns the value of attribute bg_color_hex.



49
50
51
# File 'app/components/coco/book/editable_slide/editable_slide.rb', line 49

def bg_color_hex
  @bg_color_hex
end

#bg_image ⇒ Object (readonly)

Returns the value of attribute bg_image.



49
50
51
# File 'app/components/coco/book/editable_slide/editable_slide.rb', line 49

def bg_image
  @bg_image
end

#text_color_hex ⇒ Object (readonly)

Returns the value of attribute text_color_hex.



49
50
51
# File 'app/components/coco/book/editable_slide/editable_slide.rb', line 49

def text_color_hex
  @text_color_hex
end

Instance Method Details

#render? ⇒ Boolean

Returns:

  • (Boolean)


59
60
61
# File 'app/components/coco/book/editable_slide/editable_slide.rb', line 59

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

#slide_styles ⇒ Object



63
64
65
66
67
68
69
# File 'app/components/coco/book/editable_slide/editable_slide.rb', line 63

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