@hanzogui/themes 2.0.0

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 (324) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/componentThemeDefinitions.cjs +124 -0
  3. package/dist/cjs/componentThemeDefinitions.native.js +127 -0
  4. package/dist/cjs/componentThemeDefinitions.native.js.map +1 -0
  5. package/dist/cjs/generated-new.cjs +2021 -0
  6. package/dist/cjs/generated-new.native.js +2040 -0
  7. package/dist/cjs/generated-new.native.js.map +1 -0
  8. package/dist/cjs/generated-v3.cjs +1099 -0
  9. package/dist/cjs/generated-v3.native.js +1118 -0
  10. package/dist/cjs/generated-v3.native.js.map +1 -0
  11. package/dist/cjs/generated-v4-gui.cjs +933 -0
  12. package/dist/cjs/generated-v4-gui.native.js +952 -0
  13. package/dist/cjs/generated-v4-gui.native.js.map +1 -0
  14. package/dist/cjs/generated-v4.cjs +391 -0
  15. package/dist/cjs/generated-v4.native.js +410 -0
  16. package/dist/cjs/generated-v4.native.js.map +1 -0
  17. package/dist/cjs/generated-v5-subtle.cjs +549 -0
  18. package/dist/cjs/generated-v5-subtle.native.js +568 -0
  19. package/dist/cjs/generated-v5-subtle.native.js.map +1 -0
  20. package/dist/cjs/generated-v5.cjs +549 -0
  21. package/dist/cjs/generated-v5.native.js +568 -0
  22. package/dist/cjs/generated-v5.native.js.map +1 -0
  23. package/dist/cjs/helpers.cjs +34 -0
  24. package/dist/cjs/helpers.native.js +39 -0
  25. package/dist/cjs/helpers.native.js.map +1 -0
  26. package/dist/cjs/index.cjs +25 -0
  27. package/dist/cjs/index.native.js +28 -0
  28. package/dist/cjs/index.native.js.map +1 -0
  29. package/dist/cjs/opacify.cjs +96 -0
  30. package/dist/cjs/opacify.native.js +106 -0
  31. package/dist/cjs/opacify.native.js.map +1 -0
  32. package/dist/cjs/palettes.cjs +52 -0
  33. package/dist/cjs/palettes.native.js +63 -0
  34. package/dist/cjs/palettes.native.js.map +1 -0
  35. package/dist/cjs/shadows.cjs +43 -0
  36. package/dist/cjs/shadows.native.js +46 -0
  37. package/dist/cjs/shadows.native.js.map +1 -0
  38. package/dist/cjs/subtleChildrenThemes.cjs +65 -0
  39. package/dist/cjs/subtleChildrenThemes.native.js +74 -0
  40. package/dist/cjs/subtleChildrenThemes.native.js.map +1 -0
  41. package/dist/cjs/templates.cjs +118 -0
  42. package/dist/cjs/templates.native.js +121 -0
  43. package/dist/cjs/templates.native.js.map +1 -0
  44. package/dist/cjs/themes-new.cjs +86 -0
  45. package/dist/cjs/themes-new.native.js +88 -0
  46. package/dist/cjs/themes-new.native.js.map +1 -0
  47. package/dist/cjs/themes-old.cjs +284 -0
  48. package/dist/cjs/themes-old.native.js +303 -0
  49. package/dist/cjs/themes-old.native.js.map +1 -0
  50. package/dist/cjs/themes.cjs +26 -0
  51. package/dist/cjs/themes.native.js +29 -0
  52. package/dist/cjs/themes.native.js.map +1 -0
  53. package/dist/cjs/tokens.cjs +155 -0
  54. package/dist/cjs/tokens.native.js +167 -0
  55. package/dist/cjs/tokens.native.js.map +1 -0
  56. package/dist/cjs/utils.cjs +40 -0
  57. package/dist/cjs/utils.native.js +46 -0
  58. package/dist/cjs/utils.native.js.map +1 -0
  59. package/dist/cjs/v3-themes.cjs +472 -0
  60. package/dist/cjs/v3-themes.native.js +487 -0
  61. package/dist/cjs/v3-themes.native.js.map +1 -0
  62. package/dist/cjs/v3-tokens.cjs +99 -0
  63. package/dist/cjs/v3-tokens.native.js +108 -0
  64. package/dist/cjs/v3-tokens.native.js.map +1 -0
  65. package/dist/cjs/v3.cjs +52 -0
  66. package/dist/cjs/v3.native.js +55 -0
  67. package/dist/cjs/v3.native.js.map +1 -0
  68. package/dist/cjs/v4-default.cjs +167 -0
  69. package/dist/cjs/v4-default.native.js +170 -0
  70. package/dist/cjs/v4-default.native.js.map +1 -0
  71. package/dist/cjs/v4-gui.cjs +235 -0
  72. package/dist/cjs/v4-gui.native.js +243 -0
  73. package/dist/cjs/v4-gui.native.js.map +1 -0
  74. package/dist/cjs/v4-tokens.cjs +99 -0
  75. package/dist/cjs/v4-tokens.native.js +108 -0
  76. package/dist/cjs/v4-tokens.native.js.map +1 -0
  77. package/dist/cjs/v4.cjs +32 -0
  78. package/dist/cjs/v4.native.js +35 -0
  79. package/dist/cjs/v4.native.js.map +1 -0
  80. package/dist/cjs/v5-subtle.cjs +34 -0
  81. package/dist/cjs/v5-subtle.native.js +37 -0
  82. package/dist/cjs/v5-subtle.native.js.map +1 -0
  83. package/dist/cjs/v5-templates.cjs +110 -0
  84. package/dist/cjs/v5-templates.native.js +126 -0
  85. package/dist/cjs/v5-templates.native.js.map +1 -0
  86. package/dist/cjs/v5-themes-subtle.cjs +37 -0
  87. package/dist/cjs/v5-themes-subtle.native.js +40 -0
  88. package/dist/cjs/v5-themes-subtle.native.js.map +1 -0
  89. package/dist/cjs/v5-themes.cjs +400 -0
  90. package/dist/cjs/v5-themes.native.js +445 -0
  91. package/dist/cjs/v5-themes.native.js.map +1 -0
  92. package/dist/cjs/v5-tokens.cjs +99 -0
  93. package/dist/cjs/v5-tokens.native.js +108 -0
  94. package/dist/cjs/v5-tokens.native.js.map +1 -0
  95. package/dist/cjs/v5.cjs +34 -0
  96. package/dist/cjs/v5.native.js +37 -0
  97. package/dist/cjs/v5.native.js.map +1 -0
  98. package/dist/esm/componentThemeDefinitions.mjs +100 -0
  99. package/dist/esm/componentThemeDefinitions.mjs.map +1 -0
  100. package/dist/esm/componentThemeDefinitions.native.js +100 -0
  101. package/dist/esm/componentThemeDefinitions.native.js.map +1 -0
  102. package/dist/esm/generated-new.mjs +1997 -0
  103. package/dist/esm/generated-new.mjs.map +1 -0
  104. package/dist/esm/generated-new.native.js +2013 -0
  105. package/dist/esm/generated-new.native.js.map +1 -0
  106. package/dist/esm/generated-v3.mjs +1075 -0
  107. package/dist/esm/generated-v3.mjs.map +1 -0
  108. package/dist/esm/generated-v3.native.js +1091 -0
  109. package/dist/esm/generated-v3.native.js.map +1 -0
  110. package/dist/esm/generated-v4-gui.mjs +909 -0
  111. package/dist/esm/generated-v4-gui.mjs.map +1 -0
  112. package/dist/esm/generated-v4-gui.native.js +925 -0
  113. package/dist/esm/generated-v4-gui.native.js.map +1 -0
  114. package/dist/esm/generated-v4.mjs +367 -0
  115. package/dist/esm/generated-v4.mjs.map +1 -0
  116. package/dist/esm/generated-v4.native.js +383 -0
  117. package/dist/esm/generated-v4.native.js.map +1 -0
  118. package/dist/esm/generated-v5-subtle.mjs +525 -0
  119. package/dist/esm/generated-v5-subtle.mjs.map +1 -0
  120. package/dist/esm/generated-v5-subtle.native.js +541 -0
  121. package/dist/esm/generated-v5-subtle.native.js.map +1 -0
  122. package/dist/esm/generated-v5.mjs +525 -0
  123. package/dist/esm/generated-v5.mjs.map +1 -0
  124. package/dist/esm/generated-v5.native.js +541 -0
  125. package/dist/esm/generated-v5.native.js.map +1 -0
  126. package/dist/esm/helpers.mjs +9 -0
  127. package/dist/esm/helpers.mjs.map +1 -0
  128. package/dist/esm/helpers.native.js +11 -0
  129. package/dist/esm/helpers.native.js.map +1 -0
  130. package/dist/esm/index.js +9 -0
  131. package/dist/esm/index.js.map +1 -0
  132. package/dist/esm/index.mjs +9 -0
  133. package/dist/esm/index.mjs.map +1 -0
  134. package/dist/esm/index.native.js +9 -0
  135. package/dist/esm/index.native.js.map +1 -0
  136. package/dist/esm/opacify.mjs +72 -0
  137. package/dist/esm/opacify.mjs.map +1 -0
  138. package/dist/esm/opacify.native.js +79 -0
  139. package/dist/esm/opacify.native.js.map +1 -0
  140. package/dist/esm/palettes.mjs +29 -0
  141. package/dist/esm/palettes.mjs.map +1 -0
  142. package/dist/esm/palettes.native.js +37 -0
  143. package/dist/esm/palettes.native.js.map +1 -0
  144. package/dist/esm/shadows.mjs +20 -0
  145. package/dist/esm/shadows.mjs.map +1 -0
  146. package/dist/esm/shadows.native.js +20 -0
  147. package/dist/esm/shadows.native.js.map +1 -0
  148. package/dist/esm/subtleChildrenThemes.mjs +41 -0
  149. package/dist/esm/subtleChildrenThemes.mjs.map +1 -0
  150. package/dist/esm/subtleChildrenThemes.native.js +47 -0
  151. package/dist/esm/subtleChildrenThemes.native.js.map +1 -0
  152. package/dist/esm/templates.mjs +94 -0
  153. package/dist/esm/templates.mjs.map +1 -0
  154. package/dist/esm/templates.native.js +94 -0
  155. package/dist/esm/templates.native.js.map +1 -0
  156. package/dist/esm/themes-new.mjs +63 -0
  157. package/dist/esm/themes-new.mjs.map +1 -0
  158. package/dist/esm/themes-new.native.js +62 -0
  159. package/dist/esm/themes-new.native.js.map +1 -0
  160. package/dist/esm/themes-old.mjs +261 -0
  161. package/dist/esm/themes-old.mjs.map +1 -0
  162. package/dist/esm/themes-old.native.js +277 -0
  163. package/dist/esm/themes-old.native.js.map +1 -0
  164. package/dist/esm/themes.mjs +3 -0
  165. package/dist/esm/themes.mjs.map +1 -0
  166. package/dist/esm/themes.native.js +3 -0
  167. package/dist/esm/themes.native.js.map +1 -0
  168. package/dist/esm/tokens.mjs +124 -0
  169. package/dist/esm/tokens.mjs.map +1 -0
  170. package/dist/esm/tokens.native.js +133 -0
  171. package/dist/esm/tokens.native.js.map +1 -0
  172. package/dist/esm/utils.mjs +14 -0
  173. package/dist/esm/utils.mjs.map +1 -0
  174. package/dist/esm/utils.native.js +17 -0
  175. package/dist/esm/utils.native.js.map +1 -0
  176. package/dist/esm/v3-themes.mjs +444 -0
  177. package/dist/esm/v3-themes.mjs.map +1 -0
  178. package/dist/esm/v3-themes.native.js +456 -0
  179. package/dist/esm/v3-themes.native.js.map +1 -0
  180. package/dist/esm/v3-tokens.mjs +70 -0
  181. package/dist/esm/v3-tokens.mjs.map +1 -0
  182. package/dist/esm/v3-tokens.native.js +76 -0
  183. package/dist/esm/v3-tokens.native.js.map +1 -0
  184. package/dist/esm/v3.mjs +12 -0
  185. package/dist/esm/v3.mjs.map +1 -0
  186. package/dist/esm/v3.native.js +12 -0
  187. package/dist/esm/v3.native.js.map +1 -0
  188. package/dist/esm/v4-default.mjs +133 -0
  189. package/dist/esm/v4-default.mjs.map +1 -0
  190. package/dist/esm/v4-default.native.js +133 -0
  191. package/dist/esm/v4-default.native.js.map +1 -0
  192. package/dist/esm/v4-gui.mjs +201 -0
  193. package/dist/esm/v4-gui.mjs.map +1 -0
  194. package/dist/esm/v4-gui.native.js +206 -0
  195. package/dist/esm/v4-gui.native.js.map +1 -0
  196. package/dist/esm/v4-tokens.mjs +70 -0
  197. package/dist/esm/v4-tokens.mjs.map +1 -0
  198. package/dist/esm/v4-tokens.native.js +76 -0
  199. package/dist/esm/v4-tokens.native.js.map +1 -0
  200. package/dist/esm/v4.mjs +6 -0
  201. package/dist/esm/v4.mjs.map +1 -0
  202. package/dist/esm/v4.native.js +6 -0
  203. package/dist/esm/v4.native.js.map +1 -0
  204. package/dist/esm/v5-subtle.mjs +7 -0
  205. package/dist/esm/v5-subtle.mjs.map +1 -0
  206. package/dist/esm/v5-subtle.native.js +7 -0
  207. package/dist/esm/v5-subtle.native.js.map +1 -0
  208. package/dist/esm/v5-templates.mjs +87 -0
  209. package/dist/esm/v5-templates.mjs.map +1 -0
  210. package/dist/esm/v5-templates.native.js +100 -0
  211. package/dist/esm/v5-templates.native.js.map +1 -0
  212. package/dist/esm/v5-themes-subtle.mjs +13 -0
  213. package/dist/esm/v5-themes-subtle.mjs.map +1 -0
  214. package/dist/esm/v5-themes-subtle.native.js +13 -0
  215. package/dist/esm/v5-themes-subtle.native.js.map +1 -0
  216. package/dist/esm/v5-themes.mjs +361 -0
  217. package/dist/esm/v5-themes.mjs.map +1 -0
  218. package/dist/esm/v5-themes.native.js +403 -0
  219. package/dist/esm/v5-themes.native.js.map +1 -0
  220. package/dist/esm/v5-tokens.mjs +70 -0
  221. package/dist/esm/v5-tokens.mjs.map +1 -0
  222. package/dist/esm/v5-tokens.native.js +76 -0
  223. package/dist/esm/v5-tokens.native.js.map +1 -0
  224. package/dist/esm/v5.mjs +7 -0
  225. package/dist/esm/v5.mjs.map +1 -0
  226. package/dist/esm/v5.native.js +7 -0
  227. package/dist/esm/v5.native.js.map +1 -0
  228. package/package.json +95 -0
  229. package/src/componentThemeDefinitions.tsx +129 -0
  230. package/src/generated-new.ts +2571 -0
  231. package/src/generated-v3.ts +1826 -0
  232. package/src/generated-v4-gui.ts +2200 -0
  233. package/src/generated-v4.ts +1004 -0
  234. package/src/generated-v5-subtle.ts +2170 -0
  235. package/src/generated-v5.ts +2188 -0
  236. package/src/helpers.ts +44 -0
  237. package/src/index.tsx +8 -0
  238. package/src/opacify.ts +125 -0
  239. package/src/palettes.tsx +91 -0
  240. package/src/shadows.tsx +19 -0
  241. package/src/subtleChildrenThemes.ts +54 -0
  242. package/src/templates.tsx +104 -0
  243. package/src/themes-new.ts +74 -0
  244. package/src/themes-old.tsx +378 -0
  245. package/src/themes.tsx +1 -0
  246. package/src/tokens.tsx +199 -0
  247. package/src/utils.ts +51 -0
  248. package/src/v3-themes.ts +650 -0
  249. package/src/v3-tokens.ts +103 -0
  250. package/src/v3.tsx +12 -0
  251. package/src/v4-default.ts +191 -0
  252. package/src/v4-gui.ts +287 -0
  253. package/src/v4-tokens.ts +105 -0
  254. package/src/v4.tsx +4 -0
  255. package/src/v5-subtle.tsx +11 -0
  256. package/src/v5-templates.ts +126 -0
  257. package/src/v5-themes-subtle.ts +18 -0
  258. package/src/v5-themes.ts +626 -0
  259. package/src/v5-tokens.ts +107 -0
  260. package/src/v5.tsx +11 -0
  261. package/tests/v5-themes.test.ts +215 -0
  262. package/tsconfig.json +43 -0
  263. package/types/componentThemeDefinitions.d.ts +771 -0
  264. package/types/generated-new.d.ts +135 -0
  265. package/types/generated-v3.d.ts +144 -0
  266. package/types/generated-v4-gui.d.ts +190 -0
  267. package/types/generated-v4.d.ts +137 -0
  268. package/types/generated-v5-subtle.d.ts +244 -0
  269. package/types/generated-v5.d.ts +244 -0
  270. package/types/helpers.d.ts +24 -0
  271. package/types/index.d.ts +9 -0
  272. package/types/opacify.d.ts +9 -0
  273. package/types/palettes.d.ts +21 -0
  274. package/types/shadows.d.ts +15 -0
  275. package/types/subtleChildrenThemes.d.ts +305 -0
  276. package/types/templates.d.ts +155 -0
  277. package/types/themes-new.d.ts +42243 -0
  278. package/types/themes-old.d.ts +51411 -0
  279. package/types/themes.d.ts +2 -0
  280. package/types/tokens.d.ts +1308 -0
  281. package/types/utils.d.ts +21 -0
  282. package/types/v3-themes.d.ts +16304 -0
  283. package/types/v3-tokens.d.ts +184 -0
  284. package/types/v3.d.ts +11 -0
  285. package/types/v4-default.d.ts +274 -0
  286. package/types/v4-gui.d.ts +195 -0
  287. package/types/v4-tokens.d.ts +184 -0
  288. package/types/v4.d.ts +5 -0
  289. package/types/v5-subtle.d.ts +8 -0
  290. package/types/v5-templates.d.ts +42 -0
  291. package/types/v5-themes-subtle.d.ts +250 -0
  292. package/types/v5-themes.d.ts +752 -0
  293. package/types/v5-tokens.d.ts +185 -0
  294. package/types/v5.d.ts +8 -0
  295. package/v3/index.cjs +2 -0
  296. package/v3/index.js +2 -0
  297. package/v3/index.native.cjs +2 -0
  298. package/v3/index.native.js +2 -0
  299. package/v3-themes/index.cjs +2 -0
  300. package/v3-themes/index.js +2 -0
  301. package/v3-themes/index.native.cjs +2 -0
  302. package/v3-themes/index.native.js +2 -0
  303. package/v3-themes.cjs +1 -0
  304. package/v3-themes.d.ts +1 -0
  305. package/v3.cjs +1 -0
  306. package/v3.d.ts +1 -0
  307. package/v4/index.cjs +2 -0
  308. package/v4/index.js +2 -0
  309. package/v4/index.native.cjs +2 -0
  310. package/v4/index.native.js +2 -0
  311. package/v4.cjs +1 -0
  312. package/v4.d.ts +1 -0
  313. package/v5/index.cjs +2 -0
  314. package/v5/index.js +2 -0
  315. package/v5/index.native.cjs +2 -0
  316. package/v5/index.native.js +2 -0
  317. package/v5-subtle/index.cjs +2 -0
  318. package/v5-subtle/index.js +2 -0
  319. package/v5-subtle/index.native.cjs +2 -0
  320. package/v5-subtle/index.native.js +2 -0
  321. package/v5-subtle.cjs +1 -0
  322. package/v5-subtle.d.ts +1 -0
  323. package/v5.cjs +1 -0
  324. package/v5.d.ts +1 -0
@@ -0,0 +1,650 @@
1
+ import {
2
+ blue,
3
+ blueDark,
4
+ gray,
5
+ grayDark,
6
+ green,
7
+ greenDark,
8
+ orange,
9
+ orangeDark,
10
+ pink,
11
+ pinkDark,
12
+ purple,
13
+ purpleDark,
14
+ red,
15
+ redDark,
16
+ yellow,
17
+ yellowDark,
18
+ } from '@hanzogui/colors/legacy'
19
+ import { createThemeBuilder, objectFromEntries } from '@hanzogui/theme-builder'
20
+ import { createTokens } from '@hanzogui/web'
21
+ import { objectKeys, postfixObjKeys } from './utils'
22
+ import { tokens as v3Tokens } from './v3-tokens'
23
+
24
+ const colorTokens = {
25
+ light: {
26
+ blue,
27
+ gray,
28
+ green,
29
+ orange,
30
+ pink,
31
+ purple,
32
+ red,
33
+ yellow,
34
+ },
35
+ dark: {
36
+ blue: blueDark,
37
+ gray: grayDark,
38
+ green: greenDark,
39
+ orange: orangeDark,
40
+ pink: pinkDark,
41
+ purple: purpleDark,
42
+ red: redDark,
43
+ yellow: yellowDark,
44
+ },
45
+ }
46
+
47
+ const lightShadowColor = 'rgba(0,0,0,0.04)'
48
+ const lightShadowColorStrong = 'rgba(0,0,0,0.085)'
49
+ const darkShadowColor = 'rgba(0,0,0,0.2)'
50
+ const darkShadowColorStrong = 'rgba(0,0,0,0.3)'
51
+
52
+ const darkColors = {
53
+ ...colorTokens.dark.blue,
54
+ ...colorTokens.dark.gray,
55
+ ...colorTokens.dark.green,
56
+ ...colorTokens.dark.orange,
57
+ ...colorTokens.dark.pink,
58
+ ...colorTokens.dark.purple,
59
+ ...colorTokens.dark.red,
60
+ ...colorTokens.dark.yellow,
61
+ }
62
+
63
+ const lightColors = {
64
+ ...colorTokens.light.blue,
65
+ ...colorTokens.light.gray,
66
+ ...colorTokens.light.green,
67
+ ...colorTokens.light.orange,
68
+ ...colorTokens.light.pink,
69
+ ...colorTokens.light.purple,
70
+ ...colorTokens.light.red,
71
+ ...colorTokens.light.yellow,
72
+ }
73
+
74
+ const color = {
75
+ white0: 'rgba(255,255,255,0)',
76
+ white075: 'rgba(255,255,255,0.75)',
77
+ white05: 'rgba(255,255,255,0.5)',
78
+ white025: 'rgba(255,255,255,0.25)',
79
+ black0: 'rgba(10,10,10,0)',
80
+ black075: 'rgba(10,10,10,0.75)',
81
+ black05: 'rgba(10,10,10,0.5)',
82
+ black025: 'rgba(10,10,10,0.25)',
83
+ white1: '#fff',
84
+ white2: '#f8f8f8',
85
+ white3: 'hsl(0, 0%, 96.3%)',
86
+ white4: 'hsl(0, 0%, 94.1%)',
87
+ white5: 'hsl(0, 0%, 92.0%)',
88
+ white6: 'hsl(0, 0%, 90.0%)',
89
+ white7: 'hsl(0, 0%, 88.5%)',
90
+ white8: 'hsl(0, 0%, 81.0%)',
91
+ white9: 'hsl(0, 0%, 56.1%)',
92
+ white10: 'hsl(0, 0%, 50.3%)',
93
+ white11: 'hsl(0, 0%, 42.5%)',
94
+ white12: 'hsl(0, 0%, 9.0%)',
95
+ black1: '#050505',
96
+ black2: '#151515',
97
+ black3: '#191919',
98
+ black4: '#232323',
99
+ black5: '#282828',
100
+ black6: '#323232',
101
+ black7: '#424242',
102
+ black8: '#494949',
103
+ black9: '#545454',
104
+ black10: '#626262',
105
+ black11: '#a5a5a5',
106
+ black12: '#fff',
107
+ ...postfixObjKeys(lightColors, 'Light'),
108
+ ...postfixObjKeys(darkColors, 'Dark'),
109
+ }
110
+
111
+ export const defaultPalettes = (() => {
112
+ const transparent = (hsl: string, opacity = 0) =>
113
+ hsl.replace(`%)`, `%, ${opacity})`).replace(`hsl(`, `hsla(`)
114
+
115
+ const getColorPalette = (colors: object, accentColors: object): string[] => {
116
+ const colorPalette = Object.values(colors)
117
+ // make the transparent color vibrant and towards the middle
118
+ const colorI = colorPalette.length - 4
119
+
120
+ // accents!
121
+ const accentPalette = Object.values(accentColors)
122
+ const accentBackground = accentPalette[0]
123
+ const accentColor = accentPalette[accentPalette.length - 1]
124
+
125
+ // add our transparent colors first/last
126
+ // and make sure the last (foreground) color is white/black rather than colorful
127
+ // this is mostly for consistency with the older theme-base
128
+ return [
129
+ accentBackground,
130
+ transparent(colorPalette[0], 0),
131
+ transparent(colorPalette[0], 0.25),
132
+ transparent(colorPalette[0], 0.5),
133
+ transparent(colorPalette[0], 0.75),
134
+ ...colorPalette,
135
+ transparent(colorPalette[colorI], 0.75),
136
+ transparent(colorPalette[colorI], 0.5),
137
+ transparent(colorPalette[colorI], 0.25),
138
+ transparent(colorPalette[colorI], 0),
139
+ accentColor,
140
+ ]
141
+ }
142
+
143
+ const brandColor = {
144
+ light: color.blue4Light,
145
+ dark: color.blue4Dark,
146
+ }
147
+
148
+ const lightPalette = [
149
+ brandColor.light,
150
+ color.white0,
151
+ color.white025,
152
+ color.white05,
153
+ color.white075,
154
+ color.white1,
155
+ color.white2,
156
+ color.white3,
157
+ color.white4,
158
+ color.white5,
159
+ color.white6,
160
+ color.white7,
161
+ color.white8,
162
+ color.white9,
163
+ color.white10,
164
+ color.white11,
165
+ color.white12,
166
+ color.black075,
167
+ color.black05,
168
+ color.black025,
169
+ color.black0,
170
+ brandColor.dark,
171
+ ]
172
+
173
+ const darkPalette = [
174
+ brandColor.dark,
175
+ color.black0,
176
+ color.black025,
177
+ color.black05,
178
+ color.black075,
179
+ color.black1,
180
+ color.black2,
181
+ color.black3,
182
+ color.black4,
183
+ color.black5,
184
+ color.black6,
185
+ color.black7,
186
+ color.black8,
187
+ color.black9,
188
+ color.black10,
189
+ color.black11,
190
+ color.black12,
191
+ color.white075,
192
+ color.white05,
193
+ color.white025,
194
+ color.white0,
195
+ brandColor.light,
196
+ ]
197
+
198
+ const lightColorNames = objectKeys(colorTokens.light)
199
+ const lightPalettes = objectFromEntries(
200
+ lightColorNames.map(
201
+ (key, index) =>
202
+ [
203
+ `light_${key}`,
204
+ getColorPalette(
205
+ colorTokens.light[key],
206
+ colorTokens.light[lightColorNames[(index + 1) % lightColorNames.length]]
207
+ ),
208
+ ] as const
209
+ )
210
+ )
211
+
212
+ const darkColorNames = objectKeys(colorTokens.dark)
213
+ const darkPalettes = objectFromEntries(
214
+ darkColorNames.map(
215
+ (key, index) =>
216
+ [
217
+ `dark_${key}`,
218
+ getColorPalette(
219
+ colorTokens.dark[key],
220
+ colorTokens.dark[darkColorNames[(index + 1) % darkColorNames.length]]
221
+ ),
222
+ ] as const
223
+ )
224
+ )
225
+
226
+ const colorPalettes = {
227
+ ...lightPalettes,
228
+ ...darkPalettes,
229
+ }
230
+
231
+ return {
232
+ light: lightPalette,
233
+ dark: darkPalette,
234
+ ...colorPalettes,
235
+ }
236
+ })()
237
+
238
+ const getTemplates = () => {
239
+ const getBaseTemplates = (scheme: 'dark' | 'light') => {
240
+ const isLight = scheme === 'light'
241
+
242
+ // our palettes have 4 things padding each end until you get to bg/color:
243
+ // [accentBg, transparent1, transparent2, transparent3, transparent4, background, ...]
244
+ const bgIndex = 5
245
+ const lighten = isLight ? -1 : 1
246
+ const darken = -lighten
247
+ const borderColor = bgIndex + 3
248
+
249
+ // templates use the palette and specify index
250
+ // negative goes backwards from end so -1 is the last item
251
+ const base = {
252
+ accentBackground: 0,
253
+ accentColor: -0,
254
+
255
+ background0: 1,
256
+ background025: 2,
257
+ background05: 3,
258
+ background075: 4,
259
+ color1: bgIndex,
260
+ color2: bgIndex + 1,
261
+ color3: bgIndex + 2,
262
+ color4: bgIndex + 3,
263
+ color5: bgIndex + 4,
264
+ color6: bgIndex + 5,
265
+ color7: bgIndex + 6,
266
+ color8: bgIndex + 7,
267
+ color9: bgIndex + 8,
268
+ color10: bgIndex + 9,
269
+ color11: bgIndex + 10,
270
+ color12: bgIndex + 11,
271
+ color0: -1,
272
+ color025: -2,
273
+ color05: -3,
274
+ color075: -4,
275
+ // the background, color, etc keys here work like generics - they make it so you
276
+ // can publish components for others to use without mandating a specific color scale
277
+ // the @hanzogui/button Button component looks for `$background`, so you set the
278
+ // dark_red_Button theme to have a stronger background than the dark_red theme.
279
+ background: bgIndex,
280
+ backgroundHover: bgIndex + lighten, // always lighten on hover no matter the scheme
281
+ backgroundPress: bgIndex + darken, // always darken on press no matter the theme
282
+ backgroundFocus: bgIndex + darken,
283
+ borderColor,
284
+ borderColorHover: borderColor + lighten,
285
+ borderColorPress: borderColor + darken,
286
+ borderColorFocus: borderColor,
287
+ color: -bgIndex,
288
+ colorHover: -bgIndex - 1,
289
+ colorPress: -bgIndex,
290
+ colorFocus: -bgIndex - 1,
291
+ colorTransparent: -1,
292
+ placeholderColor: -bgIndex - 3,
293
+ outlineColor: -2,
294
+ }
295
+
296
+ const surface1 = {
297
+ background: base.background + 1,
298
+ backgroundHover: base.backgroundHover + 1,
299
+ backgroundPress: base.backgroundPress + 1,
300
+ backgroundFocus: base.backgroundFocus + 1,
301
+ borderColor: base.borderColor + 1,
302
+ borderColorHover: base.borderColorHover + 1,
303
+ borderColorFocus: base.borderColorFocus + 1,
304
+ borderColorPress: base.borderColorPress + 1,
305
+ }
306
+
307
+ const surface2 = {
308
+ background: base.background + 2,
309
+ backgroundHover: base.backgroundHover + 2,
310
+ backgroundPress: base.backgroundPress + 2,
311
+ backgroundFocus: base.backgroundFocus + 2,
312
+ borderColor: base.borderColor + 2,
313
+ borderColorHover: base.borderColorHover + 2,
314
+ borderColorFocus: base.borderColorFocus + 2,
315
+ borderColorPress: base.borderColorPress + 2,
316
+ }
317
+
318
+ const surface3 = {
319
+ background: base.background + 3,
320
+ backgroundHover: base.backgroundHover + 3,
321
+ backgroundPress: base.backgroundPress + 3,
322
+ backgroundFocus: base.backgroundFocus + 3,
323
+ borderColor: base.borderColor + 3,
324
+ borderColorHover: base.borderColorHover + 3,
325
+ borderColorFocus: base.borderColorFocus + 3,
326
+ borderColorPress: base.borderColorPress + 3,
327
+ }
328
+
329
+ const surfaceActiveBg = {
330
+ background: base.background + 5,
331
+ backgroundHover: base.background + 5,
332
+ backgroundPress: base.backgroundPress + 5,
333
+ backgroundFocus: base.backgroundFocus + 5,
334
+ }
335
+
336
+ const surfaceActive = {
337
+ ...surfaceActiveBg,
338
+ // match border to background when active
339
+ borderColor: surfaceActiveBg.background,
340
+ borderColorHover: surfaceActiveBg.backgroundHover,
341
+ borderColorFocus: surfaceActiveBg.backgroundFocus,
342
+ borderColorPress: surfaceActiveBg.backgroundPress,
343
+ }
344
+
345
+ const inverseSurface1 = {
346
+ color: surface1.background,
347
+ colorHover: surface1.backgroundHover,
348
+ colorPress: surface1.backgroundPress,
349
+ colorFocus: surface1.backgroundFocus,
350
+ background: base.color,
351
+ backgroundHover: base.colorHover,
352
+ backgroundPress: base.colorPress,
353
+ backgroundFocus: base.colorFocus,
354
+ borderColor: base.color - 2,
355
+ borderColorHover: base.color - 3,
356
+ borderColorFocus: base.color - 4,
357
+ borderColorPress: base.color - 5,
358
+ }
359
+
360
+ const inverseActive = {
361
+ ...inverseSurface1,
362
+ background: base.color - 2,
363
+ backgroundHover: base.colorHover - 2,
364
+ backgroundPress: base.colorPress - 2,
365
+ backgroundFocus: base.colorFocus - 2,
366
+ borderColor: base.color - 2 - 2,
367
+ borderColorHover: base.color - 3 - 2,
368
+ borderColorFocus: base.color - 4 - 2,
369
+ borderColorPress: base.color - 5 - 2,
370
+ }
371
+
372
+ const alt1 = {
373
+ color: base.color - 1,
374
+ colorHover: base.colorHover - 1,
375
+ colorPress: base.colorPress - 1,
376
+ colorFocus: base.colorFocus - 1,
377
+ }
378
+
379
+ const alt2 = {
380
+ color: base.color - 2,
381
+ colorHover: base.colorHover - 2,
382
+ colorPress: base.colorPress - 2,
383
+ colorFocus: base.colorFocus - 2,
384
+ }
385
+
386
+ return {
387
+ base,
388
+ alt1,
389
+ alt2,
390
+ surface1,
391
+ surface2,
392
+ surface3,
393
+ inverseSurface1,
394
+ inverseActive,
395
+ surfaceActive,
396
+ }
397
+ }
398
+
399
+ const lightTemplates = getBaseTemplates('light')
400
+ const darkTemplates = getBaseTemplates('dark')
401
+ const templates = {
402
+ ...objectFromEntries(
403
+ objectKeys(lightTemplates).map(
404
+ (name) => [`light_${name}`, lightTemplates[name]] as const
405
+ )
406
+ ),
407
+ ...objectFromEntries(
408
+ objectKeys(darkTemplates).map(
409
+ (name) => [`dark_${name}`, darkTemplates[name]] as const
410
+ )
411
+ ),
412
+ }
413
+ return templates as Record<keyof typeof templates, typeof lightTemplates.base>
414
+ }
415
+
416
+ export const defaultTemplates = getTemplates()
417
+
418
+ const shadows = {
419
+ light: {
420
+ shadowColor: lightShadowColorStrong,
421
+ shadowColorHover: lightShadowColorStrong,
422
+ shadowColorPress: lightShadowColor,
423
+ shadowColorFocus: lightShadowColor,
424
+ },
425
+ dark: {
426
+ shadowColor: darkShadowColorStrong,
427
+ shadowColorHover: darkShadowColorStrong,
428
+ shadowColorPress: darkShadowColor,
429
+ shadowColorFocus: darkShadowColor,
430
+ },
431
+ }
432
+
433
+ const nonInherited = {
434
+ light: {
435
+ ...lightColors,
436
+ ...shadows.light,
437
+ },
438
+ dark: {
439
+ ...darkColors,
440
+ ...shadows.dark,
441
+ },
442
+ }
443
+
444
+ const overlayThemeDefinitions = [
445
+ {
446
+ parent: 'light',
447
+ theme: {
448
+ background: 'rgba(0,0,0,0.5)',
449
+ },
450
+ },
451
+ {
452
+ parent: 'dark',
453
+ theme: {
454
+ background: 'rgba(0,0,0,0.8)',
455
+ },
456
+ },
457
+ ]
458
+
459
+ const inverseSurface1 = [
460
+ {
461
+ parent: 'active',
462
+ template: 'inverseActive',
463
+ },
464
+ {
465
+ parent: '',
466
+ template: 'inverseSurface1',
467
+ },
468
+ ] as any
469
+
470
+ const surface1 = [
471
+ {
472
+ parent: 'active',
473
+ template: 'surfaceActive',
474
+ },
475
+ {
476
+ parent: '',
477
+ template: 'surface1',
478
+ },
479
+ ] as any
480
+
481
+ const surface2 = [
482
+ {
483
+ parent: 'active',
484
+ template: 'surfaceActive',
485
+ },
486
+ {
487
+ parent: '',
488
+ template: 'surface2',
489
+ },
490
+ ] as any
491
+
492
+ const surface3 = [
493
+ {
494
+ parent: 'active',
495
+ template: 'surfaceActive',
496
+ },
497
+ {
498
+ parent: '',
499
+ template: 'surface3',
500
+ },
501
+ ] as any
502
+
503
+ /**
504
+ * These are optional themes that serve as defaults for components. They don't
505
+ * change color1 through color12 just "generic" properties like color,
506
+ * background, borderColor.
507
+ *
508
+ * They can be overridden with the theme prop, or left out entirely for
509
+ * "un-themed" components.
510
+
511
+ */
512
+ export const defaultComponentThemes = {
513
+ ListItem: {
514
+ template: 'surface1',
515
+ },
516
+ SelectTrigger: surface1,
517
+ Card: surface1,
518
+ Button: surface3,
519
+ Checkbox: surface2,
520
+ Switch: surface2,
521
+ SwitchThumb: inverseSurface1,
522
+ TooltipContent: surface2,
523
+ Progress: {
524
+ template: 'surface1',
525
+ },
526
+ RadioGroupItem: surface2,
527
+ TooltipArrow: {
528
+ template: 'surface1',
529
+ },
530
+ SliderTrackActive: {
531
+ template: 'surface3',
532
+ },
533
+ SliderTrack: {
534
+ template: 'surface1',
535
+ },
536
+ SliderThumb: inverseSurface1,
537
+ Tooltip: inverseSurface1,
538
+ ProgressIndicator: inverseSurface1,
539
+ SheetOverlay: overlayThemeDefinitions,
540
+ DialogOverlay: overlayThemeDefinitions,
541
+ ModalOverlay: overlayThemeDefinitions,
542
+ Input: surface1,
543
+ TextArea: surface1,
544
+ } as const
545
+
546
+ /**
547
+ * These are useful for states (alt gets more subtle as it goes up) or emphasis
548
+ * (surface gets more contrasted from the background as it goes up)
549
+ */
550
+
551
+ export const defaultSubThemes = {
552
+ alt1: {
553
+ template: 'alt1',
554
+ },
555
+ alt2: {
556
+ template: 'alt2',
557
+ },
558
+ active: {
559
+ template: 'surface3',
560
+ },
561
+ surface1: {
562
+ template: 'surface1',
563
+ },
564
+ surface2: {
565
+ template: 'surface2',
566
+ },
567
+ surface3: {
568
+ template: 'surface3',
569
+ },
570
+ surface4: {
571
+ template: 'surfaceActive',
572
+ },
573
+ } as const
574
+
575
+ // --- themeBuilder ---
576
+
577
+ const themeBuilder = createThemeBuilder()
578
+ .addPalettes(defaultPalettes)
579
+ .addTemplates(defaultTemplates)
580
+ .addThemes({
581
+ light: {
582
+ template: 'base',
583
+ palette: 'light',
584
+ nonInheritedValues: nonInherited.light,
585
+ },
586
+ dark: {
587
+ template: 'base',
588
+ palette: 'dark',
589
+ nonInheritedValues: nonInherited.dark,
590
+ },
591
+ })
592
+ .addChildThemes({
593
+ orange: {
594
+ palette: 'orange',
595
+ template: 'base',
596
+ },
597
+ yellow: {
598
+ palette: 'yellow',
599
+ template: 'base',
600
+ },
601
+ green: {
602
+ palette: 'green',
603
+ template: 'base',
604
+ },
605
+ blue: {
606
+ palette: 'blue',
607
+ template: 'base',
608
+ },
609
+ purple: {
610
+ palette: 'purple',
611
+ template: 'base',
612
+ },
613
+ pink: {
614
+ palette: 'pink',
615
+ template: 'base',
616
+ },
617
+ red: {
618
+ palette: 'red',
619
+ template: 'base',
620
+ },
621
+ gray: {
622
+ palette: 'gray',
623
+ template: 'base',
624
+ },
625
+ })
626
+ .addChildThemes(defaultSubThemes)
627
+ .addComponentThemes(defaultComponentThemes, {
628
+ avoidNestingWithin: ['alt1', 'alt2', 'surface1', 'surface2', 'surface3', 'surface4'],
629
+ })
630
+
631
+ // --- themes ---
632
+
633
+ const themesIn = themeBuilder.build()
634
+
635
+ type ThemeKeys =
636
+ | keyof typeof defaultTemplates.light_base
637
+ | keyof typeof nonInherited.light
638
+
639
+ export type Theme = Record<ThemeKeys, string>
640
+
641
+ export type ThemesOut = Record<keyof typeof themesIn, Theme>
642
+
643
+ export const themes = themesIn as any as ThemesOut
644
+
645
+ // -- tokens ---
646
+
647
+ export const tokens = createTokens({
648
+ color,
649
+ ...v3Tokens,
650
+ })