Sha256: 8df9287b8e457399bfaf1f8cbb5092eb89cd0d7d22720d0c4bad71d85880db4c

Contents?: true

Size: 1.18 KB

Versions: 67

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbCheckbox
    class Checkbox
      include Playbook::Props
      include ActionView::Helpers::FormTagHelper
      include ActionView::Context

      partial "pb_checkbox/checkbox"

      prop :error, type: Playbook::Props::Boolean, default: false
      prop :checked, type: Playbook::Props::Boolean, default: false
      prop :text
      prop :value
      prop :name

      prop :input_options, type: Playbook::Props::Hash,
                           default: {}
      prop :required, type: Playbook::Props::Boolean,
                      default: false
      prop :form_spacing, type: Playbook::Props::Boolean,
                          default: false

      def checked_html
        checked ? "checked='true'" : nil
      end

      def classname
        generate_classname("pb_checkbox_kit", checked_class) + error_class
      end

      def input
        check_box_tag(name, value, checked, input_options)
      end

      def checkbox_label_status
        error ? "negative" : nil
      end

    private

      def error_class
        error ? " error" : ""
      end

      def checked_class
        checked ? "on" : "off"
      end
    end
  end
end

Version data entries

67 entries across 67 versions & 1 rubygems

Version Path
playbook_ui-7.16.0 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-7.15.1 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-7.15.0 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-7.14.0 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-7.13.0.pre.alpha1 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-7.13.0 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-7.12.1 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-7.12.0 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-7.11.1 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-7.11.0 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-7.11.0.pre.alpha1 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-7.10.0 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-7.9.0 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-7.8.4 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-7.8.3 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-7.8.2 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-7.8.1 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-7.8.0 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-7.7.0.pre.alpha1 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-7.7.0 app/pb_kits/playbook/pb_checkbox/checkbox.rb