Class: Dedalus::PatternLibrary::LibrarySectionTab

Inherits:
Molecule show all
Defined in:
lib/dedalus/pattern_library/molecules/library_section_tab.rb

Instance Attribute Summary collapse

Attributes inherited from Element

#height_percent, #margin, #padding, #position, #width, #width_percent

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Element

#big_font, #code_font, #draw_bounding_box, #font, #huge_font, #initialize, #tiny_font, #view, #window

Constructor Details

This class inherits a constructor from Dedalus::Element

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



4
5
6
# File 'lib/dedalus/pattern_library/molecules/library_section_tab.rb', line 4

def description
  @description
end

#highlightObject

Returns the value of attribute highlight.



4
5
6
# File 'lib/dedalus/pattern_library/molecules/library_section_tab.rb', line 4

def highlight
  @highlight
end

#iconObject

Returns the value of attribute icon.



4
5
6
# File 'lib/dedalus/pattern_library/molecules/library_section_tab.rb', line 4

def icon
  @icon
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/dedalus/pattern_library/molecules/library_section_tab.rb', line 4

def name
  @name
end

#scaleObject

Returns the value of attribute scale.



4
5
6
# File 'lib/dedalus/pattern_library/molecules/library_section_tab.rb', line 4

def scale
  @scale
end

#section_colorObject

Returns the value of attribute section_color.



4
5
6
# File 'lib/dedalus/pattern_library/molecules/library_section_tab.rb', line 4

def section_color
  @section_color
end

Class Method Details

.descriptionObject



44
45
46
# File 'lib/dedalus/pattern_library/molecules/library_section_tab.rb', line 44

def self.description
  "navigational tab"
end

.example_dataObject



48
49
50
51
52
53
54
55
56
# File 'lib/dedalus/pattern_library/molecules/library_section_tab.rb', line 48

def self.example_data
  {
    icon: :house,
    name: "Welcome",
    description: "Hello world (links to Welcome)",
    highlight: false,
    section_color: 'gray'
  }
end

Instance Method Details

#background_colorObject



15
16
17
18
# File 'lib/dedalus/pattern_library/molecules/library_section_tab.rb', line 15

def background_color
  bg = Palette.decode_color(section_color)
  self.highlight ? bg.lighten : bg
end

#clickObject



20
21
22
# File 'lib/dedalus/pattern_library/molecules/library_section_tab.rb', line 20

def click
  view.route_to(name)
end

#description_elementObject



40
41
42
# File 'lib/dedalus/pattern_library/molecules/library_section_tab.rb', line 40

def description_element
  TinyText.new(text: description)
end

#heightObject



28
29
30
# File 'lib/dedalus/pattern_library/molecules/library_section_tab.rb', line 28

def height
  @height ||= 80
end

#hoverObject



10
11
12
13
# File 'lib/dedalus/pattern_library/molecules/library_section_tab.rb', line 10

def hover
  p [ :hovering_on, section: name ]
  @scale = 0.2
end

#icon_elementObject



32
33
34
# File 'lib/dedalus/pattern_library/molecules/library_section_tab.rb', line 32

def icon_element
  Elements::Icon.for(icon, padding: 10)
end

#showObject



6
7
8
# File 'lib/dedalus/pattern_library/molecules/library_section_tab.rb', line 6

def show
  Container.new([[icon_element, [ title_element, description_element ]]], padding: 16)
end

#title_elementObject



36
37
38
# File 'lib/dedalus/pattern_library/molecules/library_section_tab.rb', line 36

def title_element
  Elements::Heading.new(text: name)
end