Class: CommonComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- CommonComponent
- Includes:
- ApplicationHelper, Pagy::Frontend
- Defined in:
- app/components/common_component.rb
Overview
Common component
Direct Known Subclasses
Admin::Templates::DetailComponent, Admin::Templates::EditComponent, Admin::Templates::FormComponent, Admin::Templates::TemplateComponent, Admin::Users::FormComponent, Admin::Users::UserComponent, Editor::Happenings::DetailComponent, Editor::Users::UserComponent, Events::EventComponent, Events::InfoboxComponent, Groups::GroupComponent, Happenings::BoxComponent, Happenings::DetailComponent, Happenings::HappeningComponent, Layout::FormErrorComponent, Layout::ListBoxedComponent, Layout::ListComponent, Layout::NavbarComponent, Layout::SearchComponent, Tickets::TicketComponent
Instance Method Summary collapse
-
#icon(fas, **opts) ⇒ String
Make an html structure for a bulma/awesome icon.
-
#icon_text(fas, text, **opts) ⇒ String
Make an html structure for a bulma/awesome text-icon.
- #level(ary) ⇒ Object
- #level_item(head, body, id = nil) ⇒ Object
-
#pagy(data) ⇒ Object
make html structure for pagination with pagy.
-
#turbo_yield(body, **opts) ⇒ Object
Shortkut, Make a turbo frame with id yield.
Methods included from ApplicationHelper
#fas_icon, #l_date, #l_long, #l_time, #notifications, #notify, #notify_status, #t_enum
Instance Method Details
#icon(fas, **opts) ⇒ String
Make an html structure for a bulma/awesome icon
Example: icon(‘fas fa-home’) ‘<span class=“icon”><i class=“fas fa-home”></i></span>`
18 19 20 |
# File 'app/components/common_component.rb', line 18 def icon(fas, **opts) content_tag :span, tag.i(class: fas), class: [ "icon", opts[:class] ] end |
#icon_text(fas, text, **opts) ⇒ String
Make an html structure for a bulma/awesome text-icon
Example: icon(‘fas fa-home’, ‘text’) ‘<span class=“text-icon”><span class=“icon”><i class=“fas fa-home”></i></span><span>text</span></span>`
34 35 36 37 38 39 40 |
# File 'app/components/common_component.rb', line 34 def icon_text(fas, text, **opts) content_tag( :span, icon(fas, class: opts[:icon_class]) + content_tag(:span, text), class: [ "icon-text", opts[:class] ] ) end |
#level(ary) ⇒ Object
57 58 59 |
# File 'app/components/common_component.rb', line 57 def level(ary) tag.div(safe_join(ary.map { |e| level_item(*e) }), class: "level infobox") end |
#level_item(head, body, id = nil) ⇒ Object
53 54 55 |
# File 'app/components/common_component.rb', line 53 def level_item(head, body, id = nil) tag.div tag.div(tag.p(head, class: "heading") + tag.p(body, class: "title is-6")), class: "level-item", id: id end |
#pagy(data) ⇒ Object
make html structure for pagination with pagy
43 44 45 |
# File 'app/components/common_component.rb', line 43 def pagy(data) tag.div pagy_bulma_nav(data).html_safe, data: { controller: "pagy-initializer" } end |
#turbo_yield(body, **opts) ⇒ Object
Shortkut, Make a turbo frame with id yield
48 49 50 51 |
# File 'app/components/common_component.rb', line 48 def turbo_yield(body, **opts) = { id: "yield" }.merge(**opts) tag.turbo_frame body, ** end |