Class: Pajamas::ButtonComponent
- Defined in:
- app/components/pajamas/button_component.rb
Constant Summary collapse
- CATEGORY_OPTIONS =
[:primary, :secondary, :tertiary].freeze
- VARIANT_OPTIONS =
[:default, :confirm, :danger, :link, :reset].freeze
- SIZE_OPTIONS =
[:small, :medium].freeze
- TYPE_OPTIONS =
[:button, :reset, :submit].freeze
- TARGET_OPTIONS =
%w[_self _blank _parent _top].freeze
- METHOD_OPTIONS =
[:get, :post, :put, :delete, :patch].freeze
- CATEGORY_CLASSES =
{ primary: '', secondary: 'secondary', tertiary: 'tertiary' }.freeze
- VARIANT_CLASSES =
{ default: 'btn-default', confirm: 'btn-confirm', danger: 'btn-danger', link: 'btn-link', reset: 'btn-gl-reset' }.freeze
- NON_CATEGORY_VARIANTS =
[:link, :reset].freeze
- SIZE_CLASSES =
{ small: 'btn-sm', medium: 'btn-md' }.freeze
Instance Method Summary collapse
-
#initialize(category: :primary, variant: :default, size: :medium, type: :button, disabled: false, loading: false, block: false, label: false, selected: false, icon: nil, href: nil, form: false, target: nil, method: nil, button_options: {}, button_text_classes: nil, icon_classes: nil) ⇒ ButtonComponent
constructor
A new instance of ButtonComponent.
Constructor Details
#initialize(category: :primary, variant: :default, size: :medium, type: :button, disabled: false, loading: false, block: false, label: false, selected: false, icon: nil, href: nil, form: false, target: nil, method: nil, button_options: {}, button_text_classes: nil, icon_classes: nil) ⇒ ButtonComponent
Returns a new instance of ButtonComponent.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/components/pajamas/button_component.rb', line 54 def initialize( category: :primary, variant: :default, size: :medium, type: :button, disabled: false, loading: false, block: false, label: false, selected: false, icon: nil, href: nil, form: false, target: nil, method: nil, button_options: {}, button_text_classes: nil, icon_classes: nil ) @category = filter_attribute(category.to_sym, CATEGORY_OPTIONS) @variant = filter_attribute(variant.to_sym, VARIANT_OPTIONS) @size = filter_attribute(size.to_sym, SIZE_OPTIONS) @type = filter_attribute(type.to_sym, TYPE_OPTIONS, default: :button) @disabled = disabled @loading = loading @block = block @label = label @selected = selected @icon = icon @href = href @form = form @target = filter_attribute(target, TARGET_OPTIONS) @method = filter_attribute(method, METHOD_OPTIONS) = = @icon_classes = icon_classes end |