Sha256: 2cd67fa291f7b6f431c212101a997b79ae254df42225392eb084e9f0810db40d

Contents?: true

Size: 1.96 KB

Versions: 3

Compression:

Stored size: 1.96 KB

Contents

<%= render component_tag(:div,
  x: {
    data: x_data("button", alpine_data),
    "@click": on_click,
    dropdown: dropdown_opts,
    bind: "root"
  },
  class: component_classes,
) do %>
  <%= coco_tag(button_tag_name,
    **button_attrs,
    class: "button-element",
    x: {
      "dropdown:trigger": (true if dropdown?),
      "@click": ("checkConfirmation" if confirm?),
      ":disabled": "disabled"
    }
  ) do %>
    <span class="button-inner">
      <% states.each do |name, props| %>
        <% if props[:icon].present? %>
          <% if states.many? %>
            <span
              class="button-icon"
              x-ref="<%= name %>Icon"
              x-show="showIcon('<%= name %>')"
              <%= "x-cloak" unless name == :default %>>
              <%= props[:icon] %>
            </span>
          <% else %>
            <span class="button-icon" x-ref="defaultIcon">
              <%= props[:icon] %>
            </span>
          <% end %>
        <% end %>
      <% end %>
      
      <% unless icon_only? %>
        <% states.each do |name, props| %>
          <% if states.many? %>
            <span
              class="button-content"
              x-ref="<%= name %>Content"
              x-show="showContent('<%= name %>')"
              <%= "x-cloak" unless name == :default %>>
              <%= props[:text] %>
            </span>
          <% else %>
            <span class="button-content" x-ref="defaultContent">
              <%= props[:text] %>
            </span>
          <% end %>
        <% end %>
      <% end %>

      <% if toggle? %>
        <% if toggle_direction == :horizontal %>
          <%= coco_icon(:chevron_right, class: "button-toggle") %>
        <% else %>
          <%= coco_icon(:chevron_down, class: "button-toggle") %>
        <% end %>
      <% end %>
    </span>
  <% end %>

  <% if dropdown? %>
    <div x-dropdown:content>
      <div class="button-dropdown">
        <%= dropdown %>
      </div>
    </div>
  <% end %>
<% end %>

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
coveragebook_components-0.5.2 app/components/coco/base/button/button.html.erb
coveragebook_components-0.5.1 app/components/coco/base/button/button.html.erb
coveragebook_components-0.5.0 app/components/coco/base/button/button.html.erb