Sha256: 76256954e5b3535b9252578136ee53f3b52a8ba6e2504bbce0fae65b6a71c620

Contents?: true

Size: 1.54 KB

Versions: 69

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

module Primer
  module OpenProject
    class GridLayout
      # GridLayout::Area is an internal component that wraps the items in a div with the given new class and responding "grid-area"
      class Area < Primer::Component
        status :open_project

        DEFAULT_TAG = :div
        TAG_OPTIONS = [DEFAULT_TAG, :span].freeze

        # @param css_class [String] The basic css class applied on the grid-container
        # @param area_name [Symbol] The specific area name, used for creating the element class and the "grid-area" style
        # @param component [ViewComponent::Base] The instance of the component to be rendered.
        # @param tag [Symbol] <%= one_of(Primer::OpenProject::GridLayout::Area::TAG_OPTIONS) %>
        # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
        def initialize(css_class, area_name, component = ::Primer::BaseComponent, tag: DEFAULT_TAG, **system_arguments)
          @component = component
          @system_arguments = system_arguments
          @styles = [
            "grid-area: #{area_name}"
          ]
          @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)
          @system_arguments[:style] = join_style_arguments(@system_arguments[:style], *@styles)
          @system_arguments[:classes] = class_names(
            @system_arguments[:classes],
            "#{css_class}--#{area_name}"
          )
        end

        def call
          render(@component.new(**@system_arguments)) { content }
        end
      end
    end
  end
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
openproject-primer_view_components-0.33.1 app/components/primer/open_project/grid_layout/area.rb
openproject-primer_view_components-0.33.0 app/components/primer/open_project/grid_layout/area.rb
openproject-primer_view_components-0.32.1 app/components/primer/open_project/grid_layout/area.rb
openproject-primer_view_components-0.32.0 app/components/primer/open_project/grid_layout/area.rb
openproject-primer_view_components-0.29.1 app/components/primer/open_project/grid_layout/area.rb
openproject-primer_view_components-0.29.0 app/components/primer/open_project/grid_layout/area.rb
openproject-primer_view_components-0.28.1 app/components/primer/open_project/grid_layout/area.rb
openproject-primer_view_components-0.28.0 app/components/primer/open_project/grid_layout/area.rb
openproject-primer_view_components-0.27.0 app/components/primer/open_project/grid_layout/area.rb
openproject-primer_view_components-0.26.0 app/components/primer/open_project/grid_layout/area.rb
openproject-primer_view_components-0.25.1 app/components/primer/open_project/grid_layout/area.rb
openproject-primer_view_components-0.25.0 app/components/primer/open_project/grid_layout/area.rb
openproject-primer_view_components-0.24.0 app/components/primer/open_project/grid_layout/area.rb
openproject-primer_view_components-0.23.0 app/components/primer/open_project/grid_layout/area.rb
openproject-primer_view_components-0.22.2 app/components/primer/open_project/grid_layout/area.rb
openproject-primer_view_components-0.22.1 app/components/primer/open_project/grid_layout/area.rb
openproject-primer_view_components-0.22.0 app/components/primer/open_project/grid_layout/area.rb
openproject-primer_view_components-0.21.0 app/components/primer/open_project/grid_layout/area.rb
openproject-primer_view_components-0.20.0 app/components/primer/open_project/grid_layout/area.rb
openproject-primer_view_components-0.19.0 app/components/primer/open_project/grid_layout/area.rb