/
Button.purs
32 lines (27 loc) · 1.05 KB
/
Button.purs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
-- | See [Button](https://facebook.github.io/react-native/docs/button.html)
module ReactNative.Components.Button (
button, button_, button'
) where
import Data.Record.Class (class Subrow)
import React (ReactElement)
import ReactNative.Events (TouchEvent, EventHandler)
import ReactNative.PropTypes.Color (Color)
import ReactNative.Unsafe.ApplyProps (unsafeApplyProps)
import ReactNative.Unsafe.Components (buttonU)
import Prelude
type ButtonPropsO eff = (
accessibilityLabel :: String
, color :: Color
, disabled :: Boolean
, onPress :: EventHandler eff TouchEvent
, title :: String
)
-- | Create a button with the given `title` and `onPress` handler
button :: forall eff. String -> EventHandler eff TouchEvent -> ReactElement
button title onPress = buttonU {title, onPress}
-- | Create a button with the given `title`
button_ :: String -> ReactElement
button_ title = buttonU {title}
-- | Create a button with the given props and `title`
button' :: forall o eff. Subrow o (ButtonPropsO eff) => {|o} -> ReactElement
button' = buttonU <<< unsafeApplyProps