Module: Tramway::Helpers::ViewsHelper

Includes:
ComponentHelper
Included in:
ApplicationHelper, BaseComponent
Defined in:
lib/tramway/helpers/views_helper.rb

Overview

Provides view-oriented helpers for ActionView

Instance Method Summary collapse

Methods included from ComponentHelper

#component

Instance Method Details

#tramway_back_buttonObject

rubocop:enable Metrics/ParameterLists



48
49
50
# File 'lib/tramway/helpers/views_helper.rb', line 48

def tramway_back_button
  component 'tailwinds/back_button'
end

#tramway_badge(text:, type: nil, color: nil) ⇒ Object



60
61
62
63
64
65
# File 'lib/tramway/helpers/views_helper.rb', line 60

def tramway_badge(text:, type: nil, color: nil)
  component 'tailwinds/badge',
            text:,
            type:,
            color:
end

#tramway_button(path: nil, text: nil, method: :get, link: false, form_options: {}, **options) ⇒ Object

rubocop:disable Metrics/ParameterLists



42
43
44
45
# File 'lib/tramway/helpers/views_helper.rb', line 42

def tramway_button(path: nil, text: nil, method: :get, link: false, form_options: {}, **options, &)
  component 'tailwinds/button', text:, path:, method:, link:, form_options:, color: options.delete(:color),
                                type: options.delete(:type), size: options.delete(:size), options:, &
end

#tramway_cellObject



37
38
39
# File 'lib/tramway/helpers/views_helper.rb', line 37

def tramway_cell(&)
  component 'tailwinds/table/cell', &
end

#tramway_container(id: nil) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/tramway/helpers/views_helper.rb', line 52

def tramway_container(id: nil, &)
  if id.present?
    component 'tailwinds/containers/narrow', id: id, &
  else
    component 'tailwinds/containers/narrow', &
  end
end

#tramway_flash(text:, type:, **options) ⇒ Object



71
72
73
# File 'lib/tramway/helpers/views_helper.rb', line 71

def tramway_flash(text:, type:, **options)
  component 'tailwinds/flash', text:, type:, options:
end

#tramway_form_for(object, size: :middle, **options) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/tramway/helpers/views_helper.rb', line 9

def tramway_form_for(object, *, size: :middle, **options, &)
  form_for(
    object,
    *,
    **options.merge(builder: Tailwinds::Form::Builder, size:),
    &
  )
end

#tramway_header(headers: nil, columns: nil) ⇒ Object



22
23
24
25
26
27
# File 'lib/tramway/helpers/views_helper.rb', line 22

def tramway_header(headers: nil, columns: nil, &)
  component 'tailwinds/table/header',
            headers:,
            columns:,
            &
end

#tramway_row(**options) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/tramway/helpers/views_helper.rb', line 29

def tramway_row(**options, &)
  component 'tailwinds/table/row',
            cells: options.delete(:cells),
            href: options.delete(:href),
            options:,
            &
end

#tramway_table(**options) ⇒ Object



18
19
20
# File 'lib/tramway/helpers/views_helper.rb', line 18

def tramway_table(**options, &)
  component 'tailwinds/table', options:, &
end

#tramway_title(text: nil) ⇒ Object



67
68
69
# File 'lib/tramway/helpers/views_helper.rb', line 67

def tramway_title(text: nil, &)
  component 'tailwinds/title', text:, &
end