Sha256: 18f7762da3445af64ea355d0830d091d1246fc9e4cde99d64e9a002c9a0d0938

Contents?: true

Size: 1.33 KB

Versions: 194

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

require "action_view"

module Playbook
  module PbRadio
    class Radio < Playbook::KitBase
      prop :alignment, type: Playbook::Props::String,
                       default: ""
      prop :checked, type: Playbook::Props::Boolean,
                     default: false
      prop :error, type: Playbook::Props::Boolean,
                   default: false
      prop :disabled, type: Playbook::Props::Boolean, default: false
      prop :input_options, type: Playbook::Props::HashProp,
                           default: {}
      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"

      def classname
        generate_classname("pb_radio_kit") + error_class + alignment_class
      end

      def selected
        "checked" if checked == true
      end

      def body_status
        error ? "negative" : nil
      end

      def input
        radio_button_tag(name, value, checked, input_options.merge(disabled: disabled))
      end

    private

      def error_class
        error ? " error" : ""
      end

      def alignment_class
        alignment == "vertical" ? " vertical" : ""
      end
    end
  end
end

Version data entries

194 entries across 194 versions & 1 rubygems

Version Path
playbook_ui-14.1.0.pre.alpha.PBNTR462starratingdefaultvalue3600 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.1.0.pre.alpha.pbntr373enablekitsforradio3595 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.1.0.pre.alpha.pbntr373enablekitsforradio3593 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.2.0 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.1.0.pre.alpha.PBNTR462starratingdefaultvalue3582 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.1.0.pre.alpha.PBNTR462starratingdefaultvalue3579 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.1.0.pre.alpha.PBNTR455ganttchartPOC3569 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.1.0.pre.alpha.fixaction3547 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.1.0.pre.alpha.PA1477timestampkit3536 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.0.0.pre.alpha.testthemeexport3533 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.0.0.pre.alpha.updateviewcomponentgem3527 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.0.0.pre.alpha.PLAY15063526 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.0.0.pre.alpha.PLAY15063525 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.0.0.pre.alpha.PLAY15063524 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.0.0.pre.alpha.PLAY15063523 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.0.0.pre.alpha.PLAY15063522 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.0.0.pre.alpha.PBNTR416formpillsizes3521 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.0.0.pre.alpha.PLAY15063520 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.0.0.pre.alpha.PLAY14923518 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.0.0.pre.alpha.PLAY15063511 app/pb_kits/playbook/pb_radio/radio.rb