Class: Coco::App::Blocks::SlideEditor

Inherits:
Component
  • Object
show all
Includes:
Coco::AppHelper, BookHelper, FormatHelper
Defined in:
app/components/coco/app/blocks/slide_editor/slide_editor.rb

Constant Summary collapse

DEFAULT_LAYOUT =
"one-col-title"

Constants included from Concerns::AcceptsTagAttributes

Concerns::AcceptsTagAttributes::TAG_ATTRIBUTE_NAMES

Instance Method Summary collapse

Methods included from FormatHelper

#format_css_hex_color

Methods included from BookHelper

#coco_editable_slide, #coco_media_slide

Methods included from Coco::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 inherited from Component

#accepts_options?, after_initialize, before_initialize, before_render, new

Methods included from Coco::AlpineHelper

#x_attrs, #x_data

Methods included from TagHelper

#prefix_attr_keys, #random_id, #style_str

Methods included from ComponentHelper

#coco_component, #resolve_component

Methods included from 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(generate_thumbnail: true, **kwargs) ⇒ SlideEditor

Returns a new instance of SlideEditor.



60
61
62
# File 'app/components/coco/app/blocks/slide_editor/slide_editor.rb', line 60

def initialize(generate_thumbnail: true, **kwargs)
  @generate_thumbnail = generate_thumbnail
end

Instance Method Details

#alpine_propsObject



76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'app/components/coco/app/blocks/slide_editor/slide_editor.rb', line 76

def alpine_props
  {
    bg_color: bg_color_css,
    text_color: text_color_css,
    title: title&.value,
    text_1: text_1&.value,
    text_2: text_2&.value,
    image_1: image_1_src,
    image_2: image_2_src,
    bg_image: bg_image_src,
    layout: current_layout
  }
end

#bg_color_cssObject



90
91
92
# File 'app/components/coco/app/blocks/slide_editor/slide_editor.rb', line 90

def bg_color_css
  @bg_color_options[:selected] if @bg_color_options
end

#bg_image_srcObject



98
99
100
# File 'app/components/coco/app/blocks/slide_editor/slide_editor.rb', line 98

def bg_image_src
  @bg_image_options[:src] if @bg_image_options
end

#current_layoutObject



110
111
112
# File 'app/components/coco/app/blocks/slide_editor/slide_editor.rb', line 110

def current_layout
  @layout_options&.fetch(:selected, DEFAULT_LAYOUT) || DEFAULT_LAYOUT
end

#generate_thumbnail?Boolean

Returns:

  • (Boolean)


64
# File 'app/components/coco/app/blocks/slide_editor/slide_editor.rb', line 64

def generate_thumbnail? = @generate_thumbnail

#image_1_srcObject



102
103
104
# File 'app/components/coco/app/blocks/slide_editor/slide_editor.rb', line 102

def image_1_src
  @image_1_options[:src] if @image_1_options
end

#image_2_srcObject



106
107
108
# File 'app/components/coco/app/blocks/slide_editor/slide_editor.rb', line 106

def image_2_src
  @image_2_options[:src] if @image_2_options
end

#slide_argsObject



66
67
68
69
70
71
72
73
74
# File 'app/components/coco/app/blocks/slide_editor/slide_editor.rb', line 66

def slide_args
  {
    bg_image: bg_image_src,
    bg_color_hex: bg_color_css,
    text_color_hex: text_color_css,
    layout: current_layout,
    render_empty: true
  }
end

#text_color_cssObject



94
95
96
# File 'app/components/coco/app/blocks/slide_editor/slide_editor.rb', line 94

def text_color_css
  @text_color_options[:selected] if @text_color_options
end