Class: Fluxbit::ThemeButtonComponent
- Inherits:
-
ButtonComponent
- Object
- ViewComponent::Base
- Component
- ButtonComponent
- Fluxbit::ThemeButtonComponent
- Includes:
- Config::ThemeButtonComponent
- Defined in:
- app/components/fluxbit/theme_button_component.rb
Overview
The ‘Fluxbit::ThemeButtonComponent` is a round button component that toggles between dark, light, and system themes. It extends `Fluxbit::ButtonComponent` and automatically updates the theme when clicked.
Constant Summary
Constants inherited from Component
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(**props) ⇒ Fluxbit::ThemeButtonComponent
constructor
Initializes the theme button component with the given properties.
Methods included from Config::ThemeButtonComponent
Methods inherited from ButtonComponent
#before_render, #declare_classes, #declare_disabled, #declare_selected, #declare_size
Methods inherited from Component
#add, #add_popover_or_tooltip, #anyicon, #element_name, #fx_id, #icon, #options, #popover?, #random_id, #remove_class, #remove_class_from_props, #render_popover_or_tooltip, #target, #tooltip?
Methods included from IconHelpers
#chevron_double_left, #chevron_double_right, #chevron_down, #chevron_left, #chevron_right, #chevron_up, #close_icon, #ellipsis_horizontal, #eye_icon, #eye_slash_icon, #plus_icon
Constructor Details
#initialize(**props) ⇒ Fluxbit::ThemeButtonComponent
Initializes the theme button component with the given properties.
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/components/fluxbit/theme_button_component.rb', line 19 def initialize(**props) # Set default values specific to theme button props[:pill] = true unless props.key?(:pill) props[:color] ||= :transparent props[:size] ||= 2 props[:remove_dropdown_arrow] = true # Add Stimulus controller props["data-controller"] = [props["data-controller"], "fx-theme-button"].compact.join(" ") props["data-action"] = [props["data-action"], "click->fx-theme-button#toggle"].compact.join(" ") super(**props) end |
Instance Method Details
#call ⇒ Object
33 34 35 36 |
# File 'app/components/fluxbit/theme_button_component.rb', line 33 def call concat() concat(render_popover_or_tooltip.to_s) end |