Sha256: e7d84637781215eac75d90b1b85d89dcf2af12df100f3ddaff7645609938120f

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 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 || @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.2 app/components/coco/book/blocks/slides/editable_slide/editable_slide.rb
coveragebook_components-0.5.1 app/components/coco/book/blocks/slides/editable_slide/editable_slide.rb
coveragebook_components-0.5.0 app/components/coco/book/blocks/slides/editable_slide/editable_slide.rb