Sha256: fe3a5b2e5e8a471c62d554306b3c7238ea2b39724e7efbdc1b68c3b524f56cef

Contents?: true

Size: 1.94 KB

Versions: 3

Compression:

Stored size: 1.94 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbTitle
    class Title < Playbook::PbKit::Base
      PROPS = %i[configured_aria
                 configured_classname
                 configured_dark
                 configured_data
                 configured_id
                 configured_size
                 configured_tag
                 configured_text].freeze

      def initialize(aria: default_configuration,
                     classname: default_configuration,
                     dark: default_configuration,
                     data: default_configuration,
                     id: default_configuration,
                     size: default_configuration,
                     tag: default_configuration,
                     text: default_configuration)
        self.configured_aria = aria
        self.configured_classname = classname
        self.configured_dark = dark
        self.configured_data = data
        self.configured_id = id
        self.configured_size = size
        self.configured_tag = tag
        self.configured_text = text
      end

      def tag
        tag_options = %w[h1 h2 h3 h4 h5 h6 p div span]
        one_of_value(configured_tag, tag_options, "h3")
      end

      def text
        default_value(configured_text, "Title text")
      end

      def size
        size_options = [1, 2, 3, 4]
        one_of_value(configured_size, size_options, 3)
      end

      def size_class
        adjusted_value(size, size, nil)
      end

      def dark_class
        true_value(configured_dark, "dark", nil)
      end

      def kit_class
        title_options = [
          "pb_title",
          size_class,
          dark_class,
        ]
        title_options.reject(&:nil?).join("_")
      end

      def to_partial_path
        "pb_title/title"
      end

    private

      DEFAULT = Object.new
      private_constant :DEFAULT
      def default_configuration
        DEFAULT
      end
      attr_accessor(*PROPS)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
playbook_ui-2.8.4 app/pb_kits/playbook/pb_title/title.rb
playbook_ui-2.8.3 app/pb_kits/playbook/pb_title/title.rb
playbook_ui-2.8.1 app/pb_kits/playbook/pb_title/title.rb