Sha256: 046f504d1b3960bbefe8ffc49ca5566bcefbb22675625558f5ca60d757d1eb86

Contents?: true

Size: 1.22 KB

Versions: 89

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

require "action_view"

module Playbook
  module PbRadio
    class Radio
      include ActionView::Helpers::FormTagHelper
      include ActionView::Context
      include Playbook::Props

      partial "pb_radio/radio"

      prop :checked, type: Playbook::Props::Boolean,
                     default: false
      prop :dark, type: Playbook::Props::Boolean,
                  default: false
      prop :error, type: Playbook::Props::Boolean,
                   default: false
      prop :name, type: Playbook::Props::String,
                  default: "radio_name"
      prop :text, type: Playbook::Props::String,
                  default: "Radio Text"
      prop :value, type: Playbook::Props::String,
                   default: "radio_text"
      prop :object
      def classname
        generate_classname("pb_radio_kit", dark_class) + error_class
      end

      def input
        check_box_tag(name, value, checked)
      end

      def selected
        "checked" if checked == true
      end

      def body_status
        error ? "negative" : nil
      end

    private

      def error_class
        error ? " error" : ""
      end

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

Version data entries

89 entries across 89 versions & 1 rubygems

Version Path
playbook_ui-6.2.1 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-6.2.0 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-7.0.0.pre.alpha1 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-6.1.0.pre.alpha5 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-6.1.0.pre.alpha4 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-6.1.0.pre.alpha3 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-6.1.0.pre.alpha2 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-6.1.0.pre.alpha1 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-6.1.0 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-6.0.1.pre.alpha6 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-6.0.1.pre.alpha5 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-6.0.1.pre.alpha4 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-6.0.1.pre.alpha3 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-6.0.1.pre.alpha2 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-5.2.0.pre.alpha15 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-5.2.0.pre.alpha14 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-5.2.0.pre.alpha13 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-6.0.1 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-5.2.0.pre.alpha12 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-6.0.0 app/pb_kits/playbook/pb_radio/radio.rb