Class: Arara::StepComponent

Inherits:
ActionView::Component::Base
  • Object
show all
Includes:
BaseComponent
Defined in:
app/components/arara/step_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BaseComponent

#default_data_controller, #default_html_tag, #html_class, #html_content, #html_data, #html_options, #html_tag, included

Constructor Details

#initialize(title: "", sub_title: nil, orientation: "horizontal", alternative_label: false, active: false, completed: false, disabled: false, editable: false, link: nil, order: 0, connector: false, **kw) ⇒ StepComponent

Returns a new instance of StepComponent.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/components/arara/step_component.rb', line 5

def initialize(title: "", sub_title: nil, orientation: "horizontal", alternative_label: false, active: false, completed: false, disabled: false, editable: false, link: nil, order: 0, connector: false, **kw)
  @orientation = orientation
  @alternative_label = alternative_label
  @active = active
  @completed = completed
  @disabled = disabled
  @editable = editable
  @link = link
  @title = title
  @sub_title = sub_title
  @order = order
  @connector = connector
  super(tag: "div", **kw)
end

Instance Attribute Details

#activeObject (readonly)

Returns the value of attribute active.



3
4
5
# File 'app/components/arara/step_component.rb', line 3

def active
  @active
end

#alternative_labelObject (readonly)

Returns the value of attribute alternative_label.



3
4
5
# File 'app/components/arara/step_component.rb', line 3

def alternative_label
  @alternative_label
end

#completedObject (readonly)

Returns the value of attribute completed.



3
4
5
# File 'app/components/arara/step_component.rb', line 3

def completed
  @completed
end

#connectorObject (readonly)

Returns the value of attribute connector.



3
4
5
# File 'app/components/arara/step_component.rb', line 3

def connector
  @connector
end

#disabledObject (readonly)

Returns the value of attribute disabled.



3
4
5
# File 'app/components/arara/step_component.rb', line 3

def disabled
  @disabled
end

#editableObject (readonly)

Returns the value of attribute editable.



3
4
5
# File 'app/components/arara/step_component.rb', line 3

def editable
  @editable
end

Returns the value of attribute link.



3
4
5
# File 'app/components/arara/step_component.rb', line 3

def link
  @link
end

#orderObject (readonly)

Returns the value of attribute order.



3
4
5
# File 'app/components/arara/step_component.rb', line 3

def order
  @order
end

#orientationObject (readonly)

Returns the value of attribute orientation.



3
4
5
# File 'app/components/arara/step_component.rb', line 3

def orientation
  @orientation
end

#sub_titleObject (readonly)

Returns the value of attribute sub_title.



3
4
5
# File 'app/components/arara/step_component.rb', line 3

def sub_title
  @sub_title
end

#titleObject (readonly)

Returns the value of attribute title.



3
4
5
# File 'app/components/arara/step_component.rb', line 3

def title
  @title
end

Instance Method Details

#connector_line_optionsObject



91
92
93
94
95
# File 'app/components/arara/step_component.rb', line 91

def connector_line_options
  classes = %w(MuiStepConnector-line)
  classes.push('MuiStepConnector-lineHorizontal') if orientation == "horizontal"
  { class: classes.join(" ") }
end

#connector_root_optionsObject



82
83
84
85
86
87
88
89
# File 'app/components/arara/step_component.rb', line 82

def connector_root_options
  classes = %w(MuiStepConnector-root)
  classes.push('MuiStepConnector-horizontal') if orientation == "horizontal"
  classes.push('MuiStepConnector-vertical') if orientation == "vertical"
  classes.push('MuiStepConnector-alternativeLabel') if alternative_label
  classes.push('MuiStepConnector-active')
  { class: classes.join(" ") }
end

#default_html_classObject



20
21
22
23
24
25
26
27
# File 'app/components/arara/step_component.rb', line 20

def default_html_class
  classes = %w(MuiStep-root)
  classes.push("MuiStep-horizontal") if orientation == "horizontal"
  classes.push("MuiStep-vertical") if orientation == "vertical"
  classes.push("MuiStep-alternativeLabel") if alternative_label
  classes.push("MuiStep-completed") if completed
  classes.join(" ")
end

#has_connector?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'app/components/arara/step_component.rb', line 78

def has_connector?
  connector
end

#has_vertical_content?Boolean

Returns:

  • (Boolean)


97
98
99
# File 'app/components/arara/step_component.rb', line 97

def has_vertical_content?
  orientation == "vertical" && active && !html_content.empty?
end

#icon_container_optionsObject



39
40
41
42
43
44
45
# File 'app/components/arara/step_component.rb', line 39

def icon_container_options
  classes = %w(MuiStepLabel-iconContainer)
  classes.push("MuiStepLabel-alternativeLabel") if alternative_label
  {
    class: classes.join(" "),
  }
end

#icon_optionsObject



47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/components/arara/step_component.rb', line 47

def icon_options
  classes = %w(MuiSvgIcon-root MuiStepIcon-root)
  classes.push("MuiStepIcon-completed") if completed
  classes.push("MuiStepIcon-active") if active
  {
    class: classes.join(" "),
    focusable: false,
    'view-box': "0 0 24 24",
    'aria-hidden': true,
    role: "presentation"
  }
end

#icon_tagObject



60
61
62
63
64
65
66
67
# File 'app/components/arara/step_component.rb', line 60

def icon_tag
  if completed
    return (:path, nil, d: "M12 0a12 12 0 1 0 0 24 12 12 0 0 0 0-24zm-2 17l-5-5 1.4-1.4 3.6 3.6 7.6-7.6L19 8l-9 9z")
  end

  (:circle, nil, cx: 12, cy: 12, r: 12) + 
  (:text, order, class: "MuiStepIcon-text", x: "12", y: "16", 'text-anchor': "middle")
end

#label_root_optionsObject



29
30
31
32
33
34
35
36
37
# File 'app/components/arara/step_component.rb', line 29

def label_root_options
  classes = %w(MuiStepLabel-root)
  classes.push("MuiStepLabel-horizontal") if orientation == "horizontal"
  classes.push("MuiStepLabel-vertical") if orientation == "vertical"
  classes.push("MuiStepLabel-alternativeLabel") if alternative_label
  {
    class: classes.join(" ")
  }
end

#step_label_optionsObject



69
70
71
72
73
74
75
76
# File 'app/components/arara/step_component.rb', line 69

def step_label_options
  classes = %w(MuiTypography-root MuiStepLabel-label)
  classes.push('MuiStepLabel-alternativeLabel') if alternative_label
  classes.push('MuiStepLabel-completed') if completed
  classes.push('MuiStepLabel-active') if active
  classes.push('MuiTypography-body2 MuiTypography-displayBlock')
  { class: classes.join(" ") }
end