Sha256: 91e2eef4a6b3dab32d8b764aaca861c40ff0d2d0aaa7a151c1bfe648595e8079

Contents?: true

Size: 912 Bytes

Versions: 8

Compression:

Stored size: 912 Bytes

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

      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)
      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

8 entries across 8 versions & 1 rubygems

Version Path
playbook_ui-6.2.1 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-6.2.0 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-7.0.0.pre.alpha1 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-6.1.0.pre.alpha5 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-6.1.0.pre.alpha4 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-6.1.0.pre.alpha2 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-6.1.0.pre.alpha1 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-6.1.0 app/pb_kits/playbook/pb_checkbox/checkbox.rb