Class: BulmaPhlex::Grid

Inherits:
Base
  • Object
show all
Defined in:
lib/bulma_phlex/grid.rb

Overview

Renders a responsive grid layout using [Bulma’s grid system](bulma.io/documentation/grid/).

Supports **fixed or auto-count column** layouts, configurable **minimum column width**, and independent control over gap, **column gap**, and **row gap** sizes.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fixed_columns: nil, auto_count: false, minimum_column_width: nil, gap: nil, column_gap: nil, row_gap: nil, **html_attributes) ⇒ Grid

Returns a new instance of Grid.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/bulma_phlex/grid.rb', line 28

def initialize(fixed_columns: nil,
               auto_count: false,
               minimum_column_width: nil,
               gap: nil,
               column_gap: nil,
               row_gap: nil,
               **html_attributes)
  @fixed_columns = fixed_columns
  @auto_count = auto_count
  @minimum_column_width = minimum_column_width
  @gap = gap
  @column_gap = column_gap
  @row_gap = row_gap
  @html_attributes = html_attributes
end

Class Method Details

.new(fixed_columns: nil, auto_count: false, minimum_column_width: nil, gap: nil, column_gap: nil, row_gap: nil, **html_attributes) ⇒ Object

Parameters

  • ‘fixed_columns` — Specifies a fixed number of columns for the grid

  • ‘auto_count` — If `true`, the grid will automatically adjust the number of columns based on the content

  • ‘minimum_column_width` — Sets a minimum column width (integer 1-32)

  • ‘gap` — Sets the gap size between grid items (1-8 with 0.5 increments)

  • ‘column_gap` — Sets the column gap size between grid items (1-8 with 0.5 increments)

  • ‘row_gap` — Sets the row gap size between grid items (1-8 with 0.5 increments)

  • ‘**html_attributes` — Additional HTML attributes for the grid element



18
19
20
21
22
23
24
25
26
# File 'lib/bulma_phlex/grid.rb', line 18

def self.new(fixed_columns: nil,
             auto_count: false,
             minimum_column_width: nil,
             gap: nil,
             column_gap: nil,
             row_gap: nil,
             **html_attributes)
  super
end

Instance Method Details

#view_templateObject



44
45
46
47
48
# File 'lib/bulma_phlex/grid.rb', line 44

def view_template(&)
  optional_fixed_grid_wrapper do
    div(**mix({ class: grid_classes }, @html_attributes), &)
  end
end