@ruby-native/react 0.10.6 → 0.10.8
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.
- package/README.md +9 -0
- package/index.js +13 -0
- 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
|
@@ -90,3 +90,16 @@ export function NativeSubmitButton({ title = "Save", click = "[type='submit']" }
|
|
|
90
90
|
})
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
export function NativeBadge({ count, home, tab }) {
|
|
94
|
+
if (count != null && home == null) home = count
|
|
95
|
+
if (count != null && tab == null) tab = count
|
|
96
|
+
const props = { "data-native-badge": "", hidden: true }
|
|
97
|
+
if (home != null) props["data-native-badge-home"] = home
|
|
98
|
+
if (tab != null) props["data-native-badge-tab"] = tab
|
|
99
|
+
return createElement("div", props)
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function nativeHaptic(feedback = "success", data = {}) {
|
|
103
|
+
return { ...data, "data-native-haptic": feedback }
|
|
104
|
+
}
|
|
105
|
+
|