Class: BetterUi::General::Container::Component
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- BetterUi::General::Container::Component
- Defined in:
- app/components/better_ui/general/container/component.rb
Constant Summary collapse
- CONTAINER_BASE_CLASSES =
Classi base sempre presenti
"mx-auto"- CONTAINER_MAX_WIDTH_CLASSES =
Larghezze massime con classi Tailwind dirette
{ sm: "max-w-screen-sm", md: "max-w-screen-md", lg: "max-w-screen-lg", xl: "max-w-screen-xl", xxl: "max-w-screen-2xl" }
- CONTAINER_PADDING_CLASSES =
Padding con classi Tailwind dirette
{ none: "p-0", small: "p-2", medium: "p-4", large: "p-6" }
- CONTAINER_BACKGROUND_CLASSES =
Background con classi Tailwind dirette
{ white: "bg-white", light: "bg-gray-50", dark: "bg-gray-900", transparent: "bg-transparent" }
- CONTAINER_BORDER_CLASSES =
Border con classi Tailwind dirette
{ none: "border-0", small: "border", medium: "border-2", large: "border-4" }
- CONTAINER_SHADOW_CLASSES =
Shadow con classi Tailwind dirette
{ none: "shadow-none", small: "shadow-sm", medium: "shadow", large: "shadow-lg" }
Instance Attribute Summary collapse
-
#background ⇒ Object
readonly
Returns the value of attribute background.
-
#border ⇒ Object
readonly
Returns the value of attribute border.
-
#classes ⇒ Object
readonly
Returns the value of attribute classes.
-
#fluid ⇒ Object
readonly
Returns the value of attribute fluid.
-
#html_content ⇒ Object
readonly
Returns the value of attribute html_content.
-
#max_width ⇒ Object
readonly
Returns the value of attribute max_width.
-
#padding ⇒ Object
readonly
Returns the value of attribute padding.
-
#shadow ⇒ Object
readonly
Returns the value of attribute shadow.
Instance Method Summary collapse
-
#combined_classes ⇒ Object
Combina tutte le classi CSS per il container.
-
#container_attributes ⇒ Object
Restituisce gli attributi HTML per il container.
-
#initialize(html_content: nil, fluid: false, max_width: :lg, padding: :medium, background: :white, border: false, shadow: :none, classes: nil, **html_options) ⇒ Component
constructor
A new instance of Component.
-
#render? ⇒ Boolean
Determina se il container deve essere renderizzato.
Constructor Details
#initialize(html_content: nil, fluid: false, max_width: :lg, padding: :medium, background: :white, border: false, shadow: :none, classes: nil, **html_options) ⇒ Component
Returns a new instance of Component.
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'app/components/better_ui/general/container/component.rb', line 59 def initialize( html_content: nil, fluid: false, max_width: :lg, padding: :medium, background: :white, border: false, shadow: :none, classes: nil, ** ) @html_content = html_content @fluid = fluid @max_width = max_width.to_sym @padding = padding.to_sym @background = background.to_sym @border = border @shadow = shadow @html_options = @classes = classes validate_params end |
Instance Attribute Details
#background ⇒ Object (readonly)
Returns the value of attribute background.
5 6 7 |
# File 'app/components/better_ui/general/container/component.rb', line 5 def background @background end |
#border ⇒ Object (readonly)
Returns the value of attribute border.
5 6 7 |
# File 'app/components/better_ui/general/container/component.rb', line 5 def border @border end |
#classes ⇒ Object (readonly)
Returns the value of attribute classes.
5 6 7 |
# File 'app/components/better_ui/general/container/component.rb', line 5 def classes @classes end |
#fluid ⇒ Object (readonly)
Returns the value of attribute fluid.
5 6 7 |
# File 'app/components/better_ui/general/container/component.rb', line 5 def fluid @fluid end |
#html_content ⇒ Object (readonly)
Returns the value of attribute html_content.
5 6 7 |
# File 'app/components/better_ui/general/container/component.rb', line 5 def html_content @html_content end |
#max_width ⇒ Object (readonly)
Returns the value of attribute max_width.
5 6 7 |
# File 'app/components/better_ui/general/container/component.rb', line 5 def max_width @max_width end |
#padding ⇒ Object (readonly)
Returns the value of attribute padding.
5 6 7 |
# File 'app/components/better_ui/general/container/component.rb', line 5 def padding @padding end |
#shadow ⇒ Object (readonly)
Returns the value of attribute shadow.
5 6 7 |
# File 'app/components/better_ui/general/container/component.rb', line 5 def shadow @shadow end |
Instance Method Details
#combined_classes ⇒ Object
Combina tutte le classi CSS per il container
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'app/components/better_ui/general/container/component.rb', line 84 def combined_classes [ CONTAINER_BASE_CLASSES, get_max_width_class, get_padding_class, get_background_class, get_border_class, get_shadow_class, @classes, @html_options[:class] ].compact.join(" ") end |
#container_attributes ⇒ Object
Restituisce gli attributi HTML per il container
98 99 100 101 102 |
# File 'app/components/better_ui/general/container/component.rb', line 98 def container_attributes attrs = @html_options.except(:class) attrs[:class] = combined_classes attrs end |
#render? ⇒ Boolean
Determina se il container deve essere renderizzato
105 106 107 |
# File 'app/components/better_ui/general/container/component.rb', line 105 def render? @html_content.present? || content.present? end |