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 +4 -4
- data/Gemfile.lock +1 -1
- data/app/assets/builds/avo/application.css +3 -0
- data/app/assets/stylesheets/css/components/button.css +5 -0
- data/app/components/avo/base_component.rb +34 -5
- data/app/components/avo/sidebar/link_component.rb +1 -1
- data/lib/avo/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 78097e52553f1c4b182f2542a08a85379f1fb97804598c84e6efb48fc24ccc30
|
|
4
|
+
data.tar.gz: f372148210d4b8ac86b22117ab5222e67c449649d0f5e0045c504a8902ae3e40
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 68fac9ebc6f6c49005b06f106e566308ad593d25232a56d36a2f54042dc877f6ed07e37e0da3d9fd33a5bbddd21d2220960fe24b3a0b97cc1042d13dc99e5eee
|
|
7
|
+
data.tar.gz: 5314103f75eef43decd2326a4cb1a1fab7fc7833a6a9ba000bafd117504af078d4d72a7356083ccfe7217a6d5501b0b906e07abf612222c0685ea2401adaf8c7
|
data/Gemfile.lock
CHANGED
|
@@ -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
|
-
#
|
|
19
|
+
# Supports modifier tokens rendered in a friendly OS-aware way.
|
|
20
20
|
def hotkey_badge(hotkey, **html_options)
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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)
|
data/lib/avo/version.rb
CHANGED