Class: BetterUi::Application::Main::Component

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/better_ui/application/main/component.rb

Constant Summary collapse

MAIN_ROUNDED =

Arrotondamento bordi con classi Tailwind dirette

{
  none: "",
  small: "rounded-lg",
  medium: "rounded-xl",
  large: "rounded-2xl",
  full: "rounded-full"
}.freeze
MAIN_SHADOW =

Ombre con classi Tailwind dirette

{
  none: "",
  small: "shadow-sm",
  medium: "shadow-md", 
  large: "shadow-lg"
}.freeze
MAIN_PADDING =

Padding con classi Tailwind dirette

{
  true: "p-6",
  false: "p-0"
}.freeze
MAIN_LAYOUT =

Classi layout per sidebar

{
  sidebar: { sm: "pl-48", md: "pl-64", lg: "pl-72", xl: "pl-80" },  # Con Sidebar
  none: ""              # Senza sidebar
}.freeze
MAIN_SIDEBAR_WIDTH =

Larghezza sidebar (deve corrispondere a SIDEBAR_WIDTHS del componente Sidebar)

{
  sm: 48,
  md: 64,
  lg: 72,
  xl: 80
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(padding: true, inner_padding: true, rounded: :small, shadow: :medium, with_sidebar: true, sidebar_width: :md, classes: nil) ⇒ Component

Returns a new instance of Component.

Parameters:

  • padding (Boolean) (defaults to: true)

    Se applicare il padding al contenitore principale

  • inner_padding (Boolean) (defaults to: true)

    Se applicare il padding al contenitore interno

  • rounded (Symbol) (defaults to: :small)

    Tipo di border-radius del contenitore interno (:none, :small, :medium, :large, :full), default :small

  • shadow (Symbol) (defaults to: :medium)

    Tipo di ombra del contenitore interno (:none, :small, :medium, :large), default :medium

  • with_sidebar (Boolean) (defaults to: true)

    Se lasciare lo spazio per la sidebar

  • sidebar_width (Symbol) (defaults to: :md)

    Larghezza della sidebar (:sm, :md, :lg, :xl), default :md

  • classes (String) (defaults to: nil)

    Classi CSS aggiuntive per il contenitore principale



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'app/components/better_ui/application/main/component.rb', line 53

def initialize(
  padding: true,
  inner_padding: true,
  rounded: :small,
  shadow: :medium,
  with_sidebar: true,
  sidebar_width: :md,
  classes: nil
)
  @padding = padding
  @inner_padding = inner_padding
  @rounded = rounded.to_sym
  @shadow = shadow.to_sym
  @with_sidebar = with_sidebar
  @sidebar_width = sidebar_width.to_sym
  @classes = classes
  
  validate_params
end

Instance Attribute Details

#classesObject (readonly)

Returns the value of attribute classes.



7
8
9
# File 'app/components/better_ui/application/main/component.rb', line 7

def classes
  @classes
end

#inner_paddingObject (readonly)

Returns the value of attribute inner_padding.



7
8
9
# File 'app/components/better_ui/application/main/component.rb', line 7

def inner_padding
  @inner_padding
end

#paddingObject (readonly)

Returns the value of attribute padding.



7
8
9
# File 'app/components/better_ui/application/main/component.rb', line 7

def padding
  @padding
end

#roundedObject (readonly)

Returns the value of attribute rounded.



7
8
9
# File 'app/components/better_ui/application/main/component.rb', line 7

def rounded
  @rounded
end

#shadowObject (readonly)

Returns the value of attribute shadow.



7
8
9
# File 'app/components/better_ui/application/main/component.rb', line 7

def shadow
  @shadow
end

Returns the value of attribute sidebar_width.



7
8
9
# File 'app/components/better_ui/application/main/component.rb', line 7

def sidebar_width
  @sidebar_width
end

#with_sidebarObject (readonly)

Returns the value of attribute with_sidebar.



7
8
9
# File 'app/components/better_ui/application/main/component.rb', line 7

def with_sidebar
  @with_sidebar
end