Sha256: 4585ec374482f35042b8ed11b65fbeabab8825fc3f3bc5424a678bc4f668518d

Contents?: true

Size: 1.43 KB

Versions: 2

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true

module Yattho
  module Alpha
    class ActionList
      # Heading used to describe each sub list within an action list.
      class Heading < Yattho::Component
        DEFAULT_SCHEME = :subtle
        SCHEME_MAPPINGS = {
          DEFAULT_SCHEME => nil,
          :filled => "ActionList-sectionDivider--filled"
        }.freeze
        SCHEME_OPTIONS = SCHEME_MAPPINGS.keys.freeze

        # @param list_id [String] The unique identifier of the sub list the heading belongs to. Used internally.
        # @param title [String] Sub list title.
        # @param subtitle [String] Optional sub list description.
        # @param scheme [Symbol] Display a background color if scheme is `filled`.
        # @param tag [Symbol] Semantic tag for the heading.
        # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
        def initialize(list_id:, title:, tag: :h3, scheme: DEFAULT_SCHEME, subtitle: nil, **system_arguments)
          @tag = tag
          @system_arguments = system_arguments
          @list_id = list_id
          @title = title
          @subtitle = subtitle
          @scheme = fetch_or_fallback(SCHEME_OPTIONS, scheme, DEFAULT_SCHEME)
          @system_arguments[:tag] = :li
          @system_arguments[:classes] = class_names(
            "ActionList-sectionDivider",
            SCHEME_MAPPINGS[@scheme],
            @system_arguments[:classes]
          )
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
yattho_view_components-0.1.1 app/components/yattho/alpha/action_list/heading.rb
yattho_view_components-0.0.1 app/components/yattho/alpha/action_list/heading.rb