Sha256: f0c94638c16257a7bd1ec43321c4dbb3ec08405e48ce975c7891473579fbbef9

Contents?: true

Size: 1.46 KB

Versions: 204

Compression:

Stored size: 1.46 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"
      prop :custom_children, type: Playbook::Props::Boolean,
                             default: false

      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 || input_options[:disabled]))
      end

    private

      def error_class
        error ? " error" : ""
      end

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

Version data entries

204 entries across 204 versions & 1 rubygems

Version Path
playbook_ui-14.9.0.pre.rc.9 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.8.0.pre.alpha.PLAY1680newwidthprop4661 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.8.0.pre.alpha.PLAY1658tanstackbump4657 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.8.0.pre.alpha.PLAY1649rolloutheightglobalprops4635 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.9.0.pre.rc.8 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.8.0.pre.alpha.PLAY1598floatinguiupgrade4617 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.9.0.pre.rc.7 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.9.0.pre.rc.6 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.9.0.pre.rc.5 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.8.0.pre.alpha.pbntr661createstickyleftprop4612 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.8.0.pre.alpha.play1648heightglobalprops4606 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.9.0.pre.rc.4 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.9.0.pre.rc.3 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.9.0.pre.rc.2 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.8.0.pre.alpha.revert3916revert3893PBNTR667railstypeaheadformintegration4567 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.8.0.pre.alpha.revert3916revert3893PBNTR667railstypeaheadformintegration4565 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.8.0.pre.alpha.PLAY1598floatinguiupgrade4563 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.8.0.pre.alpha.play1648heightglobalprops4559 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.9.0.pre.rc.1 app/pb_kits/playbook/pb_radio/radio.rb
playbook_ui-14.8.0.pre.alpha.PLAY16254545 app/pb_kits/playbook/pb_radio/radio.rb