Sha256: 837b3f3da5dfc38eb8edf518ab9cd74425fc0ba5ed2a0870d85ec5af2fccec98

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

module Yattho
  module Alpha
    class ActionList
      # Section heading rendered above the section contents.
      class Divider < Yattho::Component
        DEFAULT_SCHEME = :subtle
        SCHEME_MAPPINGS = {
          DEFAULT_SCHEME => nil,
          :filled => "ActionList-sectionDivider--filled"
        }.freeze
        SCHEME_OPTIONS = SCHEME_MAPPINGS.keys.freeze

        # @param scheme [Symbol] Display a background color if scheme is `filled`.
        # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
        def initialize(scheme: DEFAULT_SCHEME, **system_arguments)
          @system_arguments = system_arguments
          @system_arguments[:tag] = :li
          @system_arguments[:role] = :separator
          @system_arguments[:'aria-hidden'] = true
          @scheme = fetch_or_fallback(SCHEME_OPTIONS, scheme, DEFAULT_SCHEME)
          @system_arguments[:classes] = class_names(
            "ActionList-sectionDivider",
            SCHEME_MAPPINGS[@scheme]
          )
        end

        def call
          render(Yattho::BaseComponent.new(**@system_arguments)) { "" }
        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/divider.rb
yattho_view_components-0.0.1 app/components/yattho/alpha/action_list/divider.rb