Class: Avo::BaseComponent

Inherits:
ViewComponent::Base
  • Object
show all
Extended by:
PropInitializer::Properties
Includes:
ApplicationHelper, Concerns::FindAssociationField, Turbo::FramesHelper
Defined in:
app/components/avo/base_component.rb

Direct Known Subclasses

ActionsComponent, AlertComponent, AssetManager::JavascriptComponent, AssetManager::StylesheetComponent, BacktraceAlertComponent, BlankFieldComponent, BreadcrumbElementComponent, BreadcrumbsComponent, ButtonComponent, ClipboardComponent, CoverComponent, Debug::StatusComponent, DescriptionListComponent, DeveloperWarningComponent, DiscreetInformationComponent, DividerComponent, EmptyStateComponent, FieldWrapperComponent, Fields::Common::BooleanCheckComponent, Fields::Common::BooleanGroupComponent, Fields::Common::Files::ControlsComponent, Fields::Common::Files::ListViewerComponent, Fields::Common::Files::ViewType::GridItemComponent, Fields::Common::GravatarViewerComponent, Fields::Common::HeadingComponent, Fields::Common::KeyValueComponent, Fields::Common::NestedFieldComponent, Fields::Common::ProgressBarComponent, Fields::Common::StarsComponent, Fields::Common::StatusViewerComponent, Fields::EditComponent, Fields::IndexComponent, Fields::ShowComponent, Fields::TagsField::TagComponent, FiltersComponent, FlashAlertsComponent, Index::FieldWrapperComponent, Index::GridCoverEmptyStateComponent, Index::GridItemComponent, Index::TableRowComponent, Items::VisibleItemsComponent, KeyboardShortcutsComponent, LoadingComponent, MediaLibrary::ItemDetailsComponent, MediaLibrary::ListComponent, MediaLibrary::ListItemComponent, ModalComponent, PaginatorComponent, PanelNameComponent, ProfileItemComponent, ReferrerParamsComponent, ResourceComponent, ResourceListingComponent, ResourceSidebarComponent, RowComponent, RowSelectorComponent, SearchOverlayComponent, Sidebar::BaseItemComponent, Sidebar::HeadingComponent, Sidebar::LinkComponent, SidebarComponent, SidebarProfileComponent, TabContentComponent, TabGroupComponent, TurboFrameWrapperComponent, UI::AvatarComponent, UI::BadgeComponent, UI::CardComponent, UI::CardComponent::BodyComponent, UI::DropdownCardComponent, UI::DropdownComponent, UI::DropdownMenuComponent, UI::FileUploadInputComponent, UI::FileUploadItemComponent, UI::IconButtonComponent, UI::PanelComponent, UI::PanelHeaderComponent, UI::SearchInputComponent, UI::Tabs::TabComponent, UI::Tabs::TabsComponent, ViewTypes::BaseViewTypeComponent

Constant Summary

Constants included from Concerns::FindAssociationField

Concerns::FindAssociationField::ASSOCIATIONS

Instance Method Summary collapse

Methods included from ApplicationHelper

#a_button, #a_link, #body_classes, #button_classes, #chart_color, #container_classes, #d, #decode_filter_params, #e, #editor_file_path, #editor_url, #empty_state, #encode_filter_params, #frame_id, #get_model_class, #input_classes, #mount_path, #number_to_social, #possibly_rails_authentication?, #render_license_warning, #root_path_without_url, #rtl?, #text_direction, #ui, #wrap_in_modal

Methods included from ResourcesHelper

#field_wrapper, #filter_wrapper, #index_field_wrapper, #item_selector_data_attributes, #record_path, #record_title, #resource_for_record, #resource_grid, #resource_show_path, #resource_table

Methods included from Concerns::FindAssociationField

#find_association_field

Instance Method Details

#component_nameObject



16
# File 'app/components/avo/base_component.rb', line 16

def component_name = self.class.name.to_s.underscore

#hotkey_badge(hotkey, **html_options) ⇒ Object

Renders a <kbd> badge for a hotkey string. Supports modifier tokens rendered in a friendly OS-aware way.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/components/avo/base_component.rb', line 20

def hotkey_badge(hotkey, **html_options)
  return unless Avo.configuration.hotkeys[:enabled] && Avo.configuration.hotkeys[:show_key_badges]

  # `@github/hotkey` uses:
  # - `+` for modifier combos (e.g. "Mod+Enter")
  # - spaces for sequences/alternatives (e.g. "g n" or "Meta+Enter Control+Enter")
  #
  # Render key parts for the badge, mapping supported modifiers to OS-aware glyphs.
  keys = hotkey.to_s.split(/[+\s]+/).reject(&:blank?)

  first_key = keys.first
  return if first_key.blank?

  html_options[:class] = class_names("hotkey-badge", html_options[:class])

  (:span, **html_options) do
    # Render multiple keys (e.g. "g n") inside a wrapper so any provided
    # classes (like `ms-auto`) are applied once.
    safe_join(keys.map { |key| render_hotkey_badge_key(key) }, " ")
  end
end