Sha256: 2780732967b9f82bf812afb303ab1cec9f502b3f931c91771110d695e6c8b663

Contents?: true

Size: 1.33 KB

Versions: 3

Compression:

Stored size: 1.33 KB

Contents

module Coco
  module Book
    module Blocks
      module Slides
        class EditableSlide < Coco::Component
          include Concerns::AcceptsOptions
          include Coco::TagHelper
          include Coco::FormatHelper

          accepts_option :layout, from: %w[basic], default: "basic"

          renders_one :title,
            ->(&block) do
              @has_content = true
              block.call
            end

          renders_one :text_1,
            ->(&block) do
              @has_content = true
              block.call
            end

          attr_reader :bg_image, :text_color_hex, :bg_color_hex

          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

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

          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
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
coveragebook_components-0.5.5 app/components/coco/book/blocks/slides/editable_slide/editable_slide.rb
coveragebook_components-0.5.4 app/components/coco/book/blocks/slides/editable_slide/editable_slide.rb
coveragebook_components-0.5.3 app/components/coco/book/blocks/slides/editable_slide/editable_slide.rb