hotwire_native_version_gate 1.1.0 → 1.2.0
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/VERSION +1 -1
- data/lib/hotwire_native_version_gate/concern.rb +16 -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: 2b97bba1a1e02a907c1e5cafb0ec08cec2bb737a6908eac6f31f05faacadbdaf
|
|
4
|
+
data.tar.gz: e5a764d6f3b9cc83a68064a567dcad5188000c9fb6ec3538e78ba450ca4a1961
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 64f478dc48e9b1a9dcb31860533e6db3aefbc22271dddbb56c9b01c7f3eb6ea398110389cc2bf726e096ab5adecb815e0a5adddc0c63ccd0a498267336859129
|
|
7
|
+
data.tar.gz: f644a5ffe8d3a47298247936879f59f73144d2f16f63ae9d5735dc9c720d98f92dc8af69326bf1324565181dbe2057bfa94227d85a1e9cbaf4606aec745f2fca
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.
|
|
1
|
+
1.2.0
|
|
@@ -20,7 +20,7 @@ module HotwireNativeVersionGate
|
|
|
20
20
|
|
|
21
21
|
included do
|
|
22
22
|
if respond_to?(:helper_method)
|
|
23
|
-
helper_method :native_feature?, :native_ios?, :native_android?, :native_app_version, :native_app_platform
|
|
23
|
+
helper_method :native_feature?, :native_ios?, :native_android?, :native_app_version, :native_app_platform, :hotwire_native_html_attributes
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
@@ -54,5 +54,20 @@ module HotwireNativeVersionGate
|
|
|
54
54
|
user_agent = respond_to?(:request) && request.respond_to?(:user_agent) ? request.user_agent : nil
|
|
55
55
|
VersionGate.app_platform(user_agent)
|
|
56
56
|
end
|
|
57
|
+
|
|
58
|
+
# Space-separated data attributes for the root <html> tag, for Tailwind custom variants.
|
|
59
|
+
#
|
|
60
|
+
# <html <%= hotwire_native_html_attributes %>>
|
|
61
|
+
#
|
|
62
|
+
# Emits e.g. `data-hotwire-native data-native-ios` for iOS, or an empty string in the browser.
|
|
63
|
+
# Uses `hotwire_native_app?` from turbo-rails when available; otherwise falls back to platform helpers.
|
|
64
|
+
def hotwire_native_html_attributes
|
|
65
|
+
attrs = []
|
|
66
|
+
hotwire_native = respond_to?(:hotwire_native_app?) ? hotwire_native_app? : (native_ios? || native_android?)
|
|
67
|
+
attrs << "data-hotwire-native" if hotwire_native
|
|
68
|
+
attrs << "data-native-ios" if native_ios?
|
|
69
|
+
attrs << "data-native-android" if native_android?
|
|
70
|
+
attrs.join(" ")
|
|
71
|
+
end
|
|
57
72
|
end
|
|
58
73
|
end
|