Class: BetterUi::Application::Navbar::Component
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- BetterUi::Application::Navbar::Component
- Includes:
- General::Components::Avatar::AvatarHelper, General::Components::Breadcrumb::BreadcrumbHelper, General::Components::Icon::IconHelper
- Defined in:
- app/components/better_ui/application/navbar/component.rb
Constant Summary collapse
- NAVBAR_THEMES =
Temi navbar con classi Tailwind dirette
{ default: "bg-white text-gray-900 border-gray-200", dark: "bg-gray-900 text-white border-gray-700", light: "bg-gray-50 text-gray-900 border-gray-100" }
- NAVBAR_HEIGHTS =
Altezze navbar con classi Tailwind dirette
{ sm: "h-12", md: "h-16", lg: "h-20" }
- NAVBAR_POSITIONS =
Posizioni navbar con classi Tailwind dirette
{ top: "", fixed_top: "fixed top-0 left-0 right-0 z-50", sticky_top: "sticky top-0 z-40" }
- NAVBAR_SHADOWS =
Ombre navbar con classi Tailwind dirette
{ none: "", sm: "shadow-sm", md: "shadow-md", lg: "shadow-lg", xl: "shadow-xl" }
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#border ⇒ Object
readonly
Returns the value of attribute border.
-
#brand ⇒ Object
readonly
Returns the value of attribute brand.
-
#breadcrumb ⇒ Object
readonly
Returns the value of attribute breadcrumb.
-
#classes ⇒ Object
readonly
Returns the value of attribute classes.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#navigation_items ⇒ Object
readonly
Returns the value of attribute navigation_items.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
-
#shadow ⇒ Object
readonly
Returns the value of attribute shadow.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
Instance Method Summary collapse
- #container_classes ⇒ Object
- #has_actions? ⇒ Boolean
- #has_brand? ⇒ Boolean
- #has_breadcrumb? ⇒ Boolean
- #has_navigation? ⇒ Boolean
-
#initialize(theme: :default, position: :top, height: :md, shadow: :sm, border: true, brand: {}, breadcrumb: {}, navigation_items: [], actions: [], classes: nil) ⇒ Component
constructor
A new instance of Component.
- #render_breadcrumb ⇒ Object
Methods included from General::Components::Breadcrumb::BreadcrumbHelper
Methods included from General::Components::Avatar::AvatarHelper
Methods included from General::Components::Icon::IconHelper
Constructor Details
#initialize(theme: :default, position: :top, height: :md, shadow: :sm, border: true, brand: {}, breadcrumb: {}, navigation_items: [], actions: [], classes: nil) ⇒ Component
Returns a new instance of Component.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'app/components/better_ui/application/navbar/component.rb', line 53 def initialize( theme: :default, position: :top, height: :md, shadow: :sm, border: true, brand: {}, breadcrumb: {}, navigation_items: [], actions: [], classes: nil ) @theme = theme.to_sym @position = position.to_sym @height = height.to_sym @shadow = shadow.to_sym @border = border @brand = brand || {} @breadcrumb = || {} @navigation_items = || [] @actions = actions || [] @classes = classes end |
Instance Attribute Details
#actions ⇒ Object (readonly)
Returns the value of attribute actions.
11 12 13 |
# File 'app/components/better_ui/application/navbar/component.rb', line 11 def actions @actions end |
#border ⇒ Object (readonly)
Returns the value of attribute border.
11 12 13 |
# File 'app/components/better_ui/application/navbar/component.rb', line 11 def border @border end |
#brand ⇒ Object (readonly)
Returns the value of attribute brand.
11 12 13 |
# File 'app/components/better_ui/application/navbar/component.rb', line 11 def brand @brand end |
#breadcrumb ⇒ Object (readonly)
Returns the value of attribute breadcrumb.
11 12 13 |
# File 'app/components/better_ui/application/navbar/component.rb', line 11 def @breadcrumb end |
#classes ⇒ Object (readonly)
Returns the value of attribute classes.
11 12 13 |
# File 'app/components/better_ui/application/navbar/component.rb', line 11 def classes @classes end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
11 12 13 |
# File 'app/components/better_ui/application/navbar/component.rb', line 11 def height @height end |
#navigation_items ⇒ Object (readonly)
Returns the value of attribute navigation_items.
11 12 13 |
# File 'app/components/better_ui/application/navbar/component.rb', line 11 def @navigation_items end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
11 12 13 |
# File 'app/components/better_ui/application/navbar/component.rb', line 11 def position @position end |
#shadow ⇒ Object (readonly)
Returns the value of attribute shadow.
11 12 13 |
# File 'app/components/better_ui/application/navbar/component.rb', line 11 def shadow @shadow end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
11 12 13 |
# File 'app/components/better_ui/application/navbar/component.rb', line 11 def theme @theme end |
Instance Method Details
#container_classes ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'app/components/better_ui/application/navbar/component.rb', line 77 def container_classes base_classes = %w[w-full flex items-center justify-between px-4 sm:px-6 lg:px-8] # Posizione base_classes.concat(position_classes.split) if position != :top # Altezza base_classes << height_class # Tema base_classes.concat(theme_classes.split) # Shadow base_classes << shadow_class if shadow != :none # Border base_classes << "border-b" if border # Classi aggiuntive base_classes << classes if classes.present? base_classes.compact.join(" ") end |
#has_actions? ⇒ Boolean
113 114 115 |
# File 'app/components/better_ui/application/navbar/component.rb', line 113 def has_actions? actions.present? && actions.any? end |
#has_brand? ⇒ Boolean
101 102 103 |
# File 'app/components/better_ui/application/navbar/component.rb', line 101 def has_brand? brand.present? && (brand[:title].present? || brand[:logo].present?) end |
#has_breadcrumb? ⇒ Boolean
105 106 107 |
# File 'app/components/better_ui/application/navbar/component.rb', line 105 def .present? && [:items].present? && [:items].any? end |
#has_navigation? ⇒ Boolean
109 110 111 |
# File 'app/components/better_ui/application/navbar/component.rb', line 109 def .present? && .any? end |
#render_breadcrumb ⇒ Object
117 118 119 120 121 122 123 124 125 126 |
# File 'app/components/better_ui/application/navbar/component.rb', line 117 def return unless ( items: [:items], separator: [:separator] || :chevron, theme: [:theme] || theme, size: :small ) end |