Sha256: 25102e35863ad2caca91030664b9993a3524233ee6cf7a9b51d290c3acb0fc78

Contents?: true

Size: 1.03 KB

Versions: 78

Compression:

Stored size: 1.03 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 :dark, type: Playbook::Props::Boolean, default: false
      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", dark_class, 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

      def dark_class
        dark ? "dark" : nil
      end
    end
  end
end

Version data entries

78 entries across 78 versions & 1 rubygems

Version Path
playbook_ui-4.18.1 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-4.18.0 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-4.17.0 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-4.17.0.pre.alpha1 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-4.16.0 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-4.15.0 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-4.14.0 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-4.15.1.alpha1 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-4.13.1 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-4.13.0 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-4.12.0 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-4.11.0 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-4.11.0.pre.alpha3 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-4.11.0.pre.alpha.pre.2 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-4.10.0 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-4.10.0.pre.alpha1 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-4.9.0.pre.alpha1 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-4.9.0 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-4.8.2 app/pb_kits/playbook/pb_checkbox/checkbox.rb
playbook_ui-4.8.1 app/pb_kits/playbook/pb_checkbox/checkbox.rb