Module: IronAdmin::ThemeHelper

Included in:
ApplicationHelper, Dashboards::RecentTableComponent, Layout::SidebarComponent
Defined in:
app/helpers/iron_admin/theme_helper.rb

Overview

Helper methods for accessing themed CSS classes.

Provides convenience methods for generating Tailwind class strings based on the current theme configuration.

Instance Method Summary collapse

Instance Method Details

#cp_badge_countString

Returns Badge count classes.

Returns:

  • (String)

    Badge count classes



123
124
125
# File 'app/helpers/iron_admin/theme_helper.rb', line 123

def cp_badge_count
  "inline-flex items-center justify-center h-5 min-w-5 px-1 rounded-full #{t.badge_count} text-xs font-bold"
end

#cp_body_textString

Returns Body text classes.

Returns:

  • (String)

    Body text classes



164
165
166
# File 'app/helpers/iron_admin/theme_helper.rb', line 164

def cp_body_text
  t.body_text
end

#cp_btn_dangerString

Returns Danger button classes.

Returns:

  • (String)

    Danger button classes



34
35
36
# File 'app/helpers/iron_admin/theme_helper.rb', line 34

def cp_btn_danger
  "px-4 py-2 #{t.border_radius} #{t.btn_danger}"
end

#cp_btn_filter_applyString

Returns Filter apply button classes.

Returns:

  • (String)

    Filter apply button classes



128
129
130
131
# File 'app/helpers/iron_admin/theme_helper.rb', line 128

def cp_btn_filter_apply
  "inline-flex items-center px-3 #{t.border_radius} #{t.btn_primary} " \
    "text-sm font-medium transition duration-150 ease-in-out py-1.5"
end

#cp_btn_ghostString

Returns Ghost button classes.

Returns:

  • (String)

    Ghost button classes



39
40
41
# File 'app/helpers/iron_admin/theme_helper.rb', line 39

def cp_btn_ghost
  "inline-flex items-center gap-2 px-4 py-2 #{t.border_radius} #{t.btn_ghost}"
end

#cp_btn_primaryString

Returns Primary button classes.

Returns:

  • (String)

    Primary button classes



16
17
18
19
# File 'app/helpers/iron_admin/theme_helper.rb', line 16

def cp_btn_primary
  "inline-flex items-center px-4 py-2 #{t.border_radius} #{t.btn_primary} " \
    "transition duration-150 ease-in-out"
end

#cp_btn_primary_lgString

Returns Large primary button classes.

Returns:

  • (String)

    Large primary button classes



22
23
24
25
# File 'app/helpers/iron_admin/theme_helper.rb', line 22

def cp_btn_primary_lg
  "inline-flex items-center px-5 text-sm font-medium #{t.border_radius} shadow-sm " \
    "#{t.btn_primary} transition duration-150 ease-in-out cursor-pointer py-2.5"
end

#cp_btn_secondaryString

Returns Secondary button classes.

Returns:

  • (String)

    Secondary button classes



28
29
30
31
# File 'app/helpers/iron_admin/theme_helper.rb', line 28

def cp_btn_secondary
  "inline-flex items-center px-5 text-sm font-medium #{t.border_radius} shadow-sm " \
    "#{t.btn_secondary} transition duration-150 ease-in-out py-2.5"
end

#cp_cardString

Returns Card classes.

Returns:

  • (String)

    Card classes



159
160
161
# File 'app/helpers/iron_admin/theme_helper.rb', line 159

def cp_card
  "#{t.card_bg} #{t.border_radius} #{t.card_shadow}"
end

#cp_checkbox_classString

Returns Checkbox classes.

Returns:

  • (String)

    Checkbox classes



83
84
85
86
87
88
89
90
91
# File 'app/helpers/iron_admin/theme_helper.rb', line 83

def cp_checkbox_class
  "h-4.5 w-4.5 appearance-none rounded border #{t.input_border} #{t.card_bg} shadow-sm transition duration-150 " \
    "ease-in-out #{t.checkbox_checked} " \
    "checked:bg-[url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg" \
    "%22%20viewBox%3D%220%200%2020%2020%22%20fill%3D%22white%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20d%3D%22" \
    "M16.707%205.293a1%201%200%20010%201.414l-8%208a1%201%200%2001-1.414%200l-4-4a1%201%200%20011.414-1.414L8" \
    "%2012.586l7.293-7.293a1%201%200%20011.414%200z%22%20clip-rule%3D%22evenodd%22%2F%3E%3C%2Fsvg%3E')] " \
    "bg-[length:100%_100%] bg-center bg-no-repeat focus:ring-offset-1 cursor-pointer"
end

#cp_file_input_classString

Returns File input classes.

Returns:

  • (String)

    File input classes



194
195
196
197
198
# File 'app/helpers/iron_admin/theme_helper.rb', line 194

def cp_file_input_class
  "block w-full text-sm #{t.body_text} file:mr-4 file:py-2 file:px-4 file:rounded-lg file:border-0 " \
    "file:text-sm file:font-medium file:bg-gray-100 file:text-gray-700 hover:file:bg-gray-200 " \
    "file:cursor-pointer cursor-pointer"
end

#cp_filter_input_classString

Returns Filter input classes.

Returns:

  • (String)

    Filter input classes



94
95
96
97
# File 'app/helpers/iron_admin/theme_helper.rb', line 94

def cp_filter_input_class
  "block w-full appearance-none #{t.border_radius} border #{t.input_border} #{t.card_bg} px-3 py-2 text-sm " \
    "#{t.body_text} shadow-sm outline-none transition duration-150 ease-in-out #{t.input_focus}"
end

#cp_focusString

Returns Focus ring classes.

Returns:

  • (String)

    Focus ring classes



54
55
56
# File 'app/helpers/iron_admin/theme_helper.rb', line 54

def cp_focus
  t.input_focus
end

#cp_headingString

Returns Heading classes.

Returns:

  • (String)

    Heading classes



154
155
156
# File 'app/helpers/iron_admin/theme_helper.rb', line 154

def cp_heading
  "#{t.heading_weight} #{t.font_family}".strip
end

#cp_input_classString

Returns Text input classes.

Returns:

  • (String)

    Text input classes



59
60
61
62
# File 'app/helpers/iron_admin/theme_helper.rb', line 59

def cp_input_class
  "block w-full appearance-none #{t.border_radius} border #{t.input_border} #{t.card_bg} px-3.5 py-2.5 text-sm " \
    "#{t.body_text} shadow-sm outline-none placeholder:text-gray-400 transition duration-150 ease-in-out #{t.input_focus}"
end

#cp_label_textString

Returns Label text classes.

Returns:

  • (String)

    Label text classes



174
175
176
# File 'app/helpers/iron_admin/theme_helper.rb', line 174

def cp_label_text
  t.label_text
end

Returns Link classes.

Returns:

  • (String)

    Link classes



44
45
46
# File 'app/helpers/iron_admin/theme_helper.rb', line 44

def cp_link
  t.link
end

Returns Muted link classes.

Returns:

  • (String)

    Muted link classes



49
50
51
# File 'app/helpers/iron_admin/theme_helper.rb', line 49

def cp_link_muted
  t.link_muted
end

#cp_muted_textString

Returns Muted text classes.

Returns:

  • (String)

    Muted text classes



169
170
171
# File 'app/helpers/iron_admin/theme_helper.rb', line 169

def cp_muted_text
  t.muted_text
end

#cp_navbar_search_classString

Returns Navbar search input classes.

Returns:

  • (String)

    Navbar search input classes



106
107
108
109
110
# File 'app/helpers/iron_admin/theme_helper.rb', line 106

def cp_navbar_search_class
  "block w-full appearance-none #{t.border_radius} border #{t.input_border} #{t.navbar_search_bg} pl-10 pr-4 py-2 text-sm " \
    "#{t.body_text} shadow-sm outline-none transition duration-150 ease-in-out placeholder:text-gray-400 " \
    "#{t.input_focus} #{t.navbar_search_focus_bg}"
end

#cp_scope_activeString

Returns Active scope tab classes.

Returns:

  • (String)

    Active scope tab classes



113
114
115
# File 'app/helpers/iron_admin/theme_helper.rb', line 113

def cp_scope_active
  t.scope_active
end

#cp_scope_inactiveString

Returns Inactive scope tab classes.

Returns:

  • (String)

    Inactive scope tab classes



118
119
120
# File 'app/helpers/iron_admin/theme_helper.rb', line 118

def cp_scope_inactive
  t.scope_inactive
end

#cp_search_classString

Returns Search input classes.

Returns:

  • (String)

    Search input classes



100
101
102
103
# File 'app/helpers/iron_admin/theme_helper.rb', line 100

def cp_search_class
  "block w-full appearance-none #{t.border_radius} border #{t.input_border} #{t.card_bg} pl-10 pr-4 py-2 text-sm " \
    "#{t.body_text} shadow-sm outline-none placeholder:text-gray-400 transition duration-150 ease-in-out #{t.input_focus}"
end

#cp_select_classString

Returns Select input classes.

Returns:

  • (String)

    Select input classes



65
66
67
68
69
70
71
72
73
# File 'app/helpers/iron_admin/theme_helper.rb', line 65

def cp_select_class
  "block w-full appearance-none #{t.border_radius} border #{t.input_border} #{t.card_bg} px-3.5 py-2.5 pr-10 text-sm " \
    "#{t.body_text} shadow-sm outline-none transition duration-150 ease-in-out #{t.input_focus} " \
    "bg-[url('data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20" \
    "viewBox%3D%220%200%2020%2020%22%20fill%3D%22%236b7280%22%3E%3Cpath%20fill-rule%3D%22evenodd%22%20d%3D%22" \
    "M5.23%207.21a.75.75%200%20011.06.02L10%2011.168l3.71-3.938a.75.75%200%20111.08%201.04l-4.25%204.5a.75.75" \
    "%200%2001-1.08%200l-4.25-4.5a.75.75%200%2001.02-1.06z%22%20clip-rule%3D%22evenodd%22%2F%3E%3C%2Fsvg%3E')] " \
    "bg-[length:1.25rem_1.25rem] bg-[position:right_0.5rem_center] bg-no-repeat"
end

#cp_sidebar_bgString

Returns Sidebar background classes.

Returns:

  • (String)

    Sidebar background classes



134
135
136
# File 'app/helpers/iron_admin/theme_helper.rb', line 134

def cp_sidebar_bg
  t.sidebar_bg
end

#cp_sidebar_group_labelString

Returns Sidebar group label classes.

Returns:

  • (String)

    Sidebar group label classes



149
150
151
# File 'app/helpers/iron_admin/theme_helper.rb', line 149

def cp_sidebar_group_label
  t.sidebar_group_label
end

Returns Sidebar link classes.

Returns:

  • (String)

    Sidebar link classes



144
145
146
# File 'app/helpers/iron_admin/theme_helper.rb', line 144

def cp_sidebar_link
  "#{t.sidebar_link} #{t.sidebar_link_hover}"
end

#cp_sidebar_titleString

Returns Sidebar title classes.

Returns:

  • (String)

    Sidebar title classes



139
140
141
# File 'app/helpers/iron_admin/theme_helper.rb', line 139

def cp_sidebar_title
  t.sidebar_title
end

#cp_table_borderString

Returns Table border classes.

Returns:

  • (String)

    Table border classes



189
190
191
# File 'app/helpers/iron_admin/theme_helper.rb', line 189

def cp_table_border
  t.table_border
end

#cp_table_header_bgString

Returns Table header background classes.

Returns:

  • (String)

    Table header background classes



179
180
181
# File 'app/helpers/iron_admin/theme_helper.rb', line 179

def cp_table_header_bg
  t.table_header_bg
end

#cp_table_row_hoverString

Returns Table row hover classes.

Returns:

  • (String)

    Table row hover classes



184
185
186
# File 'app/helpers/iron_admin/theme_helper.rb', line 184

def cp_table_row_hover
  t.table_row_hover
end

#cp_textarea_classString

Returns Textarea classes.

Returns:

  • (String)

    Textarea classes



76
77
78
79
80
# File 'app/helpers/iron_admin/theme_helper.rb', line 76

def cp_textarea_class
  "block w-full appearance-none #{t.border_radius} border #{t.input_border} #{t.card_bg} px-3.5 py-2.5 text-sm " \
    "#{t.body_text} shadow-sm outline-none placeholder:text-gray-400 transition duration-150 ease-in-out " \
    "#{t.input_focus} resize-y"
end

#tIronAdmin::Configuration::Theme

Returns the current theme configuration.



11
12
13
# File 'app/helpers/iron_admin/theme_helper.rb', line 11

def t
  IronAdmin.configuration.theme
end