Sha256: fcbd26a4fdbe0b3a06ed5f14bf7676151f4b4626c558dd0a326ce6aa1f2646cb

Contents?: true

Size: 1.06 KB

Versions: 19

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

module Playbook
  module PbCheckbox
    class Checkbox < Playbook::KitBase
      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

19 entries across 19 versions & 1 rubygems

Version Path
playbook_ui-8.1.3 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-8.1.2 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-8.1.0.pre.alpha1 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-8.0.3 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-8.2.0.pre.alpha2 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-8.1.1 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-8.0.2 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-8.2.0.pre.alpha1 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-8.1.0 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-8.0.1 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-8.0.0 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-8.0.0.pre.alpha5 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-8.0.0.pre.alpha4 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-8.0.0.pre.alpha1 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-7.16.0.pre.alpha5 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-7.16.0.pre.alpha4 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-7.16.0.pre.alpha3 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-7.16.0.pre.alpha2 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-7.16.0.pre.alpha1 app/pb_kits/playbook/pb_checkbox/checkbox.rb