Button.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. import variable from "./../variables/platform";
  2. export default (variables = variable) => {
  3. const platformStyle = variables.platformStyle;
  4. const platform = variables.platform;
  5. const buttonTheme = {
  6. ".disabled": {
  7. backgroundColor: variables.btnDisabledBg
  8. },
  9. ".bordered": {
  10. ".dark": {
  11. "NativeBase.Text": {
  12. color: "#000"
  13. },
  14. "NativeBase.Icon": {
  15. color: "#000"
  16. },
  17. "NativeBase.IconNB": {
  18. color: "#000"
  19. },
  20. backgroundColor: "transparent",
  21. borderColor: "#000",
  22. borderWidth: variables.borderWidth * 2
  23. },
  24. ".light": {
  25. "NativeBase.Text": {
  26. color: "#f4f4f4"
  27. },
  28. "NativeBase.Icon": {
  29. color: "#f4f4f4"
  30. },
  31. "NativeBase.IconNB": {
  32. color: "#f4f4f4"
  33. },
  34. backgroundColor: "transparent",
  35. borderColor: "#f4f4f4",
  36. borderWidth: variables.borderWidth * 2
  37. },
  38. ".primary": {
  39. "NativeBase.Text": {
  40. color: variables.btnPrimaryBg
  41. },
  42. "NativeBase.Icon": {
  43. color: variables.btnPrimaryBg
  44. },
  45. "NativeBase.IconNB": {
  46. color: variables.btnPrimaryBg
  47. },
  48. backgroundColor: "transparent",
  49. borderColor: variables.btnPrimaryBg,
  50. borderWidth: variables.borderWidth * 2
  51. },
  52. ".success": {
  53. "NativeBase.Text": {
  54. color: variables.btnSuccessBg
  55. },
  56. "NativeBase.Icon": {
  57. color: variables.btnSuccessBg
  58. },
  59. "NativeBase.IconNB": {
  60. color: variables.btnSuccessBg
  61. },
  62. backgroundColor: "transparent",
  63. borderColor: variables.btnSuccessBg,
  64. borderWidth: variables.borderWidth * 2
  65. },
  66. ".info": {
  67. "NativeBase.Text": {
  68. color: variables.btnInfoBg
  69. },
  70. "NativeBase.Icon": {
  71. color: variables.btnInfoBg
  72. },
  73. "NativeBase.IconNB": {
  74. color: variables.btnInfoBg
  75. },
  76. backgroundColor: "transparent",
  77. borderColor: variables.btnInfoBg,
  78. borderWidth: variables.borderWidth * 2
  79. },
  80. ".warning": {
  81. "NativeBase.Text": {
  82. color: variables.btnWarningBg
  83. },
  84. "NativeBase.Icon": {
  85. color: variables.btnWarningBg
  86. },
  87. "NativeBase.IconNB": {
  88. color: variables.btnWarningBg
  89. },
  90. backgroundColor: "transparent",
  91. borderColor: variables.btnWarningBg,
  92. borderWidth: variables.borderWidth * 2
  93. },
  94. ".danger": {
  95. "NativeBase.Text": {
  96. color: variables.btnDangerBg
  97. },
  98. "NativeBase.Icon": {
  99. color: variables.btnDangerBg
  100. },
  101. "NativeBase.IconNB": {
  102. color: variables.btnDangerBg
  103. },
  104. backgroundColor: "transparent",
  105. borderColor: variables.btnDangerBg,
  106. borderWidth: variables.borderWidth * 2
  107. },
  108. ".disabled": {
  109. backgroundColor: null,
  110. borderColor: variables.btnDisabledBg,
  111. borderWidth: variables.borderWidth * 2,
  112. "NativeBase.Text": {
  113. color: variables.btnDisabledBg
  114. }
  115. },
  116. "NativeBase.Text": {
  117. color: variables.btnPrimaryBg
  118. },
  119. "NativeBase.Icon": {
  120. color: variables.btnPrimaryBg
  121. },
  122. "NativeBase.IconNB": {
  123. color: variables.btnPrimaryBg
  124. },
  125. borderWidth: variables.borderWidth * 2,
  126. elevation: null,
  127. shadowColor: null,
  128. shadowOffset: null,
  129. shadowOpacity: null,
  130. shadowRadius: null,
  131. backgroundColor: "transparent"
  132. },
  133. ".dark": {
  134. ".bordered": {
  135. "NativeBase.Text": {
  136. color: "#000"
  137. },
  138. "NativeBase.Icon": {
  139. color: "#000"
  140. },
  141. "NativeBase.IconNB": {
  142. color: "#000"
  143. }
  144. },
  145. backgroundColor: "#000"
  146. },
  147. ".light": {
  148. ".transparent": {
  149. "NativeBase.Text": {
  150. color: "#f4f4f4"
  151. },
  152. "NativeBase.Icon": {
  153. color: "#f4f4f4"
  154. },
  155. "NativeBase.IconNB": {
  156. color: "#f4f4f4"
  157. },
  158. backgroundColor: null
  159. },
  160. ".bordered": {
  161. "NativeBase.Text": {
  162. color: "#f4f4f4"
  163. },
  164. "NativeBase.Icon": {
  165. color: "#f4f4f4"
  166. },
  167. "NativeBase.IconNB": {
  168. color: "#f4f4f4"
  169. }
  170. },
  171. "NativeBase.Text": {
  172. color: "#000"
  173. },
  174. "NativeBase.Icon": {
  175. color: "#000"
  176. },
  177. "NativeBase.IconNB": {
  178. color: "#000"
  179. },
  180. backgroundColor: "#f4f4f4"
  181. },
  182. ".primary": {
  183. ".bordered": {
  184. "NativeBase.Text": {
  185. color: variables.btnPrimaryBg
  186. },
  187. "NativeBase.Icon": {
  188. color: variables.btnPrimaryBg
  189. },
  190. "NativeBase.IconNB": {
  191. color: variables.btnPrimaryBg
  192. }
  193. },
  194. backgroundColor: variables.btnPrimaryBg
  195. },
  196. ".success": {
  197. ".bordered": {
  198. "NativeBase.Text": {
  199. color: variables.btnSuccessBg
  200. },
  201. "NativeBase.Icon": {
  202. color: variables.btnSuccessBg
  203. },
  204. "NativeBase.IconNB": {
  205. color: variables.btnSuccessBg
  206. }
  207. },
  208. backgroundColor: variables.btnSuccessBg
  209. },
  210. ".info": {
  211. ".bordered": {
  212. "NativeBase.Text": {
  213. color: variables.btnInfoBg
  214. },
  215. "NativeBase.Icon": {
  216. color: variables.btnInfoBg
  217. },
  218. "NativeBase.IconNB": {
  219. color: variables.btnInfoBg
  220. }
  221. },
  222. backgroundColor: variables.btnInfoBg
  223. },
  224. ".warning": {
  225. ".bordered": {
  226. "NativeBase.Text": {
  227. color: variables.btnWarningBg
  228. },
  229. "NativeBase.Icon": {
  230. color: variables.btnWarningBg
  231. },
  232. "NativeBase.IconNB": {
  233. color: variables.btnWarningBg
  234. }
  235. },
  236. backgroundColor: variables.btnWarningBg
  237. },
  238. ".danger": {
  239. ".bordered": {
  240. "NativeBase.Text": {
  241. color: variables.btnDangerBg
  242. },
  243. "NativeBase.Icon": {
  244. color: variables.btnDangerBg
  245. },
  246. "NativeBase.IconNB": {
  247. color: variables.btnDangerBg
  248. }
  249. },
  250. backgroundColor: variables.btnDangerBg
  251. },
  252. ".block": {
  253. justifyContent: "center",
  254. alignSelf: "stretch"
  255. },
  256. ".full": {
  257. justifyContent: "center",
  258. alignSelf: "stretch",
  259. borderRadius: 0
  260. },
  261. ".code":{
  262. justifyContent: "center",
  263. alignSelf: "center",
  264. paddingHorizontal:5,
  265. width:95,
  266. marginRight:5,
  267. marginLeft:2
  268. },
  269. ".rounded": {
  270. paddingHorizontal: variables.buttonPadding + 20,
  271. borderRadius: variables.borderRadiusLarge
  272. },
  273. ".transparent": {
  274. backgroundColor: "transparent",
  275. elevation: 0,
  276. shadowColor: null,
  277. shadowOffset: null,
  278. shadowRadius: null,
  279. shadowOpacity: null,
  280. "NativeBase.Text": {
  281. color: variables.btnPrimaryBg
  282. },
  283. "NativeBase.Icon": {
  284. color: variables.btnPrimaryBg
  285. },
  286. "NativeBase.IconNB": {
  287. color: variables.btnPrimaryBg
  288. },
  289. ".dark": {
  290. "NativeBase.Text": {
  291. color: "#000"
  292. },
  293. "NativeBase.IconNB": {
  294. color: "#000"
  295. },
  296. "NativeBase.Icon": {
  297. color: "#000"
  298. },
  299. backgroundColor: null
  300. },
  301. ".danger": {
  302. "NativeBase.Text": {
  303. color: variables.btnDangerBg
  304. },
  305. "NativeBase.IconNB": {
  306. color: variables.btnDangerBg
  307. },
  308. "NativeBase.Icon": {
  309. color: variables.btnDangerBg
  310. },
  311. backgroundColor: null
  312. },
  313. ".warning": {
  314. "NativeBase.Text": {
  315. color: variables.btnWarningBg
  316. },
  317. "NativeBase.IconNB": {
  318. color: variables.btnWarningBg
  319. },
  320. "NativeBase.Icon": {
  321. color: variables.btnWarningBg
  322. },
  323. backgroundColor: null
  324. },
  325. ".info": {
  326. "NativeBase.Text": {
  327. color: variables.btnInfoBg
  328. },
  329. "NativeBase.IconNB": {
  330. color: variables.btnInfoBg
  331. },
  332. "NativeBase.Icon": {
  333. color: variables.btnInfoBg
  334. },
  335. backgroundColor: null
  336. },
  337. ".primary": {
  338. "NativeBase.Text": {
  339. color: variables.btnPrimaryBg
  340. },
  341. "NativeBase.IconNB": {
  342. color: variables.btnPrimaryBg
  343. },
  344. "NativeBase.Icon": {
  345. color: variables.btnPrimaryBg
  346. },
  347. backgroundColor: null
  348. },
  349. ".success": {
  350. "NativeBase.Text": {
  351. color: variables.btnSuccessBg
  352. },
  353. "NativeBase.IconNB": {
  354. color: variables.btnSuccessBg
  355. },
  356. "NativeBase.Icon": {
  357. color: variables.btnSuccessBg
  358. },
  359. backgroundColor: null
  360. },
  361. ".light": {
  362. "NativeBase.Text": {
  363. color: "#f4f4f4"
  364. },
  365. "NativeBase.IconNB": {
  366. color: "#f4f4f4"
  367. },
  368. "NativeBase.Icon": {
  369. color: "#f4f4f4"
  370. },
  371. backgroundColor: null
  372. }
  373. },
  374. ".small": {
  375. height: 30,
  376. "NativeBase.Text": {
  377. fontSize: 14
  378. }
  379. },
  380. ".large": {
  381. height: 60,
  382. "NativeBase.Text": {
  383. fontSize: 22,
  384. lineHeight: 32
  385. }
  386. },
  387. ".capitalize": {},
  388. ".vertical": {
  389. flexDirection: "column",
  390. height: null
  391. },
  392. "NativeBase.Text": {
  393. fontFamily: variables.btnFontFamily,
  394. marginLeft: 0,
  395. marginRight: 0,
  396. color: variables.inverseTextColor,
  397. fontSize: variables.btnTextSize,
  398. lineHeight: variables.btnLineHeight
  399. // childPosition: 1
  400. },
  401. "NativeBase.Icon": {
  402. color: variables.inverseTextColor,
  403. fontSize: 24,
  404. marginHorizontal: 5,
  405. paddingTop: platform === "ios" ? 2 : undefined
  406. },
  407. "NativeBase.IconNB": {
  408. color: variables.inverseTextColor,
  409. fontSize: 24,
  410. marginHorizontal: 5,
  411. paddingTop: platform === "ios" ? 2 : undefined
  412. },
  413. ".iconLeft": {
  414. "NativeBase.Text": {
  415. marginLeft: variables.buttonPadding
  416. },
  417. "NativeBase.IconNB": {
  418. marginRight: 10,
  419. marginLeft: 0
  420. },
  421. "NativeBase.Icon": {
  422. marginRight: 10,
  423. marginLeft: 0
  424. }
  425. },
  426. ".iconRight": {
  427. "NativeBase.Text": {
  428. marginRight: variables.buttonPadding
  429. },
  430. "NativeBase.IconNB": {
  431. marginLeft: 10,
  432. marginRight: 0
  433. },
  434. "NativeBase.Icon": {
  435. marginLeft: 10,
  436. marginRight: 0
  437. }
  438. },
  439. ".picker": {
  440. "NativeBase.Text": {
  441. ".note": {
  442. fontSize: 16,
  443. lineHeight: null
  444. }
  445. }
  446. },
  447. paddingVertical: variables.buttonPadding,
  448. paddingHorizontal: variables.buttonPadding + 10,
  449. backgroundColor: variables.btnPrimaryBg,
  450. borderRadius: variables.borderRadiusBase,
  451. borderColor: variables.btnPrimaryBg,
  452. borderWidth: null,
  453. height: 45,
  454. alignSelf: "flex-start",
  455. flexDirection: "row",
  456. elevation: 2,
  457. shadowColor: platformStyle === "material" ? "#000" : undefined,
  458. shadowOffset:
  459. platformStyle === "material" ? { width: 0, height: 2 } : undefined,
  460. shadowOpacity: platformStyle === "material" ? 0.2 : undefined,
  461. shadowRadius: platformStyle === "material" ? 1.2 : undefined,
  462. alignItems: "center",
  463. justifyContent: "space-between"
  464. };
  465. return buttonTheme;
  466. };