Sha256: e421ed0c5c68f47e9827eca73b513319803784a78d4c5e5dd0b05a87cc544905
Contents?: true
Size: 1.56 KB
Versions: 6
Compression:
Stored size: 1.56 KB
Contents
# frozen_string_literal: true class Scarpe class GlimmerLibUIPara < GlimmerLibUIWidget SIZES = { inscription: 10, ins: 10, para: 12, caption: 14, tagline: 18, subtitle: 26, title: 34, banner: 48, }.freeze private_constant :SIZES def initialize(properties) @properties = properties super end def properties_changed(changes) items = changes.delete("text_items") if items # we might need this to extend para in new prs? return end super end def display <<~GLIMMER_CODE area { text { string "#{@properties["text_items"].join(", ")}" } } GLIMMER_CODE end def items_to_display_children(items) return [] if items.nil? items.map do |item| if item.is_a?(String) item else GlimmerLibUIDisplayService.instance.query_display_widget_for(item) end end end private # hangon for future para prs def child_markup items_to_display_children(@text_items).map do |child| if child.respond_to?(:to_html) child.to_html else child end end.join end def options @html_attributes.merge(id: html_id, style: style) end def style { "color" => @stroke, "font-size" => font_size, }.compact end def font_size font_size = @size.is_a?(Symbol) ? SIZES[@size] : @size Dimensions.length(font_size) end end end
Version data entries
6 entries across 6 versions & 2 rubygems