Class: BetterUi::Application::Navbar::Component
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- BetterUi::Application::Navbar::Component
- Defined in:
- app/components/better_ui/application/navbar/component.rb
Constant Summary collapse
- NAVBAR_THEME =
Temi navbar con classi Tailwind dirette
{ default: "bg-white text-gray-900 border-gray-200", white: "bg-white text-gray-900 border-gray-200", red: "bg-red-50 text-red-900 border-red-200", rose: "bg-rose-50 text-rose-900 border-rose-200", orange: "bg-orange-50 text-orange-900 border-orange-200", green: "bg-green-50 text-green-900 border-green-200", blue: "bg-blue-50 text-blue-900 border-blue-200", yellow: "bg-yellow-50 text-yellow-900 border-yellow-200", violet: "bg-violet-50 text-violet-900 border-violet-200" }.freeze
- NAVBAR_SHADOW =
Ombre navbar con classi Tailwind dirette
{ none: "", small: "shadow-sm", medium: "shadow-md", large: "shadow-lg" }.freeze
- NAVBAR_SIDEBAR_WIDTH =
Larghezze sidebar con valori numerici per utilizzo in classi custom
{ sm: 48, md: 64, lg: 72, xl: 80 }.freeze
Instance Attribute Summary collapse
-
#actions ⇒ Object
readonly
Returns the value of attribute actions.
-
#border ⇒ Object
readonly
Returns the value of attribute border.
-
#classes ⇒ Object
readonly
Returns the value of attribute classes.
-
#shadow ⇒ Object
readonly
Returns the value of attribute shadow.
-
#sidebar_width ⇒ Object
readonly
Returns the value of attribute sidebar_width.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
-
#with_sidebar ⇒ Object
readonly
Returns the value of attribute with_sidebar.
Instance Method Summary collapse
- #container_classes ⇒ Object
- #has_actions? ⇒ Boolean
-
#initialize(theme: :default, shadow: :small, border: false, actions: [], classes: nil, with_sidebar: false, sidebar_width: :md) ⇒ Component
constructor
A new instance of Component.
Methods included from General::Components::Avatar::AvatarHelper
Methods included from General::Components::Icon::IconHelper
Constructor Details
#initialize(theme: :default, shadow: :small, border: false, actions: [], classes: nil, with_sidebar: false, sidebar_width: :md) ⇒ Component
Returns a new instance of Component.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/components/better_ui/application/navbar/component.rb', line 49 def initialize( theme: :default, shadow: :small, border: false, actions: [], classes: nil, with_sidebar: false, sidebar_width: :md ) @theme = theme.to_sym @shadow = shadow.to_sym @border = border @actions = actions || [] @classes = classes = = .to_sym validate_params 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 |
#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 |
#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 |
#sidebar_width ⇒ Object (readonly)
Returns the value of attribute sidebar_width.
11 12 13 |
# File 'app/components/better_ui/application/navbar/component.rb', line 11 def 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 |
#with_sidebar ⇒ Object (readonly)
Returns the value of attribute with_sidebar.
11 12 13 |
# File 'app/components/better_ui/application/navbar/component.rb', line 11 def end |
Instance Method Details
#container_classes ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'app/components/better_ui/application/navbar/component.rb', line 69 def container_classes base_classes = %w[h-[81px] px-6 py-4] # Width if = NAVBAR_SIDEBAR_WIDTH[] || NAVBAR_SIDEBAR_WIDTH[:md] base_classes << "pl-#{sidebar_width_value}" base_classes << "ml-auto" else base_classes << "w-full" end # 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
96 97 98 |
# File 'app/components/better_ui/application/navbar/component.rb', line 96 def has_actions? actions.present? && actions.any? end |