stories.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. import React from 'react';
  2. import { storiesOf } from '@storybook/react';
  3. import { action } from '@storybook/addon-actions';
  4. import IngredientForm from './index';
  5. import { assocPath } from 'ramda';
  6. const tabs = [
  7. 'for the chicken',
  8. 'for the sauce',
  9. 'for the rice',
  10. 'for the extra steps',
  11. ]
  12. class Form extends React.Component {
  13. constructor(props) {
  14. super(props);
  15. this.state = {
  16. components: [
  17. {
  18. "name": "",
  19. "ingredients": []
  20. },
  21. {
  22. "name": "For the Chicken:",
  23. "ingredients": [
  24. {
  25. "name": "thin boneless skinless chicken breast",
  26. "quantity": 1.5,
  27. "unit": "pound",
  28. "_original": "1-1/2 lb of Thin Boneless Skinless Chicken Breast",
  29. "suggestions": []
  30. },
  31. {
  32. "name": "olive oil",
  33. "quantity": 2,
  34. "unit": "tablespoon",
  35. "_original": "2 Tbsp of Olive Oil",
  36. "suggestions": []
  37. },
  38. {
  39. "name": "juice of lime",
  40. "quantity": 1,
  41. "unit": "",
  42. "_original": "Juice of 1 Lime",
  43. "suggestions": []
  44. },
  45. {
  46. "name": "chili powder",
  47. "quantity": 0.5,
  48. "unit": "teaspoon",
  49. "_original": "1/2 tsp of Chili Powder",
  50. "suggestions": [
  51. {
  52. "_id": "5cf1397d72cd194524435041",
  53. "name": "cocoa powder",
  54. "variants": [
  55. "cocoa"
  56. ],
  57. "equivalences": {
  58. "cup": 1,
  59. "gr": 118,
  60. "tbsp": 16,
  61. "tsp": 48
  62. },
  63. "referenceUnit": "cup",
  64. "prefferedUnit": "gr"
  65. },
  66. {
  67. "_id": "5cf1397d72cd19452443503c",
  68. "name": "icing sugar",
  69. "variants": [
  70. "confectioner sugar",
  71. "powdered sugar"
  72. ],
  73. "equivalences": {
  74. "cup": 1,
  75. "gr": 125,
  76. "oz": 0.27,
  77. "tbsp": 15,
  78. "tsp": 45,
  79. "lb": 0.27
  80. },
  81. "referenceUnit": "cup",
  82. "prefferedUnit": "gr"
  83. }
  84. ]
  85. },
  86. {
  87. "name": "oregano",
  88. "quantity": 0.5,
  89. "unit": "teaspoon",
  90. "_original": "1/2 tsp of Oregano",
  91. "suggestions": []
  92. },
  93. {
  94. "name": "cumin",
  95. "quantity": 0.5,
  96. "unit": "teaspoon",
  97. "_original": "1/2 tsp of Cumin",
  98. "suggestions": []
  99. },
  100. {
  101. "name": "paprika",
  102. "quantity": 0.5,
  103. "unit": "teaspoon",
  104. "_original": "1/2 tsp of Paprika",
  105. "suggestions": []
  106. },
  107. {
  108. "name": "granulated garlic",
  109. "quantity": 0.5,
  110. "unit": "teaspoon",
  111. "_original": "1/2 tsp of Granulated Garlic",
  112. "suggestions": [
  113. {
  114. "_id": "5cf1397d72cd19452443503b",
  115. "name": "granulated sugar",
  116. "variants": [
  117. "sugar",
  118. "plain sugar"
  119. ],
  120. "equivalences": {
  121. "cup": 1,
  122. "gr": 200,
  123. "oz": 7.1,
  124. "tbsp": 14,
  125. "tsp": 42,
  126. "lb": 0.4
  127. },
  128. "referenceUnit": "cup",
  129. "prefferedUnit": "gr"
  130. }
  131. ]
  132. },
  133. {
  134. "name": "salt, to taste",
  135. "quantity": 0,
  136. "unit": "",
  137. "_original": "Salt, to taste",
  138. "suggestions": []
  139. }
  140. ]
  141. },
  142. {
  143. "name": "For the Dressing:",
  144. "ingredients": [
  145. {
  146. "name": "plain greek yogurt",
  147. "quantity": 0.5,
  148. "unit": "cup",
  149. "_original": "1/2 cup of Plain Greek Yogurt",
  150. "suggestions": [
  151. {
  152. "_id": "5cf1397d72cd194524435040",
  153. "name": "yogurt",
  154. "variants": [
  155. "plain yogurt"
  156. ],
  157. "equivalences": {
  158. "cup": 1,
  159. "gr": 245,
  160. "oz": 8.64,
  161. "tbsp": 16,
  162. "tsp": 48
  163. },
  164. "referenceUnit": "cup",
  165. "prefferedUnit": "gr"
  166. },
  167. {
  168. "_id": "5cf1397d72cd19452443503b",
  169. "name": "granulated sugar",
  170. "variants": [
  171. "sugar",
  172. "plain sugar"
  173. ],
  174. "equivalences": {
  175. "cup": 1,
  176. "gr": 200,
  177. "oz": 7.1,
  178. "tbsp": 14,
  179. "tsp": 42,
  180. "lb": 0.4
  181. },
  182. "referenceUnit": "cup",
  183. "prefferedUnit": "gr"
  184. },
  185. {
  186. "_id": "5cf1397d72cd194524435030",
  187. "name": "all purpose flour",
  188. "variants": [
  189. "plain flour",
  190. "all purpose flour",
  191. "regular flour",
  192. "flour"
  193. ],
  194. "equivalences": {
  195. "cup": 1,
  196. "gr": 125,
  197. "tbsp": 15.5,
  198. "tsp": 47
  199. },
  200. "referenceUnit": "cup",
  201. "prefferedUnit": "gr",
  202. "translation": {
  203. "dutch": "patentbloem"
  204. }
  205. }
  206. ]
  207. },
  208. {
  209. "name": "fresh cilantro",
  210. "quantity": 1,
  211. "unit": "cup",
  212. "_original": "1 cup of Fresh Cilantro",
  213. "suggestions": []
  214. },
  215. {
  216. "name": "scallions, roughly chopped",
  217. "quantity": 2,
  218. "unit": "",
  219. "_original": "2 Scallions, roughly chopped",
  220. "suggestions": []
  221. },
  222. {
  223. "name": "juice of lime or more, according to taste",
  224. "quantity": 1,
  225. "unit": "",
  226. "_original": "Juice of 1 Lime or more, according to taste",
  227. "suggestions": []
  228. },
  229. {
  230. "name": "olive oil",
  231. "quantity": 1,
  232. "unit": "tablespoon",
  233. "_original": "1 Tbsp of Olive Oil",
  234. "suggestions": []
  235. },
  236. {
  237. "name": "salt, to taste",
  238. "quantity": 0,
  239. "unit": "",
  240. "_original": "Salt, to taste",
  241. "suggestions": []
  242. }
  243. ]
  244. },
  245. {
  246. "name": "For the rest of the salad:",
  247. "ingredients": [
  248. {
  249. "name": "fresh lettuce of your choice",
  250. "quantity": 0,
  251. "unit": "",
  252. "_original": "Fresh Lettuce of your choice",
  253. "suggestions": []
  254. },
  255. {
  256. "name": "bell peppers, halved and seeded",
  257. "quantity": 2,
  258. "unit": "",
  259. "_original": "2 Bell Peppers, halved and seeded",
  260. "suggestions": []
  261. },
  262. {
  263. "name": "scallions or red onion, sliced",
  264. "quantity": 0,
  265. "unit": "",
  266. "_original": "Scallions or REd Onion, sliced",
  267. "suggestions": []
  268. },
  269. {
  270. "name": "pico de gallo salsa",
  271. "quantity": 0.5,
  272. "unit": "cup",
  273. "_original": "1/2 cup of Pico De Gallo Salsa",
  274. "suggestions": []
  275. },
  276. {
  277. "name": "avocado, sliced",
  278. "quantity": 1,
  279. "unit": "",
  280. "_original": "1 Avocado, sliced",
  281. "suggestions": []
  282. }
  283. ]
  284. }
  285. ]
  286. }
  287. }
  288. updateField = (key) => {
  289. return (e) => {
  290. const newValue = e.currentTarget.value;
  291. this.setState(assocPath(key, newValue, this.state.components))
  292. }
  293. }
  294. render(){
  295. return (
  296. <IngredientForm
  297. components={this.state.components}
  298. updateField={this.updateField}
  299. />
  300. )
  301. }
  302. }
  303. storiesOf('IngredientForm', module)
  304. .add('Basic ingredients form', () => <Form/>)