Class: BetterUi::General::Dropdown::Component
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- BetterUi::General::Dropdown::Component
- Includes:
- Components::Icon::IconHelper
- Defined in:
- app/components/better_ui/general/dropdown/component.rb
Constant Summary collapse
- DROPDOWN_TRIGGER_THEME =
Temi per il trigger del dropdown con classi Tailwind dirette
{ default: "bg-white border-gray-300 text-gray-700 hover:bg-gray-50 focus:ring-blue-500", white: "bg-white border-gray-300 text-gray-900 hover:bg-gray-50 focus:ring-gray-500", red: "bg-red-600 border-red-600 text-white hover:bg-red-700 focus:ring-red-500", rose: "bg-rose-600 border-rose-600 text-white hover:bg-rose-700 focus:ring-rose-500", orange: "bg-orange-600 border-orange-600 text-white hover:bg-orange-700 focus:ring-orange-500", green: "bg-green-600 border-green-600 text-white hover:bg-green-700 focus:ring-green-500", blue: "bg-blue-600 border-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500", yellow: "bg-yellow-500 border-yellow-500 text-white hover:bg-yellow-600 focus:ring-yellow-500", violet: "bg-violet-600 border-violet-600 text-white hover:bg-violet-700 focus:ring-violet-500" }.freeze
- DROPDOWN_TRIGGER_SIZE =
Dimensioni del trigger con classi Tailwind dirette
{ small: "px-3 py-1.5 text-sm", medium: "px-4 py-2 text-sm", large: "px-6 py-3 text-base" }.freeze
- DROPDOWN_ROUNDED =
Border radius con classi Tailwind dirette
{ none: "rounded-none", small: "rounded-md", medium: "rounded-lg", large: "rounded-xl", full: "rounded-full" }.freeze
- DROPDOWN_POSITION =
Posizioni del menu dropdown
{ bottom: "top-full left-0", top: "bottom-full left-0", left: "top-0 right-full mr-2", right: "top-0 left-full ml-2" }.freeze
- DROPDOWN_ANIMATION =
Animazioni del dropdown
{ fade: "transition-opacity duration-150", slide: "transition-all duration-150 transform", none: "" }.freeze
- DROPDOWN_FULLWIDTH =
Stili per full-width del trigger
{ true => "w-full text-left justify-start", false => "inline-flex justify-center" }.freeze
Instance Attribute Summary collapse
-
#animation ⇒ Object
readonly
Returns the value of attribute animation.
-
#classes ⇒ Object
readonly
Returns the value of attribute classes.
-
#fullwidth ⇒ Object
readonly
Returns the value of attribute fullwidth.
-
#html_options ⇒ Object
readonly
Returns the value of attribute html_options.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
-
#rounded ⇒ Object
readonly
Returns the value of attribute rounded.
-
#selectable ⇒ Object
readonly
Returns the value of attribute selectable.
-
#show_chevron ⇒ Object
readonly
Returns the value of attribute show_chevron.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
-
#trigger ⇒ Object
readonly
Returns the value of attribute trigger.
Instance Method Summary collapse
-
#dynamic_menu_classes ⇒ Object
Restituisce solo le classi dinamiche per il menu.
-
#dynamic_trigger_classes ⇒ Object
Restituisce solo le classi dinamiche per il trigger.
- #fullwidth_classes ⇒ Object
-
#initialize(trigger:, position: :bottom, theme: :default, size: :medium, rounded: :medium, animation: :fade, fullwidth: false, show_chevron: true, selectable: false, classes: nil, **html_options) ⇒ Component
constructor
A new instance of Component.
-
#render? ⇒ Boolean
Verifica se rendere il componente.
Methods included from Components::Icon::IconHelper
Constructor Details
#initialize(trigger:, position: :bottom, theme: :default, size: :medium, rounded: :medium, animation: :fade, fullwidth: false, show_chevron: true, selectable: false, classes: nil, **html_options) ⇒ Component
Returns a new instance of Component.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'app/components/better_ui/general/dropdown/component.rb', line 63 def initialize( trigger:, position: :bottom, theme: :default, size: :medium, rounded: :medium, animation: :fade, fullwidth: false, show_chevron: true, selectable: false, classes: nil, ** ) @trigger = trigger @position = position.to_sym @theme = theme.to_sym @size = size.to_sym @rounded = rounded.to_sym @animation = animation.to_sym @fullwidth = fullwidth @show_chevron = show_chevron @selectable = selectable @classes = classes @html_options = validate_params end |
Instance Attribute Details
#animation ⇒ Object (readonly)
Returns the value of attribute animation.
9 10 11 |
# File 'app/components/better_ui/general/dropdown/component.rb', line 9 def animation @animation end |
#classes ⇒ Object (readonly)
Returns the value of attribute classes.
9 10 11 |
# File 'app/components/better_ui/general/dropdown/component.rb', line 9 def classes @classes end |
#fullwidth ⇒ Object (readonly)
Returns the value of attribute fullwidth.
9 10 11 |
# File 'app/components/better_ui/general/dropdown/component.rb', line 9 def fullwidth @fullwidth end |
#html_options ⇒ Object (readonly)
Returns the value of attribute html_options.
9 10 11 |
# File 'app/components/better_ui/general/dropdown/component.rb', line 9 def @html_options end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
9 10 11 |
# File 'app/components/better_ui/general/dropdown/component.rb', line 9 def position @position end |
#rounded ⇒ Object (readonly)
Returns the value of attribute rounded.
9 10 11 |
# File 'app/components/better_ui/general/dropdown/component.rb', line 9 def rounded @rounded end |
#selectable ⇒ Object (readonly)
Returns the value of attribute selectable.
9 10 11 |
# File 'app/components/better_ui/general/dropdown/component.rb', line 9 def selectable @selectable end |
#show_chevron ⇒ Object (readonly)
Returns the value of attribute show_chevron.
9 10 11 |
# File 'app/components/better_ui/general/dropdown/component.rb', line 9 def show_chevron @show_chevron end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
9 10 11 |
# File 'app/components/better_ui/general/dropdown/component.rb', line 9 def size @size end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
9 10 11 |
# File 'app/components/better_ui/general/dropdown/component.rb', line 9 def theme @theme end |
#trigger ⇒ Object (readonly)
Returns the value of attribute trigger.
9 10 11 |
# File 'app/components/better_ui/general/dropdown/component.rb', line 9 def trigger @trigger end |
Instance Method Details
#dynamic_menu_classes ⇒ Object
Restituisce solo le classi dinamiche per il menu
107 108 109 110 111 112 113 |
# File 'app/components/better_ui/general/dropdown/component.rb', line 107 def [ get_position_classes, get_animation_classes, ].compact.join(" ") end |
#dynamic_trigger_classes ⇒ Object
Restituisce solo le classi dinamiche per il trigger
98 99 100 101 102 103 104 |
# File 'app/components/better_ui/general/dropdown/component.rb', line 98 def dynamic_trigger_classes [ get_trigger_theme_classes, get_trigger_size_classes, get_trigger_rounded_classes ].compact.join(" ") end |
#fullwidth_classes ⇒ Object
91 92 93 94 95 |
# File 'app/components/better_ui/general/dropdown/component.rb', line 91 def fullwidth_classes [ get_fullwidth_classes ].compact.join(" ") end |
#render? ⇒ Boolean
Verifica se rendere il componente
118 119 120 |
# File 'app/components/better_ui/general/dropdown/component.rb', line 118 def render? @trigger.present? end |