Class: BetterUi::Application::Sidebar::Component
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- BetterUi::Application::Sidebar::Component
- Defined in:
- app/components/better_ui/application/sidebar/component.rb
Constant Summary collapse
- SIDEBAR_WIDTHS =
Larghezze sidebar con classi Tailwind dirette
{ sm: "w-48", md: "w-64", lg: "w-72", xl: "w-80" }
- SIDEBAR_THEMES =
Temi sidebar con classi Tailwind dirette
{ default: "bg-white text-gray-900", dark: "bg-gray-900 text-white", light: "bg-white text-gray-900" }
- SIDEBAR_SHADOWS =
Ombre sidebar con classi Tailwind dirette
{ none: "", sm: "shadow-sm", md: "shadow-md", lg: "shadow-lg", xl: "shadow-xl" }
- SIDEBAR_BORDERS =
Bordi sidebar con classi Tailwind dirette
{ left: "border-r border-gray-200", right: "border-l border-gray-200" }
Instance Attribute Summary collapse
-
#border ⇒ Object
readonly
Returns the value of attribute border.
-
#classes ⇒ Object
readonly
Returns the value of attribute classes.
-
#collapsible ⇒ Object
readonly
Returns the value of attribute collapsible.
-
#footer ⇒ Object
readonly
Returns the value of attribute footer.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#navigation_sections ⇒ Object
readonly
Returns the value of attribute navigation_sections.
-
#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.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #container_classes ⇒ Object
- #has_footer? ⇒ Boolean
- #has_header? ⇒ Boolean
-
#initialize(width: :md, position: :left, theme: :default, shadow: :lg, border: true, header: {}, footer: {}, navigation_sections: [], collapsible: true, classes: nil) ⇒ Component
constructor
A new instance of Component.
Methods included from General::Components::Avatar::AvatarHelper
Methods included from General::Components::Icon::IconHelper
Constructor Details
#initialize(width: :md, position: :left, theme: :default, shadow: :lg, border: true, header: {}, footer: {}, navigation_sections: [], collapsible: true, classes: nil) ⇒ Component
Returns a new instance of Component.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'app/components/better_ui/application/sidebar/component.rb', line 52 def initialize( width: :md, position: :left, theme: :default, shadow: :lg, border: true, header: {}, footer: {}, navigation_sections: [], collapsible: true, classes: nil ) @width = width.to_sym @position = position.to_sym @theme = theme.to_sym @shadow = shadow.to_sym @border = border @header = header || {} @footer = || {} @navigation_sections = || [] @collapsible = collapsible @classes = classes end |
Instance Attribute Details
#border ⇒ Object (readonly)
Returns the value of attribute border.
10 11 12 |
# File 'app/components/better_ui/application/sidebar/component.rb', line 10 def border @border end |
#classes ⇒ Object (readonly)
Returns the value of attribute classes.
10 11 12 |
# File 'app/components/better_ui/application/sidebar/component.rb', line 10 def classes @classes end |
#collapsible ⇒ Object (readonly)
Returns the value of attribute collapsible.
10 11 12 |
# File 'app/components/better_ui/application/sidebar/component.rb', line 10 def collapsible @collapsible end |
#footer ⇒ Object (readonly)
Returns the value of attribute footer.
10 11 12 |
# File 'app/components/better_ui/application/sidebar/component.rb', line 10 def @footer end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
10 11 12 |
# File 'app/components/better_ui/application/sidebar/component.rb', line 10 def header @header end |
#navigation_sections ⇒ Object (readonly)
Returns the value of attribute navigation_sections.
10 11 12 |
# File 'app/components/better_ui/application/sidebar/component.rb', line 10 def @navigation_sections end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
10 11 12 |
# File 'app/components/better_ui/application/sidebar/component.rb', line 10 def position @position end |
#shadow ⇒ Object (readonly)
Returns the value of attribute shadow.
10 11 12 |
# File 'app/components/better_ui/application/sidebar/component.rb', line 10 def shadow @shadow end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
10 11 12 |
# File 'app/components/better_ui/application/sidebar/component.rb', line 10 def theme @theme end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
10 11 12 |
# File 'app/components/better_ui/application/sidebar/component.rb', line 10 def width @width end |
Instance Method Details
#container_classes ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'app/components/better_ui/application/sidebar/component.rb', line 76 def container_classes base_classes = %w[fixed inset-y-0 z-50 flex flex-col overflow-y-auto] # Posizione base_classes << (position == :right ? "right-0" : "left-0") # Larghezza base_classes << width_class # Tema base_classes.concat(theme_classes) # Shadow base_classes << shadow_class if shadow != :none # Border base_classes << border_class if border # Classi aggiuntive base_classes << classes if classes.present? base_classes.compact.join(" ") end |
#has_footer? ⇒ Boolean
105 106 107 |
# File 'app/components/better_ui/application/sidebar/component.rb', line 105 def .present? && ([:content].present? || [:user_info].present?) end |
#has_header? ⇒ Boolean
101 102 103 |
# File 'app/components/better_ui/application/sidebar/component.rb', line 101 def has_header? header.present? && (header[:title].present? || header[:logo].present?) end |