avo 4.0.0.beta.4 → 4.0.0.beta.5

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: 8bc41072024aca335bb61ad71567c9654a2fa3efaa91cee5fa8ca97630fe352e
4
- data.tar.gz: c1ee0a7f198c106a9ad0050698f248ccce32a3e684ab35b5cc9876aecd9fd6f6
3
+ metadata.gz: 78097e52553f1c4b182f2542a08a85379f1fb97804598c84e6efb48fc24ccc30
4
+ data.tar.gz: f372148210d4b8ac86b22117ab5222e67c449649d0f5e0045c504a8902ae3e40
5
5
  SHA512:
6
- metadata.gz: 4e80b61da0c33adb3c3ec528e7541fdabf042645912cf87eac10b344061a4dff768120c5ec0845ce465b42824b994bb26763a02ed2b15fc8923d40b42601a37a
7
- data.tar.gz: 3e0e5e9acca71e4b43764bf7f9c47ec3f337208ce65bf148be5cc12450ae2e7c19d6031399269416b4fa3dd343ff245dc5c584afbf1077303dbc7a07dda1801b
6
+ metadata.gz: 68fac9ebc6f6c49005b06f106e566308ad593d25232a56d36a2f54042dc877f6ed07e37e0da3d9fd33a5bbddd21d2220960fe24b3a0b97cc1042d13dc99e5eee
7
+ data.tar.gz: 5314103f75eef43decd2326a4cb1a1fab7fc7833a6a9ba000bafd117504af078d4d72a7356083ccfe7217a6d5501b0b906e07abf612222c0685ea2401adaf8c7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- avo (4.0.0.beta.4)
4
+ avo (4.0.0.beta.5)
5
5
  actionview (>= 6.1)
6
6
  active_link_to
7
7
  activerecord (>= 6.1)
@@ -12078,6 +12078,9 @@
12078
12078
  --btn-color-accent-content: var(--color-rose-600);
12079
12079
  --btn-color-accent-foreground: var(--color-white);
12080
12080
  }
12081
+ &>span >kbd {
12082
+ margin-block: calc(var(--spacing) * -1);
12083
+ }
12081
12084
  }
12082
12085
  .dark {
12083
12086
  .button--style-primary {
@@ -141,6 +141,11 @@
141
141
  --btn-color-accent-content: var(--color-rose-600);
142
142
  --btn-color-accent-foreground: var(--color-white);
143
143
  }
144
+
145
+ /* The kbd element is taller than the button text, so we need to offset it */
146
+ &>span >kbd {
147
+ @apply -my-1;
148
+ }
144
149
  }
145
150
 
146
151
  .dark {
@@ -16,16 +16,45 @@ class Avo::BaseComponent < ViewComponent::Base
16
16
  def component_name = self.class.name.to_s.underscore
17
17
 
18
18
  # Renders a <kbd> badge for a hotkey string.
19
- # Skips modifier combos like "Meta+Enter" only renders simple keys.
19
+ # Supports modifier tokens rendered in a friendly OS-aware way.
20
20
  def hotkey_badge(hotkey, **html_options)
21
- first_key = hotkey.to_s.split.first
22
- return if first_key.blank? || first_key.include?("+")
23
-
24
- tag.kbd(first_key.upcase, **html_options)
21
+ # `@github/hotkey` uses:
22
+ # - `+` for modifier combos (e.g. "Mod+Enter")
23
+ # - spaces for sequences/alternatives (e.g. "g n" or "Meta+Enter Control+Enter")
24
+ #
25
+ # Render key parts for the badge, mapping supported modifiers to OS-aware glyphs.
26
+ keys = hotkey.to_s.split(/[+\s]+/).reject(&:blank?)
27
+
28
+ first_key = keys.first
29
+ return if first_key.blank?
30
+
31
+ content_tag(:span, **html_options) do
32
+ # Render multiple keys (e.g. "g n") inside a wrapper so any provided
33
+ # classes (like `ms-auto`) are applied once.
34
+ safe_join(keys.map { |key| render_hotkey_badge_key(key) }, " ")
35
+ end
25
36
  end
26
37
 
27
38
  private
28
39
 
40
+ def render_hotkey_badge_key(key)
41
+ token = key.to_s.strip
42
+
43
+ case token.downcase
44
+ when "mod"
45
+ tag.kbd do
46
+ helpers.safe_join([
47
+ tag.abbr("⌘", title: "Command", class: "no-underline os-pc:hidden"),
48
+ tag.abbr("CTRL", title: "CTRL", class: "no-underline os-mac:hidden")
49
+ ])
50
+ end
51
+ when "enter", "return"
52
+ tag.kbd("↵")
53
+ else
54
+ tag.kbd(token.upcase)
55
+ end
56
+ end
57
+
29
58
  # Use the @parent_resource to fetch the field using the @reflection name.
30
59
  def field
31
60
  find_association_field(resource: @parent_resource, association: params[:related_name] || @reflection.name)
@@ -82,6 +82,6 @@ class Avo::Sidebar::LinkComponent < Avo::BaseComponent
82
82
  def build_link_data(data, hotkey)
83
83
  return data if hotkey.blank?
84
84
 
85
- data.merge(hotkey: hotkey.to_s.first)
85
+ data.merge(hotkey: hotkey)
86
86
  end
87
87
  end
data/lib/avo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Avo
2
- VERSION = "4.0.0.beta.4" unless const_defined?(:VERSION)
2
+ VERSION = "4.0.0.beta.5" unless const_defined?(:VERSION)
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avo
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.beta.4
4
+ version: 4.0.0.beta.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Marin