kiso 0.6.1.pre → 0.6.2.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b28c57b532dc53dad377cca677637615db58881e3109d6a6a5ecbbd1cce5b02e
4
- data.tar.gz: eca25e39e3e60d918dac9df9c4bbd2b696c558649bb48d8bc74f156e5171f56b
3
+ metadata.gz: 8e190287bffc19365594567c518032deea302c6dc22ef9a3e7aa4a5b5131c602
4
+ data.tar.gz: f22a684ad94ee787f066f886ff0dd611846dd09aef7d38a89488515f1eb55f19
5
5
  SHA512:
6
- metadata.gz: ab5fd9a21f185c579e8fd745b5709915e5e4aa30c2fcc38126c616ecbaa08495dce298997bb247ccc077205f84d82f2b33bb8cff764bfc7ce6a33527396dff8b
7
- data.tar.gz: d83b4e694f3559f20c0da252dbb631224fcd23a5514595a8d57f9631dd68a65f79d6377e0594afe4c07968df9330c906b444f9e83a882b82fcf540fbcc364158
6
+ metadata.gz: c892bfb57c5155239295cc7ce5cd9f3a6747504a57883b4fa49ea7b1e9f637c164285af0a8c98824972121d13c9f57f691d95f808351bacebc176255641583d0
7
+ data.tar.gz: 215260ab8612f8521cc8f95357cc527968cb90be8886db63867441e7cf75714dce789b0d40fd48d624bb864bc129afb782defdaef74cb8cb554249b7b73729c5
@@ -1,16 +1,15 @@
1
1
  /* ── Button ──────────────────────────────────────────────────────────────────
2
2
  Default display value for the Button component.
3
3
 
4
- Why CSS instead of a Tailwind class?
5
- The theme module applies `inline-flex` via Tailwind, but Tailwind utilities
6
- live in @layer utilities the highest-priority layer. That means when JS
7
- removes a `hidden` class, the button's `inline-flex` (also in utilities)
8
- has no cascade advantage to restore visibility. Placing the default display
9
- in @layer components (lower priority) lets utility classes like `hidden`
10
- override it naturally, while still restoring inline-flex when `hidden` is
11
- removed.
4
+ Why CSS in addition to the theme class?
5
+ The theme module includes `inline-flex` so the class string is
6
+ self-contained (works on link_to, button_to, etc. without data-slot).
7
+ This @layer components rule provides a lower-priority fallback for
8
+ kui(:button) elements so that utility classes like `hidden` can override
9
+ display naturally, restoring inline-flex when `hidden` is removed.
12
10
 
13
- Fixes: https://github.com/steveclarke/kiso/issues/200 */
11
+ Fixes: https://github.com/steveclarke/kiso/issues/200
12
+ See also: https://github.com/steveclarke/kiso/issues/229 */
14
13
 
15
14
  @layer components {
16
15
  [data-slot="button"] {
@@ -1,14 +1,17 @@
1
1
  <%# locals: (color: :primary, variant: :solid, size: :md, block: false,
2
2
  type: :button, href: nil, method: nil, disabled: false,
3
- form: {}, css_classes: "", **component_options) %>
3
+ loading: false, form: {}, css_classes: "", **component_options) %>
4
4
  <%# Polymorphic button that renders as <button>, <a>, or button_to depending on props.
5
5
  With href: renders an anchor tag. With href: + method: (non-GET) renders a Rails
6
- button_to form for safe non-GET navigation. Without href: renders a plain <button>. %>
6
+ button_to form for safe non-GET navigation. Without href: renders a plain <button>.
7
+ With loading: true, prepends an animated spinner and disables the button. %>
7
8
  <%
8
9
  css = Kiso::Themes::Button.render(
9
10
  color: color, variant: variant, size: size, block: block, class: css_classes)
10
11
  data = kiso_prepare_options(component_options, slot: "button")
11
12
  use_button_to = href.present? && method.present? && method.to_s != "get"
13
+ is_disabled = disabled || loading
14
+ component_options[:"aria-busy"] = true if loading
12
15
  %>
13
16
  <% if use_button_to %>
14
17
  <%= button_to href,
@@ -16,21 +19,24 @@
16
19
  class: css,
17
20
  form_class: "contents",
18
21
  data: data,
19
- disabled: disabled || nil,
22
+ disabled: is_disabled || nil,
20
23
  form: form.presence,
21
24
  **component_options do %>
25
+ <%= kiso_component_icon(:spinner, class: "animate-spin") if loading %>
22
26
  <%= yield %>
23
27
  <% end %>
24
28
  <% elsif href.present? %>
25
29
  <% component_options[:href] = href
26
- component_options[:"aria-disabled"] = true if disabled %>
30
+ component_options[:"aria-disabled"] = true if is_disabled %>
27
31
  <%= content_tag :a, class: css, data: data, **component_options do %>
32
+ <%= kiso_component_icon(:spinner, class: "animate-spin") if loading %>
28
33
  <%= yield %>
29
34
  <% end %>
30
35
  <% else %>
31
36
  <% component_options[:type] = type
32
- component_options[:disabled] = true if disabled %>
37
+ component_options[:disabled] = true if is_disabled %>
33
38
  <%= content_tag :button, class: css, data: data, **component_options do %>
39
+ <%= kiso_component_icon(:spinner, class: "animate-spin") if loading %>
34
40
  <%= yield %>
35
41
  <% end %>
36
42
  <% end %>
@@ -1,15 +1,40 @@
1
- <%# locals: (variant: :default, inset: false, disabled: false, css_classes: "", **component_options) %>
2
- <%= content_tag :div,
3
- class: Kiso::Themes::DropdownMenuItem.render(variant: variant, class: css_classes),
4
- role: "menuitem",
5
- tabindex: "-1",
6
- data: kiso_prepare_options(component_options, slot: "dropdown-menu-item",
7
- kiso__dropdown_menu_target: "item",
8
- action: "click->kiso--dropdown-menu#selectItem",
9
- inset: (inset ? "" : nil),
10
- variant: (variant == :destructive ? "destructive" : nil),
11
- disabled: (disabled ? "true" : nil)),
12
- aria: {disabled: (disabled || nil)},
13
- **component_options do %>
14
- <%= yield %>
1
+ <%# locals: (variant: :default, inset: false, disabled: false,
2
+ href: nil, method: nil, form: {},
3
+ css_classes: "", **component_options) %>
4
+ <%# Clickable menu action. Polymorphic tag: <div> by default, <a> when href:
5
+ is provided, button_to form when href: + method: (non-GET). %>
6
+ <%
7
+ css = Kiso::Themes::DropdownMenuItem.render(variant: variant, class: css_classes)
8
+ data = kiso_prepare_options(component_options, slot: "dropdown-menu-item",
9
+ kiso__dropdown_menu_target: "item",
10
+ action: "click->kiso--dropdown-menu#selectItem",
11
+ inset: (inset ? "" : nil),
12
+ variant: (variant == :destructive ? "destructive" : nil),
13
+ disabled: (disabled ? "true" : nil))
14
+ component_options[:role] = "menuitem"
15
+ component_options[:tabindex] = "-1"
16
+ component_options[:aria] = { disabled: (disabled || nil) }
17
+ use_button_to = href.present? && method.present? && method.to_s != "get"
18
+ %>
19
+ <% if use_button_to %>
20
+ <%= button_to href,
21
+ method: method,
22
+ class: css,
23
+ form_class: "contents w-full",
24
+ data: data,
25
+ disabled: disabled || nil,
26
+ form: form.presence,
27
+ **component_options do %>
28
+ <%= yield %>
29
+ <% end %>
30
+ <% elsif href.present? %>
31
+ <% component_options[:href] = href
32
+ component_options[:"aria-disabled"] = true if disabled %>
33
+ <%= content_tag :a, class: css, data: data, **component_options do %>
34
+ <%= yield %>
35
+ <% end %>
36
+ <% else %>
37
+ <%= content_tag :div, class: css, data: data, **component_options do %>
38
+ <%= yield %>
39
+ <% end %>
15
40
  <% end %>
@@ -14,7 +14,7 @@ module Kiso
14
14
  # - +size+ — :xs, :sm, :md (default), :lg, :xl
15
15
  # - +block+ — +true+ for full-width, +false+ (default)
16
16
  Button = ClassVariants.build(
17
- base: "items-center justify-center gap-2 font-medium whitespace-nowrap shrink-0 " \
17
+ base: "inline-flex items-center justify-center gap-2 font-medium whitespace-nowrap shrink-0 " \
18
18
  "transition-all " \
19
19
  "focus-visible:outline-2 focus-visible:outline-offset-2 " \
20
20
  "disabled:pointer-events-none disabled:opacity-50 " \
data/lib/kiso/version.rb CHANGED
@@ -5,5 +5,5 @@ module Kiso
5
5
  # Updated by +bin/release+.
6
6
  #
7
7
  # @return [String]
8
- VERSION = "0.6.1.pre"
8
+ VERSION = "0.6.2.pre"
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kiso
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1.pre
4
+ version: 0.6.2.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Clarke