Sha256: 4dbc3ed990a364f7fded8b1bbc69444c38116f5745d35783feb8d30c07da718d

Contents?: true

Size: 1015 Bytes

Versions: 17

Compression:

Stored size: 1015 Bytes

Contents

# frozen_string_literal: true

module Primer
  class Classify
    # Handler for PrimerCSS grid classes.
    class Grid
      extend Primer::FetchOrFallbackHelper

      CONTAINER_KEY = :container
      CONTAINER_VALUES = [:xl, :lg, :md, :sm].freeze

      CLEARFIX_KEY = :clearfix
      CLEARFIX_VALUES = [true, false].freeze

      COL_KEY = :col
      COL_VALUES = (1..12).to_a.freeze

      KEYS = [CONTAINER_KEY, CLEARFIX_KEY, COL_KEY].freeze

      class << self
        def classes(key, value, breakpoint)
          send(key, value, breakpoint)
        end

        private

        def container(value, _breakpoint)
          val = fetch_or_fallback(CONTAINER_VALUES, value)

          "container-#{val}"
        end

        def clearfix(value, _breakpoint)
          "clearfix" if fetch_or_fallback(CLEARFIX_VALUES, value)
        end

        def col(value, breakpoint)
          val = fetch_or_fallback(COL_VALUES, value.to_i)

          "col#{breakpoint}-#{val}"
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
primer_view_components-0.0.59 lib/primer/classify/grid.rb
primer_view_components-0.0.58 lib/primer/classify/grid.rb
primer_view_components-0.0.57 lib/primer/classify/grid.rb
primer_view_components-0.0.56 lib/primer/classify/grid.rb
primer_view_components-0.0.55 lib/primer/classify/grid.rb
primer_view_components-0.0.54 lib/primer/classify/grid.rb
primer_view_components-0.0.53 lib/primer/classify/grid.rb
primer_view_components-0.0.52 lib/primer/classify/grid.rb
primer_view_components-0.0.51 lib/primer/classify/grid.rb
primer_view_components-0.0.50 lib/primer/classify/grid.rb
primer_view_components-0.0.49 lib/primer/classify/grid.rb
primer_view_components-0.0.48 lib/primer/classify/grid.rb
primer_view_components-0.0.47 lib/primer/classify/grid.rb
primer_view_components-0.0.46 lib/primer/classify/grid.rb
primer_view_components-0.0.45 app/lib/primer/classify/grid.rb
primer_view_components-0.0.44 app/lib/primer/classify/grid.rb
primer_view_components-0.0.43 app/lib/primer/classify/grid.rb