module Coco module App module Blocks class SlideEditor < Coco::Component include Coco::AppHelper include Coco::BookHelper include Coco::FormatHelper renders_one :form renders_one :title, ->(value = nil, **textarea_options) do Coco::App::Elements::SeamlessTextarea.new(**textarea_options, value: value, multiline: false, focus: true, data: {role: "title-editor"}, x: {modelable: "value", model: "title"}) end renders_one :text_1, ->(value = nil, **textarea_options) do Coco::App::Elements::SeamlessTextarea.new(**textarea_options, value: value, multiline: false, data: {role: "text-1-editor"}, x: {modelable: "value", model: "text1"}) end renders_one :bg_color, ->(value = nil, **input_options) do @bg_color_options = {selected: value, **input_options} end renders_one :text_color, ->(value = nil, **input_options) do @text_color_options = {selected: value, **input_options} end renders_one :bg_image, ->(src = nil, **input_options) do @bg_image_options = {src: src, **input_options} end # renders_one :thumbnail, ->(name: :thumbnail_image, **input_options) do # add_field(:thumbnail, name, input_options) # end def slide_args { bg_image: bg_image_src, bg_color_hex: bg_color_css, text_color_hex: text_color_css, render_empty: true } end def alpine_props { bg_color: bg_color_css, text_color: text_color_css, title: title&.value, text_1: text_1&.value, bg_image: bg_image_src } end def bg_color_css @bg_color_options[:selected] if @bg_color_options end def text_color_css @text_color_options[:selected] if @text_color_options end def bg_image_src @bg_image_options[:src] if @bg_image_options end end end end end