@lukso/web-components 1.6.3 → 1.7.4

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.
Files changed (329) hide show
  1. package/dist/color-palette.cjs +1363 -0
  2. package/dist/{shared/utils/color-palette.d.ts → color-palette.d.ts} +1 -2
  3. package/dist/color-palette.d.ts.map +1 -0
  4. package/dist/color-palette.js +1356 -0
  5. package/dist/components/index.cjs +74 -0
  6. package/dist/components/index.d.ts +2 -1
  7. package/dist/components/index.d.ts.map +1 -1
  8. package/dist/components/index.js +17 -7354
  9. package/dist/components/lukso-button/index.cjs +144 -0
  10. package/dist/components/lukso-button/index.js +95 -1190
  11. package/dist/components/lukso-card/index.cjs +143 -0
  12. package/dist/components/lukso-card/index.js +61 -1487
  13. package/dist/components/lukso-icon/index.cjs +4366 -0
  14. package/dist/components/lukso-icon/index.js +1713 -2410
  15. package/dist/components/lukso-input/index.cjs +219 -0
  16. package/dist/components/lukso-input/index.d.ts +1 -2
  17. package/dist/components/lukso-input/index.d.ts.map +1 -1
  18. package/dist/components/lukso-input/index.js +128 -1229
  19. package/dist/components/lukso-modal/index.cjs +70 -0
  20. package/dist/components/lukso-modal/index.d.ts +18 -0
  21. package/dist/components/lukso-modal/index.d.ts.map +1 -0
  22. package/dist/components/lukso-modal/index.js +68 -0
  23. package/dist/components/lukso-navbar/index.cjs +75 -0
  24. package/dist/components/lukso-navbar/index.d.ts.map +1 -1
  25. package/dist/components/lukso-navbar/index.js +45 -1155
  26. package/dist/components/lukso-profile/index.cjs +547 -0
  27. package/dist/components/lukso-profile/index.js +483 -1370
  28. package/dist/components/lukso-sanitize/index.cjs +1730 -0
  29. package/dist/components/lukso-sanitize/index.js +1643 -1544
  30. package/dist/components/lukso-tag/index.cjs +78 -0
  31. package/dist/components/lukso-tag/index.js +52 -1189
  32. package/dist/components/lukso-test/index.cjs +120 -0
  33. package/dist/components/lukso-test/index.js +65 -1767
  34. package/dist/components/lukso-username/index.cjs +126 -0
  35. package/dist/components/lukso-username/index.js +75 -1206
  36. package/dist/components/lukso-wizard/index.cjs +93 -0
  37. package/dist/components/lukso-wizard/index.js +47 -1253
  38. package/dist/directive-9ec64c08.js +28 -0
  39. package/dist/directive-db00f5fb.cjs +34 -0
  40. package/dist/index-3a24432e.js +59 -0
  41. package/dist/index-4a1ee696.cjs +67 -0
  42. package/dist/index-714323c9.js +18 -0
  43. package/dist/index-7dc05ee5.cjs +20 -0
  44. package/dist/index.cjs +74 -0
  45. package/dist/index.js +17 -7354
  46. package/dist/shared/tailwind-element/index.cjs +10 -0
  47. package/dist/shared/tailwind-element/index.js +1 -1064
  48. package/dist/state-7fde94d1.js +9 -0
  49. package/dist/state-a62a7d5d.cjs +11 -0
  50. package/dist/style-map-17d4829d.cjs +12 -0
  51. package/dist/style-map-52bada0b.js +10 -0
  52. package/dist/styles/main.css.map +1 -1
  53. package/package.json +85 -147
  54. package/tools/assets/fonts/index.cjs +10 -0
  55. package/tools/assets/fonts/index.d.ts +2 -0
  56. package/tools/assets/fonts/index.d.ts.map +1 -0
  57. package/tools/assets/fonts/index.js +6 -0
  58. package/tools/assets/images/index.cjs +10 -0
  59. package/tools/assets/images/index.d.ts +2 -0
  60. package/tools/assets/images/index.d.ts.map +1 -0
  61. package/tools/assets/images/index.js +6 -0
  62. package/tools/assets/index.cjs +15 -0
  63. package/tools/assets/index.d.ts +4 -0
  64. package/tools/assets/index.d.ts.map +1 -0
  65. package/tools/assets/index.js +9 -0
  66. package/tools/color-palette-a34f5d09.js +1356 -0
  67. package/tools/color-palette-bf5780ed.cjs +1362 -0
  68. package/tools/color-palette.cjs +11 -146
  69. package/tools/color-palette.d.ts +39 -52
  70. package/tools/color-palette.d.ts.map +1 -1
  71. package/tools/color-palette.js +1 -0
  72. package/tools/copy-assets.cjs +50 -136
  73. package/tools/copy-assets.d.ts +7 -9
  74. package/tools/copy-assets.d.ts.map +1 -1
  75. package/tools/copy-assets.js +49 -0
  76. package/tools/index.cjs +35 -0
  77. package/tools/index.d.ts +6 -0
  78. package/tools/index.d.ts.map +1 -0
  79. package/tools/index.js +22 -0
  80. package/tools/sass/index.cjs +7 -0
  81. package/tools/sass/index.js +1 -0
  82. package/tools/styles/index.cjs +5 -0
  83. package/tools/styles/index.js +3 -0
  84. package/tools/styles/main.css +287 -0
  85. package/CHANGELOG.md +0 -287
  86. package/dist/assets/fonts/index.js +0 -4
  87. package/dist/assets/fonts/index.ts +0 -1
  88. package/dist/assets/fonts/index.umd.cjs +0 -1
  89. package/dist/assets/images/index.js +0 -4
  90. package/dist/assets/images/index.ts +0 -1
  91. package/dist/assets/images/index.umd.cjs +0 -1
  92. package/dist/assets/index.js +0 -4
  93. package/dist/assets/index.ts +0 -1
  94. package/dist/assets/index.umd.cjs +0 -1
  95. package/dist/color-palette/index.js +0 -705
  96. package/dist/color-palette/index.umd.cjs +0 -1
  97. package/dist/components/index.umd.cjs +0 -3756
  98. package/dist/components/lukso-button/index.umd.cjs +0 -88
  99. package/dist/components/lukso-card/index.umd.cjs +0 -145
  100. package/dist/components/lukso-icon/index.umd.cjs +0 -3465
  101. package/dist/components/lukso-input/index.umd.cjs +0 -109
  102. package/dist/components/lukso-navbar/index.umd.cjs +0 -73
  103. package/dist/components/lukso-profile/index.umd.cjs +0 -90
  104. package/dist/components/lukso-sanitize/index.umd.cjs +0 -61
  105. package/dist/components/lukso-tag/index.umd.cjs +0 -67
  106. package/dist/components/lukso-test/index.umd.cjs +0 -95
  107. package/dist/components/lukso-username/index.umd.cjs +0 -75
  108. package/dist/components/lukso-wizard/index.umd.cjs +0 -89
  109. package/dist/index.umd.cjs +0 -3756
  110. package/dist/sass/index.js +0 -4
  111. package/dist/sass/index.ts +0 -1
  112. package/dist/sass/index.umd.cjs +0 -1
  113. package/dist/shared/assets/index.d.ts +0 -3
  114. package/dist/shared/assets/index.d.ts.map +0 -1
  115. package/dist/shared/directives/custom-class-map/index.d.ts +0 -26
  116. package/dist/shared/directives/custom-class-map/index.d.ts.map +0 -1
  117. package/dist/shared/directives/index.d.ts +0 -2
  118. package/dist/shared/directives/index.d.ts.map +0 -1
  119. package/dist/shared/styles/index.d.ts +0 -3
  120. package/dist/shared/styles/index.d.ts.map +0 -1
  121. package/dist/shared/tailwind-element/index.umd.cjs +0 -39
  122. package/dist/shared/tailwind-element.js +0 -1064
  123. package/dist/shared/tailwind-element.umd.cjs +0 -39
  124. package/dist/shared/utils/color-palette.d.ts.map +0 -1
  125. package/dist/styles/index.js +0 -4
  126. package/dist/styles/index.umd.cjs +0 -1
  127. package/src/components/index.ts +0 -13
  128. package/src/components/lukso-button/index.ts +0 -145
  129. package/src/components/lukso-button/lukso-button.stories.ts +0 -216
  130. package/src/components/lukso-card/index.ts +0 -131
  131. package/src/components/lukso-card/lukso-card.stories.ts +0 -191
  132. package/src/components/lukso-card/style.scss +0 -7
  133. package/src/components/lukso-icon/icons/add-photo.ts +0 -46
  134. package/src/components/lukso-icon/icons/arrow-down-lg.ts +0 -26
  135. package/src/components/lukso-icon/icons/arrow-down-sm.ts +0 -26
  136. package/src/components/lukso-icon/icons/arrow-left-lg.ts +0 -26
  137. package/src/components/lukso-icon/icons/arrow-left-sm.ts +0 -26
  138. package/src/components/lukso-icon/icons/arrow-right-lg.ts +0 -26
  139. package/src/components/lukso-icon/icons/arrow-right-sm.ts +0 -26
  140. package/src/components/lukso-icon/icons/arrow-up-lg.ts +0 -26
  141. package/src/components/lukso-icon/icons/arrow-up-sm.ts +0 -26
  142. package/src/components/lukso-icon/icons/barbell-outline.ts +0 -54
  143. package/src/components/lukso-icon/icons/bulb-outline.ts +0 -54
  144. package/src/components/lukso-icon/icons/camera.ts +0 -40
  145. package/src/components/lukso-icon/icons/clipboard.ts +0 -59
  146. package/src/components/lukso-icon/icons/clock.ts +0 -31
  147. package/src/components/lukso-icon/icons/close-lg.ts +0 -33
  148. package/src/components/lukso-icon/icons/close-sm.ts +0 -33
  149. package/src/components/lukso-icon/icons/cloud.ts +0 -25
  150. package/src/components/lukso-icon/icons/compass-outline.ts +0 -29
  151. package/src/components/lukso-icon/icons/complete-filled-fade-in.ts +0 -34
  152. package/src/components/lukso-icon/icons/complete-filled.ts +0 -32
  153. package/src/components/lukso-icon/icons/complete-outline.ts +0 -31
  154. package/src/components/lukso-icon/icons/connect.ts +0 -33
  155. package/src/components/lukso-icon/icons/connections.ts +0 -34
  156. package/src/components/lukso-icon/icons/contract-lock.ts +0 -43
  157. package/src/components/lukso-icon/icons/controller.ts +0 -55
  158. package/src/components/lukso-icon/icons/copy.ts +0 -31
  159. package/src/components/lukso-icon/icons/cross-outline.ts +0 -38
  160. package/src/components/lukso-icon/icons/dots.ts +0 -22
  161. package/src/components/lukso-icon/icons/edit.ts +0 -30
  162. package/src/components/lukso-icon/icons/error.ts +0 -31
  163. package/src/components/lukso-icon/icons/eth-logo.ts +0 -50
  164. package/src/components/lukso-icon/icons/expand.ts +0 -31
  165. package/src/components/lukso-icon/icons/extension.ts +0 -31
  166. package/src/components/lukso-icon/icons/eye-hide.ts +0 -47
  167. package/src/components/lukso-icon/icons/eye-show.ts +0 -37
  168. package/src/components/lukso-icon/icons/filter.ts +0 -43
  169. package/src/components/lukso-icon/icons/fish-outline.ts +0 -36
  170. package/src/components/lukso-icon/icons/flip.ts +0 -45
  171. package/src/components/lukso-icon/icons/globe.ts +0 -61
  172. package/src/components/lukso-icon/icons/google-color.ts +0 -35
  173. package/src/components/lukso-icon/icons/hamburger.ts +0 -40
  174. package/src/components/lukso-icon/icons/infinite.ts +0 -33
  175. package/src/components/lukso-icon/icons/information.ts +0 -38
  176. package/src/components/lukso-icon/icons/key-outline.ts +0 -25
  177. package/src/components/lukso-icon/icons/link.ts +0 -33
  178. package/src/components/lukso-icon/icons/link1.ts +0 -39
  179. package/src/components/lukso-icon/icons/link2.ts +0 -46
  180. package/src/components/lukso-icon/icons/link3.ts +0 -32
  181. package/src/components/lukso-icon/icons/link4.ts +0 -52
  182. package/src/components/lukso-icon/icons/loading.ts +0 -50
  183. package/src/components/lukso-icon/icons/location.ts +0 -33
  184. package/src/components/lukso-icon/icons/locked.ts +0 -44
  185. package/src/components/lukso-icon/icons/login-2.ts +0 -55
  186. package/src/components/lukso-icon/icons/login-3.ts +0 -53
  187. package/src/components/lukso-icon/icons/login.ts +0 -39
  188. package/src/components/lukso-icon/icons/logo-chrome.ts +0 -35
  189. package/src/components/lukso-icon/icons/lyx-logo.ts +0 -41
  190. package/src/components/lukso-icon/icons/mail.ts +0 -33
  191. package/src/components/lukso-icon/icons/menu-1.ts +0 -71
  192. package/src/components/lukso-icon/icons/menu-2.ts +0 -61
  193. package/src/components/lukso-icon/icons/migrate.ts +0 -47
  194. package/src/components/lukso-icon/icons/minimize.ts +0 -53
  195. package/src/components/lukso-icon/icons/network.ts +0 -49
  196. package/src/components/lukso-icon/icons/notifications.ts +0 -33
  197. package/src/components/lukso-icon/icons/phone-portrait-outline.ts +0 -33
  198. package/src/components/lukso-icon/icons/pin.ts +0 -25
  199. package/src/components/lukso-icon/icons/play-filled.ts +0 -23
  200. package/src/components/lukso-icon/icons/play-outline.ts +0 -24
  201. package/src/components/lukso-icon/icons/plus.ts +0 -33
  202. package/src/components/lukso-icon/icons/profile-add.ts +0 -43
  203. package/src/components/lukso-icon/icons/profile-export.ts +0 -42
  204. package/src/components/lukso-icon/icons/profile-import.ts +0 -42
  205. package/src/components/lukso-icon/icons/profile-recovery-2.ts +0 -62
  206. package/src/components/lukso-icon/icons/profile-recovery.ts +0 -55
  207. package/src/components/lukso-icon/icons/profile-restore.ts +0 -50
  208. package/src/components/lukso-icon/icons/profile.ts +0 -29
  209. package/src/components/lukso-icon/icons/progress-complete.ts +0 -289
  210. package/src/components/lukso-icon/icons/progress-indicator.ts +0 -236
  211. package/src/components/lukso-icon/icons/pulse-dot.ts +0 -22
  212. package/src/components/lukso-icon/icons/qr-code.ts +0 -122
  213. package/src/components/lukso-icon/icons/relayer.ts +0 -40
  214. package/src/components/lukso-icon/icons/reload.ts +0 -32
  215. package/src/components/lukso-icon/icons/return-down.ts +0 -33
  216. package/src/components/lukso-icon/icons/return-left.ts +0 -33
  217. package/src/components/lukso-icon/icons/return-right.ts +0 -33
  218. package/src/components/lukso-icon/icons/return-up.ts +0 -33
  219. package/src/components/lukso-icon/icons/search.ts +0 -28
  220. package/src/components/lukso-icon/icons/settings.ts +0 -33
  221. package/src/components/lukso-icon/icons/smart-contract-doc.ts +0 -40
  222. package/src/components/lukso-icon/icons/smart-contract.ts +0 -31
  223. package/src/components/lukso-icon/icons/star-filled.ts +0 -23
  224. package/src/components/lukso-icon/icons/star-outline.ts +0 -24
  225. package/src/components/lukso-icon/icons/step-dot.ts +0 -34
  226. package/src/components/lukso-icon/icons/step-progress.ts +0 -31
  227. package/src/components/lukso-icon/icons/steps.ts +0 -40
  228. package/src/components/lukso-icon/icons/tick.ts +0 -26
  229. package/src/components/lukso-icon/icons/timer-outline.ts +0 -47
  230. package/src/components/lukso-icon/icons/transaction-receive.ts +0 -39
  231. package/src/components/lukso-icon/icons/transaction-send.ts +0 -39
  232. package/src/components/lukso-icon/icons/transfer.ts +0 -47
  233. package/src/components/lukso-icon/icons/trash.ts +0 -40
  234. package/src/components/lukso-icon/icons/turn-down.ts +0 -33
  235. package/src/components/lukso-icon/icons/turn-left.ts +0 -33
  236. package/src/components/lukso-icon/icons/turn-right.ts +0 -33
  237. package/src/components/lukso-icon/icons/turn-up.ts +0 -33
  238. package/src/components/lukso-icon/icons/unlocked.ts +0 -41
  239. package/src/components/lukso-icon/icons/wallet-outline.ts +0 -35
  240. package/src/components/lukso-icon/icons/warning-round.ts +0 -32
  241. package/src/components/lukso-icon/icons/warning-triangle.ts +0 -32
  242. package/src/components/lukso-icon/index.ts +0 -310
  243. package/src/components/lukso-icon/lukso-icon.stories.ts +0 -116
  244. package/src/components/lukso-icon/style.scss +0 -3
  245. package/src/components/lukso-input/index.ts +0 -211
  246. package/src/components/lukso-input/lukso-input.stories.ts +0 -184
  247. package/src/components/lukso-navbar/index.ts +0 -63
  248. package/src/components/lukso-navbar/lukso-navbar.stories.ts +0 -70
  249. package/src/components/lukso-profile/index.ts +0 -106
  250. package/src/components/lukso-profile/lukso-profile.stories.ts +0 -104
  251. package/src/components/lukso-sanitize/index.ts +0 -28
  252. package/src/components/lukso-sanitize/lukso-sanitize.stories.ts +0 -30
  253. package/src/components/lukso-tag/index.ts +0 -68
  254. package/src/components/lukso-tag/lukso-tag.stories.ts +0 -129
  255. package/src/components/lukso-test/index.ts +0 -72
  256. package/src/components/lukso-test/test.component.scss +0 -7
  257. package/src/components/lukso-test/test.stories.ts +0 -31
  258. package/src/components/lukso-username/index.ts +0 -105
  259. package/src/components/lukso-username/lukso-username.stories.ts +0 -98
  260. package/src/components/lukso-wizard/index.ts +0 -74
  261. package/src/components/lukso-wizard/lukso-wizard.stories.ts +0 -52
  262. package/src/docs/animations.stories.mdx +0 -83
  263. package/src/docs/colors.stories.mdx +0 -77
  264. package/src/docs/drop-shadows.stories.mdx +0 -108
  265. package/src/docs/icons.stories.mdx +0 -1590
  266. package/src/docs/typography.stories.mdx +0 -253
  267. package/src/index.ts +0 -1
  268. package/src/postcss.config.ts +0 -8
  269. package/src/shared/assets/fonts/Apax-Bold.woff2 +0 -0
  270. package/src/shared/assets/fonts/Apax-Light.woff2 +0 -0
  271. package/src/shared/assets/fonts/Apax-Medium.woff2 +0 -0
  272. package/src/shared/assets/fonts/Apax-Regular.woff2 +0 -0
  273. package/src/shared/assets/fonts/Inter-Bold.woff2 +0 -0
  274. package/src/shared/assets/fonts/Inter-ExtraBold.woff2 +0 -0
  275. package/src/shared/assets/fonts/Inter-Medium.woff2 +0 -0
  276. package/src/shared/assets/fonts/Inter-Regular.woff2 +0 -0
  277. package/src/shared/assets/fonts/Inter-SemiBold.woff2 +0 -0
  278. package/src/shared/assets/fonts/Inter-Thin.woff2 +0 -0
  279. package/src/shared/assets/fonts/PT-Mono-Bold.woff2 +0 -0
  280. package/src/shared/assets/fonts/PT-Mono-Regular.woff2 +0 -0
  281. package/src/shared/assets/fonts/index.ts +0 -1
  282. package/src/shared/assets/images/index.ts +0 -1
  283. package/src/shared/assets/images/lukso-logo.svg +0 -3
  284. package/src/shared/assets/images/profile-default.png +0 -0
  285. package/src/shared/assets/index.ts +0 -1
  286. package/src/shared/directives/custom-class-map/index.ts +0 -49
  287. package/src/shared/directives/index.ts +0 -1
  288. package/src/shared/globals.d.ts +0 -5
  289. package/src/shared/styles/colors.scss +0 -91
  290. package/src/shared/styles/component.scss +0 -13
  291. package/src/shared/styles/fonts.scss +0 -97
  292. package/src/shared/styles/index.ts +0 -1
  293. package/src/shared/styles/main.scss +0 -13
  294. package/src/shared/styles/typography.scss +0 -142
  295. package/src/shared/styles/variables.scss +0 -5
  296. package/src/shared/tailwind-element/index.ts +0 -16
  297. package/src/shared/utils/__tests__/slice-address.spec.ts +0 -15
  298. package/src/shared/utils/color-palette.ts +0 -76
  299. package/src/shared/utils/copy-assets.ts +0 -80
  300. package/src/shared/utils/hsl-color-map.ts +0 -20
  301. package/src/shared/utils/slice-address.ts +0 -30
  302. /package/{dist → tools}/assets/fonts/Apax-Bold.woff2 +0 -0
  303. /package/{dist → tools}/assets/fonts/Apax-Light.woff2 +0 -0
  304. /package/{dist → tools}/assets/fonts/Apax-Medium.woff2 +0 -0
  305. /package/{dist → tools}/assets/fonts/Apax-Regular.woff2 +0 -0
  306. /package/{dist → tools}/assets/fonts/Inter-Bold.woff2 +0 -0
  307. /package/{dist → tools}/assets/fonts/Inter-ExtraBold.woff2 +0 -0
  308. /package/{dist → tools}/assets/fonts/Inter-Medium.woff2 +0 -0
  309. /package/{dist → tools}/assets/fonts/Inter-Regular.woff2 +0 -0
  310. /package/{dist → tools}/assets/fonts/Inter-SemiBold.woff2 +0 -0
  311. /package/{dist → tools}/assets/fonts/Inter-Thin.woff2 +0 -0
  312. /package/{dist → tools}/assets/fonts/PT-Mono-Bold.woff2 +0 -0
  313. /package/{dist → tools}/assets/fonts/PT-Mono-Regular.woff2 +0 -0
  314. /package/{dist → tools}/assets/images/lukso-logo.svg +0 -0
  315. /package/{dist → tools}/assets/images/profile-default.png +0 -0
  316. /package/{dist/shared/utils → tools}/hsl-color-map.d.ts +0 -0
  317. /package/{dist/shared/utils → tools}/hsl-color-map.d.ts.map +0 -0
  318. /package/{dist → tools}/sass/colors.scss +0 -0
  319. /package/{dist → tools}/sass/component.scss +0 -0
  320. /package/{dist → tools}/sass/fonts.scss +0 -0
  321. /package/{dist/shared/assets/fonts → tools/sass}/index.d.ts +0 -0
  322. /package/{dist/shared/assets/fonts → tools/sass}/index.d.ts.map +0 -0
  323. /package/{dist → tools}/sass/main.scss +0 -0
  324. /package/{dist → tools}/sass/typography.scss +0 -0
  325. /package/{dist → tools}/sass/variables.scss +0 -0
  326. /package/{dist/shared/utils → tools}/slice-address.d.ts +0 -0
  327. /package/{dist/shared/utils → tools}/slice-address.d.ts.map +0 -0
  328. /package/{dist/shared/assets/images → tools/styles}/index.d.ts +0 -0
  329. /package/{dist/shared/assets/images → tools/styles}/index.d.ts.map +0 -0
@@ -0,0 +1,1356 @@
1
+ // This file is autogenerated. It's used to publish ESM to npm.
2
+ // https://github.com/bgrins/TinyColor
3
+ // Brian Grinstead, MIT License
4
+
5
+ const trimLeft = /^\s+/;
6
+ const trimRight = /\s+$/;
7
+
8
+ function tinycolor(color, opts) {
9
+ color = color ? color : "";
10
+ opts = opts || {};
11
+
12
+ // If input is already a tinycolor, return itself
13
+ if (color instanceof tinycolor) {
14
+ return color;
15
+ }
16
+ // If we are called as a function, call using new instead
17
+ if (!(this instanceof tinycolor)) {
18
+ return new tinycolor(color, opts);
19
+ }
20
+
21
+ var rgb = inputToRGB(color);
22
+ (this._originalInput = color),
23
+ (this._r = rgb.r),
24
+ (this._g = rgb.g),
25
+ (this._b = rgb.b),
26
+ (this._a = rgb.a),
27
+ (this._roundA = Math.round(100 * this._a) / 100),
28
+ (this._format = opts.format || rgb.format);
29
+ this._gradientType = opts.gradientType;
30
+
31
+ // Don't let the range of [0,255] come back in [0,1].
32
+ // Potentially lose a little bit of precision here, but will fix issues where
33
+ // .5 gets interpreted as half of the total, instead of half of 1
34
+ // If it was supposed to be 128, this was already taken care of by `inputToRgb`
35
+ if (this._r < 1) this._r = Math.round(this._r);
36
+ if (this._g < 1) this._g = Math.round(this._g);
37
+ if (this._b < 1) this._b = Math.round(this._b);
38
+
39
+ this._ok = rgb.ok;
40
+ }
41
+
42
+ tinycolor.prototype = {
43
+ isDark: function () {
44
+ return this.getBrightness() < 128;
45
+ },
46
+ isLight: function () {
47
+ return !this.isDark();
48
+ },
49
+ isValid: function () {
50
+ return this._ok;
51
+ },
52
+ getOriginalInput: function () {
53
+ return this._originalInput;
54
+ },
55
+ getFormat: function () {
56
+ return this._format;
57
+ },
58
+ getAlpha: function () {
59
+ return this._a;
60
+ },
61
+ getBrightness: function () {
62
+ //http://www.w3.org/TR/AERT#color-contrast
63
+ var rgb = this.toRgb();
64
+ return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
65
+ },
66
+ getLuminance: function () {
67
+ //http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
68
+ var rgb = this.toRgb();
69
+ var RsRGB, GsRGB, BsRGB, R, G, B;
70
+ RsRGB = rgb.r / 255;
71
+ GsRGB = rgb.g / 255;
72
+ BsRGB = rgb.b / 255;
73
+
74
+ if (RsRGB <= 0.03928) R = RsRGB / 12.92;
75
+ else R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);
76
+ if (GsRGB <= 0.03928) G = GsRGB / 12.92;
77
+ else G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);
78
+ if (BsRGB <= 0.03928) B = BsRGB / 12.92;
79
+ else B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);
80
+ return 0.2126 * R + 0.7152 * G + 0.0722 * B;
81
+ },
82
+ setAlpha: function (value) {
83
+ this._a = boundAlpha(value);
84
+ this._roundA = Math.round(100 * this._a) / 100;
85
+ return this;
86
+ },
87
+ toHsv: function () {
88
+ var hsv = rgbToHsv(this._r, this._g, this._b);
89
+ return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: this._a };
90
+ },
91
+ toHsvString: function () {
92
+ var hsv = rgbToHsv(this._r, this._g, this._b);
93
+ var h = Math.round(hsv.h * 360),
94
+ s = Math.round(hsv.s * 100),
95
+ v = Math.round(hsv.v * 100);
96
+ return this._a == 1
97
+ ? "hsv(" + h + ", " + s + "%, " + v + "%)"
98
+ : "hsva(" + h + ", " + s + "%, " + v + "%, " + this._roundA + ")";
99
+ },
100
+ toHsl: function () {
101
+ var hsl = rgbToHsl(this._r, this._g, this._b);
102
+ return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: this._a };
103
+ },
104
+ toHslString: function () {
105
+ var hsl = rgbToHsl(this._r, this._g, this._b);
106
+ var h = Math.round(hsl.h * 360),
107
+ s = Math.round(hsl.s * 100),
108
+ l = Math.round(hsl.l * 100);
109
+ return this._a == 1
110
+ ? "hsl(" + h + ", " + s + "%, " + l + "%)"
111
+ : "hsla(" + h + ", " + s + "%, " + l + "%, " + this._roundA + ")";
112
+ },
113
+ toHex: function (allow3Char) {
114
+ return rgbToHex(this._r, this._g, this._b, allow3Char);
115
+ },
116
+ toHexString: function (allow3Char) {
117
+ return "#" + this.toHex(allow3Char);
118
+ },
119
+ toHex8: function (allow4Char) {
120
+ return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char);
121
+ },
122
+ toHex8String: function (allow4Char) {
123
+ return "#" + this.toHex8(allow4Char);
124
+ },
125
+ toRgb: function () {
126
+ return {
127
+ r: Math.round(this._r),
128
+ g: Math.round(this._g),
129
+ b: Math.round(this._b),
130
+ a: this._a,
131
+ };
132
+ },
133
+ toRgbString: function () {
134
+ return this._a == 1
135
+ ? "rgb(" +
136
+ Math.round(this._r) +
137
+ ", " +
138
+ Math.round(this._g) +
139
+ ", " +
140
+ Math.round(this._b) +
141
+ ")"
142
+ : "rgba(" +
143
+ Math.round(this._r) +
144
+ ", " +
145
+ Math.round(this._g) +
146
+ ", " +
147
+ Math.round(this._b) +
148
+ ", " +
149
+ this._roundA +
150
+ ")";
151
+ },
152
+ toPercentageRgb: function () {
153
+ return {
154
+ r: Math.round(bound01(this._r, 255) * 100) + "%",
155
+ g: Math.round(bound01(this._g, 255) * 100) + "%",
156
+ b: Math.round(bound01(this._b, 255) * 100) + "%",
157
+ a: this._a,
158
+ };
159
+ },
160
+ toPercentageRgbString: function () {
161
+ return this._a == 1
162
+ ? "rgb(" +
163
+ Math.round(bound01(this._r, 255) * 100) +
164
+ "%, " +
165
+ Math.round(bound01(this._g, 255) * 100) +
166
+ "%, " +
167
+ Math.round(bound01(this._b, 255) * 100) +
168
+ "%)"
169
+ : "rgba(" +
170
+ Math.round(bound01(this._r, 255) * 100) +
171
+ "%, " +
172
+ Math.round(bound01(this._g, 255) * 100) +
173
+ "%, " +
174
+ Math.round(bound01(this._b, 255) * 100) +
175
+ "%, " +
176
+ this._roundA +
177
+ ")";
178
+ },
179
+ toName: function () {
180
+ if (this._a === 0) {
181
+ return "transparent";
182
+ }
183
+
184
+ if (this._a < 1) {
185
+ return false;
186
+ }
187
+
188
+ return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;
189
+ },
190
+ toFilter: function (secondColor) {
191
+ var hex8String = "#" + rgbaToArgbHex(this._r, this._g, this._b, this._a);
192
+ var secondHex8String = hex8String;
193
+ var gradientType = this._gradientType ? "GradientType = 1, " : "";
194
+
195
+ if (secondColor) {
196
+ var s = tinycolor(secondColor);
197
+ secondHex8String = "#" + rgbaToArgbHex(s._r, s._g, s._b, s._a);
198
+ }
199
+
200
+ return (
201
+ "progid:DXImageTransform.Microsoft.gradient(" +
202
+ gradientType +
203
+ "startColorstr=" +
204
+ hex8String +
205
+ ",endColorstr=" +
206
+ secondHex8String +
207
+ ")"
208
+ );
209
+ },
210
+ toString: function (format) {
211
+ var formatSet = !!format;
212
+ format = format || this._format;
213
+
214
+ var formattedString = false;
215
+ var hasAlpha = this._a < 1 && this._a >= 0;
216
+ var needsAlphaFormat =
217
+ !formatSet &&
218
+ hasAlpha &&
219
+ (format === "hex" ||
220
+ format === "hex6" ||
221
+ format === "hex3" ||
222
+ format === "hex4" ||
223
+ format === "hex8" ||
224
+ format === "name");
225
+
226
+ if (needsAlphaFormat) {
227
+ // Special case for "transparent", all other non-alpha formats
228
+ // will return rgba when there is transparency.
229
+ if (format === "name" && this._a === 0) {
230
+ return this.toName();
231
+ }
232
+ return this.toRgbString();
233
+ }
234
+ if (format === "rgb") {
235
+ formattedString = this.toRgbString();
236
+ }
237
+ if (format === "prgb") {
238
+ formattedString = this.toPercentageRgbString();
239
+ }
240
+ if (format === "hex" || format === "hex6") {
241
+ formattedString = this.toHexString();
242
+ }
243
+ if (format === "hex3") {
244
+ formattedString = this.toHexString(true);
245
+ }
246
+ if (format === "hex4") {
247
+ formattedString = this.toHex8String(true);
248
+ }
249
+ if (format === "hex8") {
250
+ formattedString = this.toHex8String();
251
+ }
252
+ if (format === "name") {
253
+ formattedString = this.toName();
254
+ }
255
+ if (format === "hsl") {
256
+ formattedString = this.toHslString();
257
+ }
258
+ if (format === "hsv") {
259
+ formattedString = this.toHsvString();
260
+ }
261
+
262
+ return formattedString || this.toHexString();
263
+ },
264
+ clone: function () {
265
+ return tinycolor(this.toString());
266
+ },
267
+
268
+ _applyModification: function (fn, args) {
269
+ var color = fn.apply(null, [this].concat([].slice.call(args)));
270
+ this._r = color._r;
271
+ this._g = color._g;
272
+ this._b = color._b;
273
+ this.setAlpha(color._a);
274
+ return this;
275
+ },
276
+ lighten: function () {
277
+ return this._applyModification(lighten, arguments);
278
+ },
279
+ brighten: function () {
280
+ return this._applyModification(brighten, arguments);
281
+ },
282
+ darken: function () {
283
+ return this._applyModification(darken, arguments);
284
+ },
285
+ desaturate: function () {
286
+ return this._applyModification(desaturate, arguments);
287
+ },
288
+ saturate: function () {
289
+ return this._applyModification(saturate, arguments);
290
+ },
291
+ greyscale: function () {
292
+ return this._applyModification(greyscale, arguments);
293
+ },
294
+ spin: function () {
295
+ return this._applyModification(spin, arguments);
296
+ },
297
+
298
+ _applyCombination: function (fn, args) {
299
+ return fn.apply(null, [this].concat([].slice.call(args)));
300
+ },
301
+ analogous: function () {
302
+ return this._applyCombination(analogous, arguments);
303
+ },
304
+ complement: function () {
305
+ return this._applyCombination(complement, arguments);
306
+ },
307
+ monochromatic: function () {
308
+ return this._applyCombination(monochromatic, arguments);
309
+ },
310
+ splitcomplement: function () {
311
+ return this._applyCombination(splitcomplement, arguments);
312
+ },
313
+ // Disabled until https://github.com/bgrins/TinyColor/issues/254
314
+ // polyad: function (number) {
315
+ // return this._applyCombination(polyad, [number]);
316
+ // },
317
+ triad: function () {
318
+ return this._applyCombination(polyad, [3]);
319
+ },
320
+ tetrad: function () {
321
+ return this._applyCombination(polyad, [4]);
322
+ },
323
+ };
324
+
325
+ // If input is an object, force 1 into "1.0" to handle ratios properly
326
+ // String input requires "1.0" as input, so 1 will be treated as 1
327
+ tinycolor.fromRatio = function (color, opts) {
328
+ if (typeof color == "object") {
329
+ var newColor = {};
330
+ for (var i in color) {
331
+ if (color.hasOwnProperty(i)) {
332
+ if (i === "a") {
333
+ newColor[i] = color[i];
334
+ } else {
335
+ newColor[i] = convertToPercentage(color[i]);
336
+ }
337
+ }
338
+ }
339
+ color = newColor;
340
+ }
341
+
342
+ return tinycolor(color, opts);
343
+ };
344
+
345
+ // Given a string or object, convert that input to RGB
346
+ // Possible string inputs:
347
+ //
348
+ // "red"
349
+ // "#f00" or "f00"
350
+ // "#ff0000" or "ff0000"
351
+ // "#ff000000" or "ff000000"
352
+ // "rgb 255 0 0" or "rgb (255, 0, 0)"
353
+ // "rgb 1.0 0 0" or "rgb (1, 0, 0)"
354
+ // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
355
+ // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
356
+ // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
357
+ // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
358
+ // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
359
+ //
360
+ function inputToRGB(color) {
361
+ var rgb = { r: 0, g: 0, b: 0 };
362
+ var a = 1;
363
+ var s = null;
364
+ var v = null;
365
+ var l = null;
366
+ var ok = false;
367
+ var format = false;
368
+
369
+ if (typeof color == "string") {
370
+ color = stringInputToObject(color);
371
+ }
372
+
373
+ if (typeof color == "object") {
374
+ if (
375
+ isValidCSSUnit(color.r) &&
376
+ isValidCSSUnit(color.g) &&
377
+ isValidCSSUnit(color.b)
378
+ ) {
379
+ rgb = rgbToRgb(color.r, color.g, color.b);
380
+ ok = true;
381
+ format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
382
+ } else if (
383
+ isValidCSSUnit(color.h) &&
384
+ isValidCSSUnit(color.s) &&
385
+ isValidCSSUnit(color.v)
386
+ ) {
387
+ s = convertToPercentage(color.s);
388
+ v = convertToPercentage(color.v);
389
+ rgb = hsvToRgb(color.h, s, v);
390
+ ok = true;
391
+ format = "hsv";
392
+ } else if (
393
+ isValidCSSUnit(color.h) &&
394
+ isValidCSSUnit(color.s) &&
395
+ isValidCSSUnit(color.l)
396
+ ) {
397
+ s = convertToPercentage(color.s);
398
+ l = convertToPercentage(color.l);
399
+ rgb = hslToRgb(color.h, s, l);
400
+ ok = true;
401
+ format = "hsl";
402
+ }
403
+
404
+ if (color.hasOwnProperty("a")) {
405
+ a = color.a;
406
+ }
407
+ }
408
+
409
+ a = boundAlpha(a);
410
+
411
+ return {
412
+ ok: ok,
413
+ format: color.format || format,
414
+ r: Math.min(255, Math.max(rgb.r, 0)),
415
+ g: Math.min(255, Math.max(rgb.g, 0)),
416
+ b: Math.min(255, Math.max(rgb.b, 0)),
417
+ a: a,
418
+ };
419
+ }
420
+
421
+ // Conversion Functions
422
+ // --------------------
423
+
424
+ // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
425
+ // <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
426
+
427
+ // `rgbToRgb`
428
+ // Handle bounds / percentage checking to conform to CSS color spec
429
+ // <http://www.w3.org/TR/css3-color/>
430
+ // *Assumes:* r, g, b in [0, 255] or [0, 1]
431
+ // *Returns:* { r, g, b } in [0, 255]
432
+ function rgbToRgb(r, g, b) {
433
+ return {
434
+ r: bound01(r, 255) * 255,
435
+ g: bound01(g, 255) * 255,
436
+ b: bound01(b, 255) * 255,
437
+ };
438
+ }
439
+
440
+ // `rgbToHsl`
441
+ // Converts an RGB color value to HSL.
442
+ // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
443
+ // *Returns:* { h, s, l } in [0,1]
444
+ function rgbToHsl(r, g, b) {
445
+ r = bound01(r, 255);
446
+ g = bound01(g, 255);
447
+ b = bound01(b, 255);
448
+
449
+ var max = Math.max(r, g, b),
450
+ min = Math.min(r, g, b);
451
+ var h,
452
+ s,
453
+ l = (max + min) / 2;
454
+
455
+ if (max == min) {
456
+ h = s = 0; // achromatic
457
+ } else {
458
+ var d = max - min;
459
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
460
+ switch (max) {
461
+ case r:
462
+ h = (g - b) / d + (g < b ? 6 : 0);
463
+ break;
464
+ case g:
465
+ h = (b - r) / d + 2;
466
+ break;
467
+ case b:
468
+ h = (r - g) / d + 4;
469
+ break;
470
+ }
471
+
472
+ h /= 6;
473
+ }
474
+
475
+ return { h: h, s: s, l: l };
476
+ }
477
+
478
+ // `hslToRgb`
479
+ // Converts an HSL color value to RGB.
480
+ // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
481
+ // *Returns:* { r, g, b } in the set [0, 255]
482
+ function hslToRgb(h, s, l) {
483
+ var r, g, b;
484
+
485
+ h = bound01(h, 360);
486
+ s = bound01(s, 100);
487
+ l = bound01(l, 100);
488
+
489
+ function hue2rgb(p, q, t) {
490
+ if (t < 0) t += 1;
491
+ if (t > 1) t -= 1;
492
+ if (t < 1 / 6) return p + (q - p) * 6 * t;
493
+ if (t < 1 / 2) return q;
494
+ if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
495
+ return p;
496
+ }
497
+
498
+ if (s === 0) {
499
+ r = g = b = l; // achromatic
500
+ } else {
501
+ var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
502
+ var p = 2 * l - q;
503
+ r = hue2rgb(p, q, h + 1 / 3);
504
+ g = hue2rgb(p, q, h);
505
+ b = hue2rgb(p, q, h - 1 / 3);
506
+ }
507
+
508
+ return { r: r * 255, g: g * 255, b: b * 255 };
509
+ }
510
+
511
+ // `rgbToHsv`
512
+ // Converts an RGB color value to HSV
513
+ // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
514
+ // *Returns:* { h, s, v } in [0,1]
515
+ function rgbToHsv(r, g, b) {
516
+ r = bound01(r, 255);
517
+ g = bound01(g, 255);
518
+ b = bound01(b, 255);
519
+
520
+ var max = Math.max(r, g, b),
521
+ min = Math.min(r, g, b);
522
+ var h,
523
+ s,
524
+ v = max;
525
+
526
+ var d = max - min;
527
+ s = max === 0 ? 0 : d / max;
528
+
529
+ if (max == min) {
530
+ h = 0; // achromatic
531
+ } else {
532
+ switch (max) {
533
+ case r:
534
+ h = (g - b) / d + (g < b ? 6 : 0);
535
+ break;
536
+ case g:
537
+ h = (b - r) / d + 2;
538
+ break;
539
+ case b:
540
+ h = (r - g) / d + 4;
541
+ break;
542
+ }
543
+ h /= 6;
544
+ }
545
+ return { h: h, s: s, v: v };
546
+ }
547
+
548
+ // `hsvToRgb`
549
+ // Converts an HSV color value to RGB.
550
+ // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
551
+ // *Returns:* { r, g, b } in the set [0, 255]
552
+ function hsvToRgb(h, s, v) {
553
+ h = bound01(h, 360) * 6;
554
+ s = bound01(s, 100);
555
+ v = bound01(v, 100);
556
+
557
+ var i = Math.floor(h),
558
+ f = h - i,
559
+ p = v * (1 - s),
560
+ q = v * (1 - f * s),
561
+ t = v * (1 - (1 - f) * s),
562
+ mod = i % 6,
563
+ r = [v, q, p, p, t, v][mod],
564
+ g = [t, v, v, q, p, p][mod],
565
+ b = [p, p, t, v, v, q][mod];
566
+
567
+ return { r: r * 255, g: g * 255, b: b * 255 };
568
+ }
569
+
570
+ // `rgbToHex`
571
+ // Converts an RGB color to hex
572
+ // Assumes r, g, and b are contained in the set [0, 255]
573
+ // Returns a 3 or 6 character hex
574
+ function rgbToHex(r, g, b, allow3Char) {
575
+ var hex = [
576
+ pad2(Math.round(r).toString(16)),
577
+ pad2(Math.round(g).toString(16)),
578
+ pad2(Math.round(b).toString(16)),
579
+ ];
580
+
581
+ // Return a 3 character hex if possible
582
+ if (
583
+ allow3Char &&
584
+ hex[0].charAt(0) == hex[0].charAt(1) &&
585
+ hex[1].charAt(0) == hex[1].charAt(1) &&
586
+ hex[2].charAt(0) == hex[2].charAt(1)
587
+ ) {
588
+ return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
589
+ }
590
+
591
+ return hex.join("");
592
+ }
593
+
594
+ // `rgbaToHex`
595
+ // Converts an RGBA color plus alpha transparency to hex
596
+ // Assumes r, g, b are contained in the set [0, 255] and
597
+ // a in [0, 1]. Returns a 4 or 8 character rgba hex
598
+ function rgbaToHex(r, g, b, a, allow4Char) {
599
+ var hex = [
600
+ pad2(Math.round(r).toString(16)),
601
+ pad2(Math.round(g).toString(16)),
602
+ pad2(Math.round(b).toString(16)),
603
+ pad2(convertDecimalToHex(a)),
604
+ ];
605
+
606
+ // Return a 4 character hex if possible
607
+ if (
608
+ allow4Char &&
609
+ hex[0].charAt(0) == hex[0].charAt(1) &&
610
+ hex[1].charAt(0) == hex[1].charAt(1) &&
611
+ hex[2].charAt(0) == hex[2].charAt(1) &&
612
+ hex[3].charAt(0) == hex[3].charAt(1)
613
+ ) {
614
+ return (
615
+ hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0)
616
+ );
617
+ }
618
+
619
+ return hex.join("");
620
+ }
621
+
622
+ // `rgbaToArgbHex`
623
+ // Converts an RGBA color to an ARGB Hex8 string
624
+ // Rarely used, but required for "toFilter()"
625
+ function rgbaToArgbHex(r, g, b, a) {
626
+ var hex = [
627
+ pad2(convertDecimalToHex(a)),
628
+ pad2(Math.round(r).toString(16)),
629
+ pad2(Math.round(g).toString(16)),
630
+ pad2(Math.round(b).toString(16)),
631
+ ];
632
+
633
+ return hex.join("");
634
+ }
635
+
636
+ // `equals`
637
+ // Can be called with any tinycolor input
638
+ tinycolor.equals = function (color1, color2) {
639
+ if (!color1 || !color2) return false;
640
+ return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
641
+ };
642
+
643
+ tinycolor.random = function () {
644
+ return tinycolor.fromRatio({
645
+ r: Math.random(),
646
+ g: Math.random(),
647
+ b: Math.random(),
648
+ });
649
+ };
650
+
651
+ // Modification Functions
652
+ // ----------------------
653
+ // Thanks to less.js for some of the basics here
654
+ // <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js>
655
+
656
+ function desaturate(color, amount) {
657
+ amount = amount === 0 ? 0 : amount || 10;
658
+ var hsl = tinycolor(color).toHsl();
659
+ hsl.s -= amount / 100;
660
+ hsl.s = clamp01(hsl.s);
661
+ return tinycolor(hsl);
662
+ }
663
+
664
+ function saturate(color, amount) {
665
+ amount = amount === 0 ? 0 : amount || 10;
666
+ var hsl = tinycolor(color).toHsl();
667
+ hsl.s += amount / 100;
668
+ hsl.s = clamp01(hsl.s);
669
+ return tinycolor(hsl);
670
+ }
671
+
672
+ function greyscale(color) {
673
+ return tinycolor(color).desaturate(100);
674
+ }
675
+
676
+ function lighten(color, amount) {
677
+ amount = amount === 0 ? 0 : amount || 10;
678
+ var hsl = tinycolor(color).toHsl();
679
+ hsl.l += amount / 100;
680
+ hsl.l = clamp01(hsl.l);
681
+ return tinycolor(hsl);
682
+ }
683
+
684
+ function brighten(color, amount) {
685
+ amount = amount === 0 ? 0 : amount || 10;
686
+ var rgb = tinycolor(color).toRgb();
687
+ rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))));
688
+ rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))));
689
+ rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))));
690
+ return tinycolor(rgb);
691
+ }
692
+
693
+ function darken(color, amount) {
694
+ amount = amount === 0 ? 0 : amount || 10;
695
+ var hsl = tinycolor(color).toHsl();
696
+ hsl.l -= amount / 100;
697
+ hsl.l = clamp01(hsl.l);
698
+ return tinycolor(hsl);
699
+ }
700
+
701
+ // Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
702
+ // Values outside of this range will be wrapped into this range.
703
+ function spin(color, amount) {
704
+ var hsl = tinycolor(color).toHsl();
705
+ var hue = (hsl.h + amount) % 360;
706
+ hsl.h = hue < 0 ? 360 + hue : hue;
707
+ return tinycolor(hsl);
708
+ }
709
+
710
+ // Combination Functions
711
+ // ---------------------
712
+ // Thanks to jQuery xColor for some of the ideas behind these
713
+ // <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js>
714
+
715
+ function complement(color) {
716
+ var hsl = tinycolor(color).toHsl();
717
+ hsl.h = (hsl.h + 180) % 360;
718
+ return tinycolor(hsl);
719
+ }
720
+
721
+ function polyad(color, number) {
722
+ if (isNaN(number) || number <= 0) {
723
+ throw new Error("Argument to polyad must be a positive number");
724
+ }
725
+ var hsl = tinycolor(color).toHsl();
726
+ var result = [tinycolor(color)];
727
+ var step = 360 / number;
728
+ for (var i = 1; i < number; i++) {
729
+ result.push(tinycolor({ h: (hsl.h + i * step) % 360, s: hsl.s, l: hsl.l }));
730
+ }
731
+
732
+ return result;
733
+ }
734
+
735
+ function splitcomplement(color) {
736
+ var hsl = tinycolor(color).toHsl();
737
+ var h = hsl.h;
738
+ return [
739
+ tinycolor(color),
740
+ tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l }),
741
+ tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l }),
742
+ ];
743
+ }
744
+
745
+ function analogous(color, results, slices) {
746
+ results = results || 6;
747
+ slices = slices || 30;
748
+
749
+ var hsl = tinycolor(color).toHsl();
750
+ var part = 360 / slices;
751
+ var ret = [tinycolor(color)];
752
+
753
+ for (hsl.h = (hsl.h - ((part * results) >> 1) + 720) % 360; --results; ) {
754
+ hsl.h = (hsl.h + part) % 360;
755
+ ret.push(tinycolor(hsl));
756
+ }
757
+ return ret;
758
+ }
759
+
760
+ function monochromatic(color, results) {
761
+ results = results || 6;
762
+ var hsv = tinycolor(color).toHsv();
763
+ var h = hsv.h,
764
+ s = hsv.s,
765
+ v = hsv.v;
766
+ var ret = [];
767
+ var modification = 1 / results;
768
+
769
+ while (results--) {
770
+ ret.push(tinycolor({ h: h, s: s, v: v }));
771
+ v = (v + modification) % 1;
772
+ }
773
+
774
+ return ret;
775
+ }
776
+
777
+ // Utility Functions
778
+ // ---------------------
779
+
780
+ tinycolor.mix = function (color1, color2, amount) {
781
+ amount = amount === 0 ? 0 : amount || 50;
782
+
783
+ var rgb1 = tinycolor(color1).toRgb();
784
+ var rgb2 = tinycolor(color2).toRgb();
785
+
786
+ var p = amount / 100;
787
+
788
+ var rgba = {
789
+ r: (rgb2.r - rgb1.r) * p + rgb1.r,
790
+ g: (rgb2.g - rgb1.g) * p + rgb1.g,
791
+ b: (rgb2.b - rgb1.b) * p + rgb1.b,
792
+ a: (rgb2.a - rgb1.a) * p + rgb1.a,
793
+ };
794
+
795
+ return tinycolor(rgba);
796
+ };
797
+
798
+ // Readability Functions
799
+ // ---------------------
800
+ // <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)
801
+
802
+ // `contrast`
803
+ // Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2)
804
+ tinycolor.readability = function (color1, color2) {
805
+ var c1 = tinycolor(color1);
806
+ var c2 = tinycolor(color2);
807
+ return (
808
+ (Math.max(c1.getLuminance(), c2.getLuminance()) + 0.05) /
809
+ (Math.min(c1.getLuminance(), c2.getLuminance()) + 0.05)
810
+ );
811
+ };
812
+
813
+ // `isReadable`
814
+ // Ensure that foreground and background color combinations meet WCAG2 guidelines.
815
+ // The third argument is an optional Object.
816
+ // the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA';
817
+ // the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'.
818
+ // If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}.
819
+
820
+ // *Example*
821
+ // tinycolor.isReadable("#000", "#111") => false
822
+ // tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false
823
+ tinycolor.isReadable = function (color1, color2, wcag2) {
824
+ var readability = tinycolor.readability(color1, color2);
825
+ var wcag2Parms, out;
826
+
827
+ out = false;
828
+
829
+ wcag2Parms = validateWCAG2Parms(wcag2);
830
+ switch (wcag2Parms.level + wcag2Parms.size) {
831
+ case "AAsmall":
832
+ case "AAAlarge":
833
+ out = readability >= 4.5;
834
+ break;
835
+ case "AAlarge":
836
+ out = readability >= 3;
837
+ break;
838
+ case "AAAsmall":
839
+ out = readability >= 7;
840
+ break;
841
+ }
842
+ return out;
843
+ };
844
+
845
+ // `mostReadable`
846
+ // Given a base color and a list of possible foreground or background
847
+ // colors for that base, returns the most readable color.
848
+ // Optionally returns Black or White if the most readable color is unreadable.
849
+ // *Example*
850
+ // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255"
851
+ // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff"
852
+ // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(); // "#faf3f3"
853
+ // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff"
854
+ tinycolor.mostReadable = function (baseColor, colorList, args) {
855
+ var bestColor = null;
856
+ var bestScore = 0;
857
+ var readability;
858
+ var includeFallbackColors, level, size;
859
+ args = args || {};
860
+ includeFallbackColors = args.includeFallbackColors;
861
+ level = args.level;
862
+ size = args.size;
863
+
864
+ for (var i = 0; i < colorList.length; i++) {
865
+ readability = tinycolor.readability(baseColor, colorList[i]);
866
+ if (readability > bestScore) {
867
+ bestScore = readability;
868
+ bestColor = tinycolor(colorList[i]);
869
+ }
870
+ }
871
+
872
+ if (
873
+ tinycolor.isReadable(baseColor, bestColor, {
874
+ level: level,
875
+ size: size,
876
+ }) ||
877
+ !includeFallbackColors
878
+ ) {
879
+ return bestColor;
880
+ } else {
881
+ args.includeFallbackColors = false;
882
+ return tinycolor.mostReadable(baseColor, ["#fff", "#000"], args);
883
+ }
884
+ };
885
+
886
+ // Big List of Colors
887
+ // ------------------
888
+ // <https://www.w3.org/TR/css-color-4/#named-colors>
889
+ var names = (tinycolor.names = {
890
+ aliceblue: "f0f8ff",
891
+ antiquewhite: "faebd7",
892
+ aqua: "0ff",
893
+ aquamarine: "7fffd4",
894
+ azure: "f0ffff",
895
+ beige: "f5f5dc",
896
+ bisque: "ffe4c4",
897
+ black: "000",
898
+ blanchedalmond: "ffebcd",
899
+ blue: "00f",
900
+ blueviolet: "8a2be2",
901
+ brown: "a52a2a",
902
+ burlywood: "deb887",
903
+ burntsienna: "ea7e5d",
904
+ cadetblue: "5f9ea0",
905
+ chartreuse: "7fff00",
906
+ chocolate: "d2691e",
907
+ coral: "ff7f50",
908
+ cornflowerblue: "6495ed",
909
+ cornsilk: "fff8dc",
910
+ crimson: "dc143c",
911
+ cyan: "0ff",
912
+ darkblue: "00008b",
913
+ darkcyan: "008b8b",
914
+ darkgoldenrod: "b8860b",
915
+ darkgray: "a9a9a9",
916
+ darkgreen: "006400",
917
+ darkgrey: "a9a9a9",
918
+ darkkhaki: "bdb76b",
919
+ darkmagenta: "8b008b",
920
+ darkolivegreen: "556b2f",
921
+ darkorange: "ff8c00",
922
+ darkorchid: "9932cc",
923
+ darkred: "8b0000",
924
+ darksalmon: "e9967a",
925
+ darkseagreen: "8fbc8f",
926
+ darkslateblue: "483d8b",
927
+ darkslategray: "2f4f4f",
928
+ darkslategrey: "2f4f4f",
929
+ darkturquoise: "00ced1",
930
+ darkviolet: "9400d3",
931
+ deeppink: "ff1493",
932
+ deepskyblue: "00bfff",
933
+ dimgray: "696969",
934
+ dimgrey: "696969",
935
+ dodgerblue: "1e90ff",
936
+ firebrick: "b22222",
937
+ floralwhite: "fffaf0",
938
+ forestgreen: "228b22",
939
+ fuchsia: "f0f",
940
+ gainsboro: "dcdcdc",
941
+ ghostwhite: "f8f8ff",
942
+ gold: "ffd700",
943
+ goldenrod: "daa520",
944
+ gray: "808080",
945
+ green: "008000",
946
+ greenyellow: "adff2f",
947
+ grey: "808080",
948
+ honeydew: "f0fff0",
949
+ hotpink: "ff69b4",
950
+ indianred: "cd5c5c",
951
+ indigo: "4b0082",
952
+ ivory: "fffff0",
953
+ khaki: "f0e68c",
954
+ lavender: "e6e6fa",
955
+ lavenderblush: "fff0f5",
956
+ lawngreen: "7cfc00",
957
+ lemonchiffon: "fffacd",
958
+ lightblue: "add8e6",
959
+ lightcoral: "f08080",
960
+ lightcyan: "e0ffff",
961
+ lightgoldenrodyellow: "fafad2",
962
+ lightgray: "d3d3d3",
963
+ lightgreen: "90ee90",
964
+ lightgrey: "d3d3d3",
965
+ lightpink: "ffb6c1",
966
+ lightsalmon: "ffa07a",
967
+ lightseagreen: "20b2aa",
968
+ lightskyblue: "87cefa",
969
+ lightslategray: "789",
970
+ lightslategrey: "789",
971
+ lightsteelblue: "b0c4de",
972
+ lightyellow: "ffffe0",
973
+ lime: "0f0",
974
+ limegreen: "32cd32",
975
+ linen: "faf0e6",
976
+ magenta: "f0f",
977
+ maroon: "800000",
978
+ mediumaquamarine: "66cdaa",
979
+ mediumblue: "0000cd",
980
+ mediumorchid: "ba55d3",
981
+ mediumpurple: "9370db",
982
+ mediumseagreen: "3cb371",
983
+ mediumslateblue: "7b68ee",
984
+ mediumspringgreen: "00fa9a",
985
+ mediumturquoise: "48d1cc",
986
+ mediumvioletred: "c71585",
987
+ midnightblue: "191970",
988
+ mintcream: "f5fffa",
989
+ mistyrose: "ffe4e1",
990
+ moccasin: "ffe4b5",
991
+ navajowhite: "ffdead",
992
+ navy: "000080",
993
+ oldlace: "fdf5e6",
994
+ olive: "808000",
995
+ olivedrab: "6b8e23",
996
+ orange: "ffa500",
997
+ orangered: "ff4500",
998
+ orchid: "da70d6",
999
+ palegoldenrod: "eee8aa",
1000
+ palegreen: "98fb98",
1001
+ paleturquoise: "afeeee",
1002
+ palevioletred: "db7093",
1003
+ papayawhip: "ffefd5",
1004
+ peachpuff: "ffdab9",
1005
+ peru: "cd853f",
1006
+ pink: "ffc0cb",
1007
+ plum: "dda0dd",
1008
+ powderblue: "b0e0e6",
1009
+ purple: "800080",
1010
+ rebeccapurple: "663399",
1011
+ red: "f00",
1012
+ rosybrown: "bc8f8f",
1013
+ royalblue: "4169e1",
1014
+ saddlebrown: "8b4513",
1015
+ salmon: "fa8072",
1016
+ sandybrown: "f4a460",
1017
+ seagreen: "2e8b57",
1018
+ seashell: "fff5ee",
1019
+ sienna: "a0522d",
1020
+ silver: "c0c0c0",
1021
+ skyblue: "87ceeb",
1022
+ slateblue: "6a5acd",
1023
+ slategray: "708090",
1024
+ slategrey: "708090",
1025
+ snow: "fffafa",
1026
+ springgreen: "00ff7f",
1027
+ steelblue: "4682b4",
1028
+ tan: "d2b48c",
1029
+ teal: "008080",
1030
+ thistle: "d8bfd8",
1031
+ tomato: "ff6347",
1032
+ turquoise: "40e0d0",
1033
+ violet: "ee82ee",
1034
+ wheat: "f5deb3",
1035
+ white: "fff",
1036
+ whitesmoke: "f5f5f5",
1037
+ yellow: "ff0",
1038
+ yellowgreen: "9acd32",
1039
+ });
1040
+
1041
+ // Make it easy to access colors via `hexNames[hex]`
1042
+ var hexNames = (tinycolor.hexNames = flip(names));
1043
+
1044
+ // Utilities
1045
+ // ---------
1046
+
1047
+ // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }`
1048
+ function flip(o) {
1049
+ var flipped = {};
1050
+ for (var i in o) {
1051
+ if (o.hasOwnProperty(i)) {
1052
+ flipped[o[i]] = i;
1053
+ }
1054
+ }
1055
+ return flipped;
1056
+ }
1057
+
1058
+ // Return a valid alpha value [0,1] with all invalid values being set to 1
1059
+ function boundAlpha(a) {
1060
+ a = parseFloat(a);
1061
+
1062
+ if (isNaN(a) || a < 0 || a > 1) {
1063
+ a = 1;
1064
+ }
1065
+
1066
+ return a;
1067
+ }
1068
+
1069
+ // Take input from [0, n] and return it as [0, 1]
1070
+ function bound01(n, max) {
1071
+ if (isOnePointZero(n)) n = "100%";
1072
+
1073
+ var processPercent = isPercentage(n);
1074
+ n = Math.min(max, Math.max(0, parseFloat(n)));
1075
+
1076
+ // Automatically convert percentage into number
1077
+ if (processPercent) {
1078
+ n = parseInt(n * max, 10) / 100;
1079
+ }
1080
+
1081
+ // Handle floating point rounding errors
1082
+ if (Math.abs(n - max) < 0.000001) {
1083
+ return 1;
1084
+ }
1085
+
1086
+ // Convert into [0, 1] range if it isn't already
1087
+ return (n % max) / parseFloat(max);
1088
+ }
1089
+
1090
+ // Force a number between 0 and 1
1091
+ function clamp01(val) {
1092
+ return Math.min(1, Math.max(0, val));
1093
+ }
1094
+
1095
+ // Parse a base-16 hex value into a base-10 integer
1096
+ function parseIntFromHex(val) {
1097
+ return parseInt(val, 16);
1098
+ }
1099
+
1100
+ // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
1101
+ // <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
1102
+ function isOnePointZero(n) {
1103
+ return typeof n == "string" && n.indexOf(".") != -1 && parseFloat(n) === 1;
1104
+ }
1105
+
1106
+ // Check to see if string passed in is a percentage
1107
+ function isPercentage(n) {
1108
+ return typeof n === "string" && n.indexOf("%") != -1;
1109
+ }
1110
+
1111
+ // Force a hex value to have 2 characters
1112
+ function pad2(c) {
1113
+ return c.length == 1 ? "0" + c : "" + c;
1114
+ }
1115
+
1116
+ // Replace a decimal with it's percentage value
1117
+ function convertToPercentage(n) {
1118
+ if (n <= 1) {
1119
+ n = n * 100 + "%";
1120
+ }
1121
+
1122
+ return n;
1123
+ }
1124
+
1125
+ // Converts a decimal to a hex value
1126
+ function convertDecimalToHex(d) {
1127
+ return Math.round(parseFloat(d) * 255).toString(16);
1128
+ }
1129
+ // Converts a hex value to a decimal
1130
+ function convertHexToDecimal(h) {
1131
+ return parseIntFromHex(h) / 255;
1132
+ }
1133
+
1134
+ var matchers = (function () {
1135
+ // <http://www.w3.org/TR/css3-values/#integers>
1136
+ var CSS_INTEGER = "[-\\+]?\\d+%?";
1137
+
1138
+ // <http://www.w3.org/TR/css3-values/#number-value>
1139
+ var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
1140
+
1141
+ // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
1142
+ var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
1143
+
1144
+ // Actual matching.
1145
+ // Parentheses and commas are optional, but not required.
1146
+ // Whitespace can take the place of commas or opening paren
1147
+ var PERMISSIVE_MATCH3 =
1148
+ "[\\s|\\(]+(" +
1149
+ CSS_UNIT +
1150
+ ")[,|\\s]+(" +
1151
+ CSS_UNIT +
1152
+ ")[,|\\s]+(" +
1153
+ CSS_UNIT +
1154
+ ")\\s*\\)?";
1155
+ var PERMISSIVE_MATCH4 =
1156
+ "[\\s|\\(]+(" +
1157
+ CSS_UNIT +
1158
+ ")[,|\\s]+(" +
1159
+ CSS_UNIT +
1160
+ ")[,|\\s]+(" +
1161
+ CSS_UNIT +
1162
+ ")[,|\\s]+(" +
1163
+ CSS_UNIT +
1164
+ ")\\s*\\)?";
1165
+
1166
+ return {
1167
+ CSS_UNIT: new RegExp(CSS_UNIT),
1168
+ rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
1169
+ rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
1170
+ hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
1171
+ hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
1172
+ hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
1173
+ hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
1174
+ hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
1175
+ hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
1176
+ hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
1177
+ hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
1178
+ };
1179
+ })();
1180
+
1181
+ // `isValidCSSUnit`
1182
+ // Take in a single string / number and check to see if it looks like a CSS unit
1183
+ // (see `matchers` above for definition).
1184
+ function isValidCSSUnit(color) {
1185
+ return !!matchers.CSS_UNIT.exec(color);
1186
+ }
1187
+
1188
+ // `stringInputToObject`
1189
+ // Permissive string parsing. Take in a number of formats, and output an object
1190
+ // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
1191
+ function stringInputToObject(color) {
1192
+ color = color.replace(trimLeft, "").replace(trimRight, "").toLowerCase();
1193
+ var named = false;
1194
+ if (names[color]) {
1195
+ color = names[color];
1196
+ named = true;
1197
+ } else if (color == "transparent") {
1198
+ return { r: 0, g: 0, b: 0, a: 0, format: "name" };
1199
+ }
1200
+
1201
+ // Try to match string input using regular expressions.
1202
+ // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
1203
+ // Just return an object and let the conversion functions handle that.
1204
+ // This way the result will be the same whether the tinycolor is initialized with string or object.
1205
+ var match;
1206
+ if ((match = matchers.rgb.exec(color))) {
1207
+ return { r: match[1], g: match[2], b: match[3] };
1208
+ }
1209
+ if ((match = matchers.rgba.exec(color))) {
1210
+ return { r: match[1], g: match[2], b: match[3], a: match[4] };
1211
+ }
1212
+ if ((match = matchers.hsl.exec(color))) {
1213
+ return { h: match[1], s: match[2], l: match[3] };
1214
+ }
1215
+ if ((match = matchers.hsla.exec(color))) {
1216
+ return { h: match[1], s: match[2], l: match[3], a: match[4] };
1217
+ }
1218
+ if ((match = matchers.hsv.exec(color))) {
1219
+ return { h: match[1], s: match[2], v: match[3] };
1220
+ }
1221
+ if ((match = matchers.hsva.exec(color))) {
1222
+ return { h: match[1], s: match[2], v: match[3], a: match[4] };
1223
+ }
1224
+ if ((match = matchers.hex8.exec(color))) {
1225
+ return {
1226
+ r: parseIntFromHex(match[1]),
1227
+ g: parseIntFromHex(match[2]),
1228
+ b: parseIntFromHex(match[3]),
1229
+ a: convertHexToDecimal(match[4]),
1230
+ format: named ? "name" : "hex8",
1231
+ };
1232
+ }
1233
+ if ((match = matchers.hex6.exec(color))) {
1234
+ return {
1235
+ r: parseIntFromHex(match[1]),
1236
+ g: parseIntFromHex(match[2]),
1237
+ b: parseIntFromHex(match[3]),
1238
+ format: named ? "name" : "hex",
1239
+ };
1240
+ }
1241
+ if ((match = matchers.hex4.exec(color))) {
1242
+ return {
1243
+ r: parseIntFromHex(match[1] + "" + match[1]),
1244
+ g: parseIntFromHex(match[2] + "" + match[2]),
1245
+ b: parseIntFromHex(match[3] + "" + match[3]),
1246
+ a: convertHexToDecimal(match[4] + "" + match[4]),
1247
+ format: named ? "name" : "hex8",
1248
+ };
1249
+ }
1250
+ if ((match = matchers.hex3.exec(color))) {
1251
+ return {
1252
+ r: parseIntFromHex(match[1] + "" + match[1]),
1253
+ g: parseIntFromHex(match[2] + "" + match[2]),
1254
+ b: parseIntFromHex(match[3] + "" + match[3]),
1255
+ format: named ? "name" : "hex",
1256
+ };
1257
+ }
1258
+
1259
+ return false;
1260
+ }
1261
+
1262
+ function validateWCAG2Parms(parms) {
1263
+ // return valid WCAG2 parms for isReadable.
1264
+ // If input parms are invalid, return {"level":"AA", "size":"small"}
1265
+ var level, size;
1266
+ parms = parms || { level: "AA", size: "small" };
1267
+ level = (parms.level || "AA").toUpperCase();
1268
+ size = (parms.size || "small").toLowerCase();
1269
+ if (level !== "AA" && level !== "AAA") {
1270
+ level = "AA";
1271
+ }
1272
+ if (size !== "small" && size !== "large") {
1273
+ size = "small";
1274
+ }
1275
+ return { level: level, size: size };
1276
+ }
1277
+
1278
+ const hslColorMap = (h, s, l) => {
1279
+ const colors = {};
1280
+ for (let i = 0; i < l.length; i++) {
1281
+ const lightness = l[i];
1282
+ colors[lightness] = tinycolor({ h, s, l: lightness }).toHexString();
1283
+ }
1284
+ return colors;
1285
+ };
1286
+
1287
+ const colorPalette = {
1288
+ neutral: hslColorMap(
1289
+ 206,
1290
+ 30,
1291
+ [
1292
+ 10,
1293
+ 15,
1294
+ 20,
1295
+ 25,
1296
+ 30,
1297
+ 35,
1298
+ 40,
1299
+ 45,
1300
+ 50,
1301
+ 55,
1302
+ 60,
1303
+ 65,
1304
+ 70,
1305
+ 75,
1306
+ 80,
1307
+ 85,
1308
+ 90,
1309
+ 95,
1310
+ 97,
1311
+ 98,
1312
+ 100
1313
+ ]
1314
+ ),
1315
+ honey: hslColorMap(42, 93, [72, 75, 82, 85, 92]),
1316
+ coral: hslColorMap(14, 87, [65, 74, 75, 84, 85, 94]),
1317
+ warm: hslColorMap(25, 100, [77, 87, 97]),
1318
+ "sea-salt": hslColorMap(180, 17, [57, 67, 88]),
1319
+ cloud: hslColorMap(200, 38, [43, 75, 88]),
1320
+ ocean: hslColorMap(209, 38, [38, 75, 88]),
1321
+ sky: hslColorMap(209, 64, [64, 75, 85]),
1322
+ lukso: hslColorMap(335, 33, [70, 80, 90]),
1323
+ yellow: hslColorMap(36, 100, [55, 65, 75, 85]),
1324
+ green: hslColorMap(135, 57, [45, 54, 75, 85]),
1325
+ blue: hslColorMap(216, 96, [50, 60, 75, 85]),
1326
+ red: hslColorMap(0, 75, [55, 65, 75, 85]),
1327
+ purple: hslColorMap(230, 24, [94, 82, 63, 58, 51, 41, 31, 15]),
1328
+ pink: hslColorMap(11, 73, [97, 96, 95, 94, 93, 92, 91, 90]),
1329
+ "gradient-1": {
1330
+ start: "#D39B9D",
1331
+ end: "#9071D1"
1332
+ },
1333
+ "gradient-2": {
1334
+ start: "#F8DAD3",
1335
+ end: "#CC99AE"
1336
+ },
1337
+ "gradient-3": {
1338
+ start: tinycolor({ h: 230, s: 20, l: 28 }).toHexString(),
1339
+ end: tinycolor({ h: 230, s: 24, l: 51 }).toHexString()
1340
+ }
1341
+ };
1342
+ const splitColor = (colors, from, to) => {
1343
+ return Object.keys(colors).slice(from, to).reduce((result, key) => {
1344
+ result[key] = colors[key];
1345
+ return result;
1346
+ }, {});
1347
+ };
1348
+ const neutral1 = splitColor(colorPalette.neutral, 0, 8);
1349
+ const neutral2 = splitColor(colorPalette.neutral, 8, 16);
1350
+ const neutral3 = splitColor(
1351
+ colorPalette.neutral,
1352
+ 16,
1353
+ Object.keys(colorPalette.neutral).length
1354
+ );
1355
+
1356
+ export { colorPalette, neutral1, neutral2, neutral3 };