class Dedalus::PatternLibrary::LibraryEntry
Attributes
color[RW]
description[RW]
item[RW]
items[RW]
show_table[RW]
subtitle[RW]
title[RW]
Public Class Methods
description()
click to toggle source
# File lib/dedalus/pattern_library/organisms/library_entry.rb, line 49 def self.description "An entry in a library" end
example_data()
click to toggle source
# File lib/dedalus/pattern_library/organisms/library_entry.rb, line 53 def self.example_data { title: "Welcome", subtitle: "world", description: "Welcome to this section", color: "darkblue", items: [ LibraryItemExample.example_data ] } end
from_item(item)
click to toggle source
# File lib/dedalus/pattern_library/organisms/library_entry.rb, line 6 def self.from_item(item) new(title: item[:name], subtitle: item[:description], item: item) end
Public Instance Methods
background_color()
click to toggle source
# File lib/dedalus/pattern_library/organisms/library_entry.rb, line 41 def background_color if color Palette.decode_color(color).lighten elsif item && item[:color] Palette.decode_color(item[:color]) end end
library_items()
click to toggle source
# File lib/dedalus/pattern_library/organisms/library_entry.rb, line 18 def library_items if items if show_table PeriodicTable.new(elements: items) else # items items.map do |name:, description:, item_class_name:, item_data:, kind:, color:| PeriodicTableEntry.new( element_name: name, color: color, kind: kind) end end elsif item LibraryItemExample.new(item) else [] end end
padding()
click to toggle source
# File lib/dedalus/pattern_library/organisms/library_entry.rb, line 37 def padding @padding ||= 40 end
show()
click to toggle source
# File lib/dedalus/pattern_library/organisms/library_entry.rb, line 10 def show [ HugeText.new(text: title), LargeText.new(text: subtitle), TinyText.new(text: description) ] + [ library_items ] end