Sha256: 26dd7305eebc8379e57cf794f6d05d6eb6c570d2adb68d418b49d82b2f78ecf8

Contents?: true

Size: 873 Bytes

Versions: 5

Compression:

Stored size: 873 Bytes

Contents

# frozen_string_literal: true

module Primer
  class LayoutComponent < Primer::Component
    with_content_areas :main, :sidebar

    DEFAULT_SIDE = :right
    ALLOWED_SIDES = [DEFAULT_SIDE, :left].freeze

    MAX_COL = 12
    DEFAULT_SIDEBAR_COL = 3
    ALLOWED_SIDEBAR_COLS = (1..(MAX_COL - 1)).to_a.freeze

    def initialize(responsive: false, side: DEFAULT_SIDE, sidebar_col: DEFAULT_SIDEBAR_COL, **kwargs)
      @kwargs = kwargs
      @side = fetch_or_fallback(ALLOWED_SIDES, side.to_sym, DEFAULT_SIDE)
      @responsive = responsive
      @kwargs[:classes] = class_names(
        "gutter-condensed gutter-lg",
        @kwargs[:classes]
      )
      @kwargs[:direction] = responsive ? [:column, nil, :row] : nil

      @sidebar_col = fetch_or_fallback(ALLOWED_SIDEBAR_COLS, sidebar_col, DEFAULT_SIDEBAR_COL)
      @main_col = MAX_COL - @sidebar_col
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
primer_view_components-0.0.8 app/components/primer/layout_component.rb
primer_view_components-0.0.7 app/components/primer/layout_component.rb
primer_view_components-0.0.6 app/components/primer/layout_component.rb
primer_view_components-0.0.5 app/components/primer/layout_component.rb
primer_view_components-0.0.4 app/components/primer/layout_component.rb