Class: BetterUi::General::Panel::Component
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- BetterUi::General::Panel::Component
- Defined in:
- app/components/better_ui/general/panel/component.rb
Constant Summary collapse
- PANEL_BASE_CLASSES =
Classi base sempre presenti
"overflow-hidden"- PANEL_THEME_CLASSES =
Temi con classi Tailwind dirette - LOGICA CORRETTA
{ default: "bg-gray-800 border-gray-700", # Scuro per sfondi scuri white: "bg-white border-gray-200", # Chiaro per sfondi chiari red: "bg-red-50 border-red-200", rose: "bg-rose-50 border-rose-200", orange: "bg-orange-50 border-orange-200", green: "bg-green-50 border-green-200", blue: "bg-blue-50 border-blue-200", yellow: "bg-yellow-50 border-yellow-200", violet: "bg-violet-50 border-violet-200" }
- PANEL_TEXT_THEME_CLASSES =
Temi per testo - LOGICA CORRETTA
{ default: "text-white", # Testo bianco per sfondi scuri white: "text-gray-900", # Testo nero per sfondi chiari red: "text-red-900", rose: "text-rose-900", orange: "text-orange-900", green: "text-green-900", blue: "text-blue-900", yellow: "text-yellow-900", violet: "text-violet-900" }
- PANEL_STYLE_CLASSES =
Stili con classi Tailwind dirette
{ default: "border shadow-sm", flat: "border-0", raised: "border shadow-lg", bordered: "border-2" }
- PANEL_PADDING_CLASSES =
Padding con classi Tailwind dirette
{ none: "p-0", small: "p-2", medium: "p-4", large: "p-6" }
- PANEL_RADIUS_CLASSES =
Radius con classi Tailwind dirette
{ none: "rounded-none", small: "rounded", medium: "rounded-md", large: "rounded-lg", full: "rounded-full" }
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#footer ⇒ Object
readonly
Returns the value of attribute footer.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#padding ⇒ Object
readonly
Returns the value of attribute padding.
-
#radius ⇒ Object
readonly
Returns the value of attribute radius.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
-
#body_classes ⇒ Object
Classi per il body.
-
#combined_classes ⇒ Object
Combina tutte le classi CSS per il panel.
-
#footer_classes ⇒ Object
Classi per il footer.
-
#header_classes ⇒ Object
Classi per l’header.
-
#initialize(title: nil, body: nil, header: nil, footer: nil, theme: :white, style: :default, padding: :medium, radius: :small, **html_options) ⇒ Component
constructor
A new instance of Component.
-
#panel_attributes ⇒ Object
Restituisce gli attributi HTML per il panel.
-
#render? ⇒ Boolean
Determina se il pannello deve essere renderizzato.
-
#show_body? ⇒ Boolean
Determina se mostrare il body.
-
#show_footer? ⇒ Boolean
Determina se mostrare il footer.
-
#show_header? ⇒ Boolean
Determina se mostrare l’header.
-
#title_classes ⇒ Object
Classi per il title.
Constructor Details
#initialize(title: nil, body: nil, header: nil, footer: nil, theme: :white, style: :default, padding: :medium, radius: :small, **html_options) ⇒ Component
Returns a new instance of Component.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/components/better_ui/general/panel/component.rb', line 70 def initialize( title: nil, body: nil, header: nil, footer: nil, theme: :white, style: :default, padding: :medium, radius: :small, ** ) @title = title @body = body @header = header @footer = @theme = theme.to_sym @style = style.to_sym @padding = padding.to_sym @radius = radius.to_sym @html_options = validate_params end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
5 6 7 |
# File 'app/components/better_ui/general/panel/component.rb', line 5 def body @body end |
#footer ⇒ Object (readonly)
Returns the value of attribute footer.
5 6 7 |
# File 'app/components/better_ui/general/panel/component.rb', line 5 def @footer end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
5 6 7 |
# File 'app/components/better_ui/general/panel/component.rb', line 5 def header @header end |
#padding ⇒ Object (readonly)
Returns the value of attribute padding.
5 6 7 |
# File 'app/components/better_ui/general/panel/component.rb', line 5 def padding @padding end |
#radius ⇒ Object (readonly)
Returns the value of attribute radius.
5 6 7 |
# File 'app/components/better_ui/general/panel/component.rb', line 5 def radius @radius end |
#style ⇒ Object (readonly)
Returns the value of attribute style.
5 6 7 |
# File 'app/components/better_ui/general/panel/component.rb', line 5 def style @style end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
5 6 7 |
# File 'app/components/better_ui/general/panel/component.rb', line 5 def theme @theme end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
5 6 7 |
# File 'app/components/better_ui/general/panel/component.rb', line 5 def title @title end |
Instance Method Details
#body_classes ⇒ Object
Classi per il body
123 124 125 126 127 128 |
# File 'app/components/better_ui/general/panel/component.rb', line 123 def body_classes [ get_text_theme_class, get_padding_class ].compact.join(" ") end |
#combined_classes ⇒ Object
Combina tutte le classi CSS per il panel
95 96 97 98 99 100 101 102 103 |
# File 'app/components/better_ui/general/panel/component.rb', line 95 def combined_classes [ PANEL_BASE_CLASSES, get_theme_class, get_style_class, get_radius_class, @html_options[:class] ].compact.join(" ") end |
#footer_classes ⇒ Object
Classi per il footer
131 132 133 134 135 136 137 138 |
# File 'app/components/better_ui/general/panel/component.rb', line 131 def [ "border-t", get_border_theme_class, get_text_theme_class, get_padding_class ].compact.join(" ") end |
#header_classes ⇒ Object
Classi per l’header
113 114 115 116 117 118 119 120 |
# File 'app/components/better_ui/general/panel/component.rb', line 113 def header_classes [ "border-b", get_border_theme_class, get_text_theme_class, get_padding_class ].compact.join(" ") end |
#panel_attributes ⇒ Object
Restituisce gli attributi HTML per il panel
106 107 108 109 110 |
# File 'app/components/better_ui/general/panel/component.rb', line 106 def panel_attributes attrs = @html_options.except(:class) attrs[:class] = combined_classes attrs end |
#render? ⇒ Boolean
Determina se il pannello deve essere renderizzato
149 150 151 |
# File 'app/components/better_ui/general/panel/component.rb', line 149 def render? @body.present? || @header.present? || @footer.present? || content.present? end |
#show_body? ⇒ Boolean
Determina se mostrare il body
159 160 161 |
# File 'app/components/better_ui/general/panel/component.rb', line 159 def show_body? @body.present? || content.present? end |
#show_footer? ⇒ Boolean
Determina se mostrare il footer
164 165 166 |
# File 'app/components/better_ui/general/panel/component.rb', line 164 def @footer.present? end |
#show_header? ⇒ Boolean
Determina se mostrare l’header
154 155 156 |
# File 'app/components/better_ui/general/panel/component.rb', line 154 def show_header? @header.present? || @title.present? end |
#title_classes ⇒ Object
Classi per il title
141 142 143 144 145 146 |
# File 'app/components/better_ui/general/panel/component.rb', line 141 def title_classes [ "font-semibold text-lg leading-6", get_text_theme_class ].compact.join(" ") end |