Sha256: 6bb885cf8611b8ec454e5f2c2278257b1e5688d7660f664ff9d238d21813231c

Contents?: true

Size: 1004 Bytes

Versions: 1

Compression:

Stored size: 1004 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

      prop :required, 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)
      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

1 entries across 1 versions & 1 rubygems

Version Path
playbook_ui-6.0.1.pre.alpha6 app/pb_kits/playbook/pb_checkbox/checkbox.rb