Guest User

Untitled

a guest
Oct 23rd, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. // @flow
  2.  
  3. import React from "react"
  4.  
  5. import Hoverable from "../../modules/Hoverable"
  6. import Focusable from "../../modules/Focusable"
  7. import Touchable from "../../modules/Touchable"
  8.  
  9. type PropsType = {
  10. children?: React$Element<any>,
  11.  
  12. // hoc
  13. hovered: boolean,
  14. focused: boolean,
  15. touched: boolean,
  16.  
  17. // users
  18. component: Class<React$Component<*,*,*>>,
  19. style?: any,
  20. hoveredStyle?: any,
  21. focusedStyle?: any,
  22. touchedStyle?: any,
  23. hoveredOrFocusedStyle?: any,
  24. }
  25.  
  26. const Stylable = (props: PropsType): React$Element<any> => {
  27. const {
  28. component: Component,
  29. hovered,
  30. focused,
  31. touched,
  32. style,
  33. hoveredStyle,
  34. focusedStyle,
  35. touchedStyle,
  36. hoveredOrFocusedStyle,
  37. children,
  38. ...othersProps,
  39. } = props
  40.  
  41. return (
  42. <Component
  43. { ...othersProps }
  44. style={ [
  45. style,
  46. hovered && hoveredStyle,
  47. focused && focusedStyle,
  48. (hovered || focused) && hoveredOrFocusedStyle,
  49. touched && touchedStyle,
  50. ] }
  51. >
  52. { children }
  53. </Component>
  54. )
  55. }
  56.  
  57. export default Hoverable(Focusable(Touchable(Stylable)))
Add Comment
Please, Sign In to add comment