@ruby-native/react 0.10.6 → 0.10.9

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.
Files changed (3) hide show
  1. package/README.md +9 -0
  2. package/index.js +32 -0
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -41,6 +41,15 @@ Each component renders a hidden `data-native-*` signal element that the Ruby Nat
41
41
  - `NativeMenuItem` - item inside a native menu
42
42
  - `NativeSubmitButton` - native "Save" button that submits a form
43
43
  - `NativeOverscroll` - per-page overscroll colors
44
+ - `NativeBadge` - set the badge count on a home screen or tab bar icon
45
+
46
+ ## Helpers
47
+
48
+ - `nativeHaptic(feedback = "success", data = {})` - returns props to spread onto a clickable element so tapping it triggers native haptic feedback:
49
+
50
+ ```jsx
51
+ <button {...nativeHaptic("success")}>Save</button>
52
+ ```
44
53
 
45
54
  ## Docs
46
55
 
package/index.js CHANGED
@@ -64,6 +64,25 @@ export function NativeMenuItem({ title, href, click, icon, icons, selected }) {
64
64
  return createElement("div", props)
65
65
  }
66
66
 
67
+ export function NativeShareButton({ position = "trailing", title = "Share", icon = "square.and.arrow.up", icons, url }) {
68
+ const resolved = resolveIcon(icon, icons)
69
+ const props = { "data-native-button": true, "data-native-share": "" }
70
+ if (title) props["data-native-title"] = title
71
+ if (resolved) props["data-native-icon"] = resolved
72
+ if (position) props["data-native-position"] = position
73
+ if (url) props["data-native-share-url"] = url
74
+ return createElement("div", props)
75
+ }
76
+
77
+ export function NativeShareMenuItem({ title = "Share", url, icon = "square.and.arrow.up", icons, selected }) {
78
+ const resolved = resolveIcon(icon, icons)
79
+ const props = { "data-native-menu-item": true, "data-native-share": "", "data-native-title": title }
80
+ if (url) props["data-native-share-url"] = url
81
+ if (resolved) props["data-native-icon"] = resolved
82
+ if (selected) props["data-native-selected"] = ""
83
+ return createElement("div", props)
84
+ }
85
+
67
86
  export function NativeFab({ icon, icons, href, click }) {
68
87
  const resolved = resolveIcon(icon, icons)
69
88
  if (!resolved) throw new Error("NativeFab requires `icon` or `icons`")
@@ -90,3 +109,16 @@ export function NativeSubmitButton({ title = "Save", click = "[type='submit']" }
90
109
  })
91
110
  }
92
111
 
112
+ export function NativeBadge({ count, home, tab }) {
113
+ if (count != null && home == null) home = count
114
+ if (count != null && tab == null) tab = count
115
+ const props = { "data-native-badge": "", hidden: true }
116
+ if (home != null) props["data-native-badge-home"] = home
117
+ if (tab != null) props["data-native-badge-tab"] = tab
118
+ return createElement("div", props)
119
+ }
120
+
121
+ export function nativeHaptic(feedback = "success", data = {}) {
122
+ return { ...data, "data-native-haptic": feedback }
123
+ }
124
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ruby-native/react",
3
- "version": "0.10.6",
3
+ "version": "0.10.9",
4
4
  "description": "React components for Ruby Native",
5
5
  "main": "index.js",
6
6
  "files": ["index.js", "README.md"],