Class: Keystone::Ui::PageComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/keystone/ui/page_component.rb

Constant Summary collapse

MAX_WIDTH_CLASSES =
{
  sm: "max-w-2xl",
  md: "max-w-4xl",
  lg: "max-w-6xl",
  xl: "max-w-7xl",
  full: ""
}.freeze
PADDING_CLASSES =
"px-4 py-4 sm:px-6 lg:px-8"
TOP_OFFSET_CLASSES =
{
  sm: "pt-12",
  md: "pt-16",
  lg: "pt-20",
  xl: "pt-24"
}.freeze

Instance Method Summary collapse

Constructor Details

#initialize(max_width: :full, padding: :standard, top_offset: nil) ⇒ PageComponent

Returns a new instance of PageComponent.



23
24
25
26
27
# File 'app/components/keystone/ui/page_component.rb', line 23

def initialize(max_width: :full, padding: :standard, top_offset: nil)
  @max_width = max_width
  @padding = padding
  @top_offset = top_offset
end

Instance Method Details

#classesObject



29
30
31
32
33
34
35
36
37
# File 'app/components/keystone/ui/page_component.rb', line 29

def classes
  tokens = []
  tokens << PADDING_CLASSES unless @padding == :none
  tokens << TOP_OFFSET_CLASSES.fetch(@top_offset) if @top_offset
  width_class = MAX_WIDTH_CLASSES.fetch(@max_width)
  tokens << width_class unless width_class.empty?
  tokens << "mx-auto" unless @max_width == :full
  tokens.join(" ")
end