Module: ViewComponent::ButtonComponent

Included in:
UiHelper
Defined in:
app/helpers/view_component/button_component.rb

Defined Under Namespace

Classes: ButtonComponent

Instance Method Summary collapse

Instance Method Details

#button(label: nil, type: 'primary', size: 'md', icon_name: nil, icon_position: 'left', tooltip_text: '', tooltip_position: 'bottom', disabled: false, html_options: {}) ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'app/helpers/view_component/button_component.rb', line 120

def button(
  label: nil,
  type: 'primary',
  size: 'md',
  icon_name: nil,
  icon_position: 'left',
  tooltip_text: '',
  tooltip_position: 'bottom',
  disabled: false,
  html_options: {}
)
  render(
    partial: "view_components/buttons/#{type}",
    locals: {
      label:,
      type:,
      size:,
      icon_name:,
      icon_position:,
      tooltip_text:,
      tooltip_position:,
      disabled:,
      html_options:
    }
  )
end

#button_component(text: '', type: 'solid', size: 'md', colorscheme: 'primary', icon_name: '', icon_position: 'left', tooltip_text: '', tooltip_position: 'bottom', disabled: false, hide_label_in_mobile: false, html_options: {}) ⇒ Object



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'app/helpers/view_component/button_component.rb', line 147

def button_component(
  text: '',
  type: 'solid',
  size: 'md',
  colorscheme: 'primary',
  icon_name: '',
  icon_position: 'left',
  tooltip_text: '',
  tooltip_position: 'bottom',
  disabled: false,
  hide_label_in_mobile: false,
  html_options: {}
)
  button = ButtonComponent.new(
    text:,
    type:,
    size:,
    colorscheme:,
    icon_name:,
    icon_position:,
    tooltip_text:,
    tooltip_position:,
    disabled:,
    hide_label_in_mobile:,
    html_options:
  )

  render(
    partial: 'view_components/button_component/button',
    locals: { button: }
  )
end