Sha256: 6cad2f4f00e9af3be50dc0db2882469b4efc6941d29a55158b49bd5317ea113f
Contents?: true
Size: 1.89 KB
Versions: 5
Compression:
Stored size: 1.89 KB
Contents
module Coco module Book class EditableSlide < Coco::Component include Concerns::AcceptsOptions include Coco::TagHelper include Coco::FormatHelper accepts_option :layout, from: %w[one-col-title one-col-text one-col-media two-col-text two-col-media two-col-mixed], default: "one-col-title" renders_one :title, ->(&block) do @has_content = true block.call end renders_one :text_1, ->(&block) do @has_content = true block.call end renders_one :text_2, ->(&block) do @has_content = true block.call end renders_one :image_1, ->(src: nil, &block) do @has_content = true block ? block.call : tag.img(src: src) end renders_one :image_2, ->(src: nil, &block) do @has_content = true block ? block.call : tag.img(src: src) end before_initialize do |kwargs| if kwargs[:layout] kwargs[:layout] = kwargs[:layout].to_s.tr("_", "-") kwargs[:layout] = "one-col-title" if kwargs[:layout] == "basic" # handle legacy layout name end kwargs 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
Version data entries
5 entries across 5 versions & 1 rubygems