class Playbook::PbButton::Button
def classname
def classname button_class = generate_classname("pb_button_kit", variant, full_width_class, disabled_class, loading_class) button_class + size_class + default_reaction_class + highlight_active end
def default_reaction_class
def default_reaction_class variant === "reaction" && !object.valid_emoji(object.icon) ? " reaction_default" : "" end
def disabled_class
def disabled_class disabled ? "disabled" : "enabled" end
def full_width_class
def full_width_class full_width ? "block" : "inline" end
def highlight_active
def highlight_active variant === "reaction" && object.highlight ? " active" : "" end
def link_options
def link_options options.tap do |option| option[:href] = link option[:role] = "link" option[:target] = target_attribute if target_attribute.present? option[:tabindex] = 0 end end
def loading_class
def loading_class loading ? "loading" : nil end
def options
def options options = { class: classname, disabled: disabled, id: id, role: "button", tabindex: 0, type: type, value: value, form: form, }.compact combined_html_options.merge!(options) if combined_html_options.present? end
def size_class
def size_class size ? " size_#{size}" : "" end
def spinner_path
def spinner_path "app/pb_kits/playbook/utilities/icons/spinner.svg" end
def tag
def tag link ? "a" : "button" end
def target_attribute
def target_attribute if target && link target elsif new_window "_blank" end end
def valid_emoji(icon)
def valid_emoji(icon) emoji_regex = /\p{Emoji}/ emoji_regex.match?(icon) end