Class: Coco::App::SlideEditor

Inherits:
Component
  • Object
show all
Includes:
Coco::AppComponentsHelper, BookComponentsHelper, FormatHelper
Defined in:
app/components/coco/app/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 BookComponentsHelper

#coco_editable_slide, #coco_media_slide

Methods included from Coco::AppComponentsHelper

#coco_app_header, #coco_app_layout, #coco_contact_callout, #coco_faqs, #coco_plan_card, #coco_plan_confirmation, #coco_plan_picker, #coco_sidebar_nav, #coco_sidebar_nav_menu

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

Returns a new instance of SlideEditor.



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

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

Instance Method Details

#alpine_propsObject



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

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



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

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

#bg_image_srcObject



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

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

#current_layoutObject



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

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

#generate_thumbnail?Boolean

Returns:

  • (Boolean)


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

def generate_thumbnail? = @generate_thumbnail

#image_1_srcObject



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

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

#image_2_srcObject



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

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

#slide_argsObject



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

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



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

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