Sha256: c1e9592c6523d51f3384d03a1f1146bec8b4c5dfc9de513d6b30f9098d18b73b

Contents?: true

Size: 1.94 KB

Versions: 9

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_kit",
          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

9 entries across 9 versions & 1 rubygems

Version Path
playbook_ui-2.9.3 app/pb_kits/playbook/pb_title/title.rb
playbook_ui-2.9.2 app/pb_kits/playbook/pb_title/title.rb
playbook_ui-2.9.1 app/pb_kits/playbook/pb_title/title.rb
playbook_ui-2.9.0 app/pb_kits/playbook/pb_title/title.rb
playbook_ui-2.8.9 app/pb_kits/playbook/pb_title/title.rb
playbook_ui-2.8.8 app/pb_kits/playbook/pb_title/title.rb
playbook_ui-2.8.7 app/pb_kits/playbook/pb_title/title.rb
playbook_ui-2.8.6 app/pb_kits/playbook/pb_title/title.rb
playbook_ui-2.8.5 app/pb_kits/playbook/pb_title/title.rb