expo-dev-client-components 1.0.0 → 1.1.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 (255) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +129 -0
  3. package/assets/branch-icon-light.png +0 -0
  4. package/assets/branch-icon-light@2x.png +0 -0
  5. package/assets/branch-icon-light@3x.png +0 -0
  6. package/assets/branch-icon.png +0 -0
  7. package/assets/branch-icon@2x.png +0 -0
  8. package/assets/branch-icon@3x.png +0 -0
  9. package/assets/check-icon-light.png +0 -0
  10. package/assets/check-icon-light@2x.png +0 -0
  11. package/assets/check-icon-light@3x.png +0 -0
  12. package/assets/check-icon.png +0 -0
  13. package/assets/check-icon@2x.png +0 -0
  14. package/assets/check-icon@3x.png +0 -0
  15. package/assets/clipboard-icon.png +0 -0
  16. package/assets/clipboard-icon@2x.png +0 -0
  17. package/assets/clipboard-icon@3x.png +0 -0
  18. package/assets/debug-icon.png +0 -0
  19. package/assets/debug-icon@2x.png +0 -0
  20. package/assets/debug-icon@3x.png +0 -0
  21. package/assets/extensions-filled-active-icon-light.png +0 -0
  22. package/assets/extensions-filled-active-icon-light@2x.png +0 -0
  23. package/assets/extensions-filled-active-icon-light@3x.png +0 -0
  24. package/assets/extensions-filled-active-icon.png +0 -0
  25. package/assets/extensions-filled-active-icon@2x.png +0 -0
  26. package/assets/extensions-filled-active-icon@3x.png +0 -0
  27. package/assets/extensions-filled-inactive-icon-light.png +0 -0
  28. package/assets/extensions-filled-inactive-icon-light@2x.png +0 -0
  29. package/assets/extensions-filled-inactive-icon-light@3x.png +0 -0
  30. package/assets/extensions-filled-inactive-icon.png +0 -0
  31. package/assets/extensions-filled-inactive-icon@2x.png +0 -0
  32. package/assets/extensions-filled-inactive-icon@3x.png +0 -0
  33. package/assets/extensions-icon-light.png +0 -0
  34. package/assets/extensions-icon-light@2x.png +0 -0
  35. package/assets/extensions-icon-light@3x.png +0 -0
  36. package/assets/extensions-icon.png +0 -0
  37. package/assets/extensions-icon@2x.png +0 -0
  38. package/assets/extensions-icon@3x.png +0 -0
  39. package/assets/home-filled-active-icon-light.png +0 -0
  40. package/assets/home-filled-active-icon-light@2x.png +0 -0
  41. package/assets/home-filled-active-icon-light@3x.png +0 -0
  42. package/assets/home-filled-inactive-icon-light.png +0 -0
  43. package/assets/home-filled-inactive-icon-light@2x.png +0 -0
  44. package/assets/home-filled-inactive-icon-light@3x.png +0 -0
  45. package/assets/info-icon-light.png +0 -0
  46. package/assets/info-icon-light@2x.png +0 -0
  47. package/assets/info-icon-light@3x.png +0 -0
  48. package/assets/info-icon.png +0 -0
  49. package/assets/info-icon@2x.png +0 -0
  50. package/assets/info-icon@3x.png +0 -0
  51. package/assets/inspect-element-icon.png +0 -0
  52. package/assets/inspect-element-icon@2x.png +0 -0
  53. package/assets/inspect-element-icon@3x.png +0 -0
  54. package/assets/loading-indicator-icon.png +0 -0
  55. package/assets/loading-indicator-icon@2x.png +0 -0
  56. package/assets/loading-indicator-icon@3x.png +0 -0
  57. package/assets/performance-icon.png +0 -0
  58. package/assets/performance-icon@2x.png +0 -0
  59. package/assets/performance-icon@3x.png +0 -0
  60. package/assets/run-icon.png +0 -0
  61. package/assets/run-icon@2x.png +0 -0
  62. package/assets/run-icon@3x.png +0 -0
  63. package/assets/settings-filled-active-icon-light.png +0 -0
  64. package/assets/settings-filled-active-icon-light@2x.png +0 -0
  65. package/assets/settings-filled-active-icon-light@3x.png +0 -0
  66. package/assets/settings-filled-inactive-icon-light.png +0 -0
  67. package/assets/settings-filled-inactive-icon-light@2x.png +0 -0
  68. package/assets/settings-filled-inactive-icon-light@3x.png +0 -0
  69. package/assets/shake-device-icon-light.png +0 -0
  70. package/assets/shake-device-icon-light@2x.png +0 -0
  71. package/assets/shake-device-icon-light@3x.png +0 -0
  72. package/assets/show-menu-at-launch-icon-light.png +0 -0
  73. package/assets/show-menu-at-launch-icon-light@2x.png +0 -0
  74. package/assets/show-menu-at-launch-icon-light@3x.png +0 -0
  75. package/assets/three-finger-long-press-icon-light.png +0 -0
  76. package/assets/three-finger-long-press-icon-light@2x.png +0 -0
  77. package/assets/three-finger-long-press-icon-light@3x.png +0 -0
  78. package/assets/update-icon-light.png +0 -0
  79. package/assets/update-icon-light@2x.png +0 -0
  80. package/assets/update-icon-light@3x.png +0 -0
  81. package/assets/update-icon.png +0 -0
  82. package/assets/update-icon@2x.png +0 -0
  83. package/assets/update-icon@3x.png +0 -0
  84. package/assets/user-icon-light.png +0 -0
  85. package/assets/user-icon-light@2x.png +0 -0
  86. package/assets/user-icon-light@3x.png +0 -0
  87. package/assets/warning-triangle-icon-light.png +0 -0
  88. package/assets/warning-triangle-icon-light@2x.png +0 -0
  89. package/assets/warning-triangle-icon-light@3x.png +0 -0
  90. package/assets/warning-triangle-icon.png +0 -0
  91. package/assets/warning-triangle-icon@2x.png +0 -0
  92. package/assets/warning-triangle-icon@3x.png +0 -0
  93. package/assets/x-icon-light.png +0 -0
  94. package/assets/x-icon-light@2x.png +0 -0
  95. package/assets/x-icon-light@3x.png +0 -0
  96. package/assets/x-icon.png +0 -0
  97. package/assets/x-icon@2x.png +0 -0
  98. package/assets/x-icon@3x.png +0 -0
  99. package/build/Button.d.ts +46 -22
  100. package/build/Button.d.ts.map +1 -0
  101. package/build/Button.js +4 -3
  102. package/build/Button.js.map +1 -1
  103. package/build/Image.d.ts +7 -1
  104. package/build/Image.d.ts.map +1 -0
  105. package/build/Image.js +1 -1
  106. package/build/Image.js.map +1 -1
  107. package/build/Text.d.ts +36 -10
  108. package/build/Text.d.ts.map +1 -0
  109. package/build/Text.js +30 -21
  110. package/build/Text.js.map +1 -1
  111. package/build/View.d.ts +80 -28
  112. package/build/View.d.ts.map +1 -0
  113. package/build/View.js +93 -43
  114. package/build/View.js.map +1 -1
  115. package/build/create-primitive.d.ts +41 -0
  116. package/build/create-primitive.d.ts.map +1 -0
  117. package/build/create-primitive.js +73 -0
  118. package/build/create-primitive.js.map +1 -0
  119. package/build/icons/BranchIcon.d.ts +4 -0
  120. package/build/icons/BranchIcon.d.ts.map +1 -0
  121. package/build/icons/BranchIcon.js +11 -0
  122. package/build/icons/BranchIcon.js.map +1 -0
  123. package/build/icons/CheckIcon.d.ts +1 -0
  124. package/build/icons/CheckIcon.d.ts.map +1 -0
  125. package/build/icons/CheckIcon.js +5 -1
  126. package/build/icons/CheckIcon.js.map +1 -1
  127. package/build/icons/ChevronRightIcon.d.ts +1 -0
  128. package/build/icons/ChevronRightIcon.d.ts.map +1 -0
  129. package/build/icons/ClipboardIcon.d.ts +4 -0
  130. package/build/icons/ClipboardIcon.d.ts.map +1 -0
  131. package/build/icons/ClipboardIcon.js +7 -0
  132. package/build/icons/ClipboardIcon.js.map +1 -0
  133. package/build/icons/DebugIcon.d.ts +4 -0
  134. package/build/icons/DebugIcon.d.ts.map +1 -0
  135. package/build/icons/DebugIcon.js +7 -0
  136. package/build/icons/DebugIcon.js.map +1 -0
  137. package/build/icons/ExpoLogoIcon.d.ts +1 -0
  138. package/build/icons/ExpoLogoIcon.d.ts.map +1 -0
  139. package/build/icons/ExtensionsFilledIcon.d.ts +8 -0
  140. package/build/icons/ExtensionsFilledIcon.d.ts.map +1 -0
  141. package/build/icons/ExtensionsFilledIcon.js +24 -0
  142. package/build/icons/ExtensionsFilledIcon.js.map +1 -0
  143. package/build/icons/ExtensionsIcon.d.ts +4 -0
  144. package/build/icons/ExtensionsIcon.d.ts.map +1 -0
  145. package/build/icons/ExtensionsIcon.js +11 -0
  146. package/build/icons/ExtensionsIcon.js.map +1 -0
  147. package/build/icons/HomeFilledIcon.d.ts +1 -0
  148. package/build/icons/HomeFilledIcon.d.ts.map +1 -0
  149. package/build/icons/HomeFilledIcon.js +16 -1
  150. package/build/icons/HomeFilledIcon.js.map +1 -1
  151. package/build/icons/InfoIcon.d.ts +1 -0
  152. package/build/icons/InfoIcon.d.ts.map +1 -0
  153. package/build/icons/InfoIcon.js +5 -1
  154. package/build/icons/InfoIcon.js.map +1 -1
  155. package/build/icons/InspectElementIcon.d.ts +4 -0
  156. package/build/icons/InspectElementIcon.d.ts.map +1 -0
  157. package/build/icons/InspectElementIcon.js +7 -0
  158. package/build/icons/InspectElementIcon.js.map +1 -0
  159. package/build/icons/LoadingIndicatorIcon.d.ts +4 -0
  160. package/build/icons/LoadingIndicatorIcon.d.ts.map +1 -0
  161. package/build/icons/LoadingIndicatorIcon.js +7 -0
  162. package/build/icons/LoadingIndicatorIcon.js.map +1 -0
  163. package/build/icons/PerformanceIcon.d.ts +4 -0
  164. package/build/icons/PerformanceIcon.d.ts.map +1 -0
  165. package/build/icons/PerformanceIcon.js +7 -0
  166. package/build/icons/PerformanceIcon.js.map +1 -0
  167. package/build/icons/QuestionMarkIcon.d.ts +1 -0
  168. package/build/icons/QuestionMarkIcon.d.ts.map +1 -0
  169. package/build/icons/RefreshIcon.d.ts +1 -0
  170. package/build/icons/RefreshIcon.d.ts.map +1 -0
  171. package/build/icons/RunIcon.d.ts +4 -0
  172. package/build/icons/RunIcon.d.ts.map +1 -0
  173. package/build/icons/RunIcon.js +7 -0
  174. package/build/icons/RunIcon.js.map +1 -0
  175. package/build/icons/SettingsFilledIcon.d.ts +1 -0
  176. package/build/icons/SettingsFilledIcon.d.ts.map +1 -0
  177. package/build/icons/SettingsFilledIcon.js +16 -1
  178. package/build/icons/SettingsFilledIcon.js.map +1 -1
  179. package/build/icons/ShakeDeviceIcon.d.ts +1 -0
  180. package/build/icons/ShakeDeviceIcon.d.ts.map +1 -0
  181. package/build/icons/ShakeDeviceIcon.js +5 -1
  182. package/build/icons/ShakeDeviceIcon.js.map +1 -1
  183. package/build/icons/ShowMenuIcon.d.ts +1 -0
  184. package/build/icons/ShowMenuIcon.d.ts.map +1 -0
  185. package/build/icons/ShowMenuIcon.js +5 -1
  186. package/build/icons/ShowMenuIcon.js.map +1 -1
  187. package/build/icons/TerminalIcon.d.ts +1 -0
  188. package/build/icons/TerminalIcon.d.ts.map +1 -0
  189. package/build/icons/ThreeFingerPressIcon.d.ts +1 -0
  190. package/build/icons/ThreeFingerPressIcon.d.ts.map +1 -0
  191. package/build/icons/ThreeFingerPressIcon.js +5 -1
  192. package/build/icons/ThreeFingerPressIcon.js.map +1 -1
  193. package/build/icons/ToolbarOverlayIcon.d.ts +1 -0
  194. package/build/icons/ToolbarOverlayIcon.d.ts.map +1 -0
  195. package/build/icons/UpdateIcon.d.ts +4 -0
  196. package/build/icons/UpdateIcon.d.ts.map +1 -0
  197. package/build/icons/UpdateIcon.js +11 -0
  198. package/build/icons/UpdateIcon.js.map +1 -0
  199. package/build/icons/UserIcon.d.ts +1 -0
  200. package/build/icons/UserIcon.d.ts.map +1 -0
  201. package/build/icons/UserIcon.js +5 -1
  202. package/build/icons/UserIcon.js.map +1 -1
  203. package/build/icons/WarningIcon.d.ts +4 -0
  204. package/build/icons/WarningIcon.d.ts.map +1 -0
  205. package/build/icons/WarningIcon.js +11 -0
  206. package/build/icons/WarningIcon.js.map +1 -0
  207. package/build/icons/XIcon.d.ts +1 -0
  208. package/build/icons/XIcon.d.ts.map +1 -0
  209. package/build/icons/XIcon.js +5 -1
  210. package/build/icons/XIcon.js.map +1 -1
  211. package/build/icons/index.d.ts +13 -1
  212. package/build/icons/index.d.ts.map +1 -0
  213. package/build/icons/index.js +12 -1
  214. package/build/icons/index.js.map +1 -1
  215. package/build/index.d.ts +1 -0
  216. package/build/index.d.ts.map +1 -0
  217. package/build/theme.d.ts +128 -131
  218. package/build/theme.d.ts.map +1 -0
  219. package/build/theme.js +77 -73
  220. package/build/theme.js.map +1 -1
  221. package/build/useExpoTheme.d.ts +236 -0
  222. package/build/useExpoTheme.d.ts.map +1 -0
  223. package/build/useExpoTheme.js +24 -3
  224. package/build/useExpoTheme.js.map +1 -1
  225. package/package.json +15 -9
  226. package/setupTests.js +35 -0
  227. package/src/Button.tsx +4 -3
  228. package/src/Image.tsx +1 -1
  229. package/src/Text.tsx +35 -21
  230. package/src/View.tsx +115 -44
  231. package/src/create-primitive.tsx +128 -0
  232. package/src/icons/BranchIcon.tsx +14 -0
  233. package/src/icons/CheckIcon.tsx +6 -1
  234. package/src/icons/ClipboardIcon.tsx +9 -0
  235. package/src/icons/DebugIcon.tsx +9 -0
  236. package/src/icons/ExtensionsFilledIcon.tsx +31 -0
  237. package/src/icons/ExtensionsIcon.tsx +14 -0
  238. package/src/icons/HomeFilledIcon.tsx +17 -1
  239. package/src/icons/InfoIcon.tsx +6 -1
  240. package/src/icons/InspectElementIcon.tsx +9 -0
  241. package/src/icons/LoadingIndicatorIcon.tsx +9 -0
  242. package/src/icons/PerformanceIcon.tsx +9 -0
  243. package/src/icons/RunIcon.tsx +9 -0
  244. package/src/icons/SettingsFilledIcon.tsx +17 -1
  245. package/src/icons/ShakeDeviceIcon.tsx +6 -1
  246. package/src/icons/ShowMenuIcon.tsx +6 -1
  247. package/src/icons/ThreeFingerPressIcon.tsx +6 -1
  248. package/src/icons/UpdateIcon.tsx +14 -0
  249. package/src/icons/UserIcon.tsx +6 -1
  250. package/src/icons/WarningIcon.tsx +14 -0
  251. package/src/icons/XIcon.tsx +6 -1
  252. package/src/icons/index.ts +12 -1
  253. package/src/theme.ts +90 -78
  254. package/src/useExpoTheme.tsx +50 -0
  255. package/src/useExpoTheme.ts +0 -14
package/src/View.tsx CHANGED
@@ -1,8 +1,19 @@
1
- import { lightTheme, darkTheme, shadows, iconSize } from '@expo/styleguide-native';
2
- import { View as RNView } from 'react-native';
3
- import { create } from 'react-native-primitives';
1
+ import { lightTheme, darkTheme, shadows } from '@expo/styleguide-native';
2
+ import { View as RNView, StyleSheet } from 'react-native';
4
3
 
5
- import { scale, padding, margin, rounded, bg, bgDark } from './theme';
4
+ import { create } from './create-primitive';
5
+ import {
6
+ scale,
7
+ padding,
8
+ margin,
9
+ rounded,
10
+ bg,
11
+ bgDark,
12
+ width,
13
+ height,
14
+ borderDark,
15
+ border,
16
+ } from './theme';
6
17
 
7
18
  export const View = create(RNView, {
8
19
  variants: {
@@ -17,6 +28,9 @@ export const View = create(RNView, {
17
28
  justifyContent: 'center',
18
29
  alignItems: 'center',
19
30
  },
31
+ start: {
32
+ alignItems: 'flex-start',
33
+ },
20
34
  },
21
35
 
22
36
  flex: {
@@ -29,10 +43,49 @@ export const View = create(RNView, {
29
43
  '0': { flexShrink: 0 },
30
44
  },
31
45
 
46
+ grow: {
47
+ '1': { flexGrow: 1 },
48
+ '0': { flexGrow: 0 },
49
+ },
50
+
32
51
  bg,
33
52
 
53
+ opacity: {
54
+ '1': { opacity: 1 },
55
+ '0.5': { opacity: 0.5 },
56
+ '0.75': { opacity: 0.75 },
57
+ '0': { opacity: 0 },
58
+ },
59
+
60
+ inset: {
61
+ top: {
62
+ position: 'absolute',
63
+ top: 0,
64
+ left: 0,
65
+ right: 0,
66
+ },
67
+
68
+ bottom: {
69
+ position: 'absolute',
70
+ bottom: 0,
71
+ left: 0,
72
+ right: 0,
73
+ },
74
+
75
+ full: {
76
+ position: 'absolute',
77
+ top: 0,
78
+ left: 0,
79
+ right: 0,
80
+ bottom: 0,
81
+ },
82
+ },
83
+
34
84
  border: {
35
85
  default: { borderColor: lightTheme.border.default, borderWidth: 1 },
86
+ hairline: { borderColor: lightTheme.border.default, borderWidth: StyleSheet.hairlineWidth },
87
+ warning: { borderColor: lightTheme.border.warning, borderWidth: 1 },
88
+ error: { borderColor: lightTheme.border.error, borderWidth: 1 },
36
89
  },
37
90
 
38
91
  ...rounded,
@@ -45,23 +98,8 @@ export const View = create(RNView, {
45
98
  button: shadows.button,
46
99
  },
47
100
 
48
- width: {
49
- micro: { width: iconSize.micro },
50
- tiny: { width: iconSize.tiny },
51
- small: { width: iconSize.small },
52
- medium: { width: iconSize.regular },
53
- large: { width: iconSize.large },
54
- xl: { width: scale.xl },
55
- },
56
-
57
- height: {
58
- micro: { height: iconSize.micro },
59
- tiny: { height: iconSize.tiny },
60
- small: { height: iconSize.small },
61
- medium: { height: iconSize.regular },
62
- large: { height: iconSize.large },
63
- xl: { height: scale.xl },
64
- },
101
+ width,
102
+ height,
65
103
 
66
104
  ...padding,
67
105
  ...margin,
@@ -71,9 +109,7 @@ export const View = create(RNView, {
71
109
  dark: {
72
110
  bg: bgDark,
73
111
 
74
- border: {
75
- default: { borderColor: darkTheme.border.default, borderWidth: 1 },
76
- },
112
+ border: borderDark,
77
113
  },
78
114
 
79
115
  light: {
@@ -90,47 +126,79 @@ export const Row = create(RNView, {
90
126
  variants: {
91
127
  bg,
92
128
 
129
+ flex: {
130
+ '1': { flex: 1 },
131
+ '0': { flex: 0 },
132
+ },
133
+
134
+ shrink: {
135
+ '1': { flexShrink: 1 },
136
+ '0': { flexShrink: 0 },
137
+ },
138
+
139
+ grow: {
140
+ '1': { flexGrow: 1 },
141
+ '0': { flexGrow: 0 },
142
+ },
143
+
93
144
  align: {
94
145
  center: { alignItems: 'center' },
95
146
  start: { alignItems: 'flex-start' },
96
147
  end: { alignItems: 'flex-end' },
97
148
  },
98
149
 
150
+ justify: {
151
+ center: { justifyContent: 'center' },
152
+ start: { justifyContent: 'flex-start' },
153
+ end: { justifyContent: 'flex-end' },
154
+ between: { justifyContent: 'space-between' },
155
+ around: { justifyContent: 'space-around' },
156
+ },
157
+
99
158
  ...padding,
100
159
  ...margin,
160
+
161
+ ...rounded,
162
+
163
+ border,
101
164
  },
102
165
 
103
166
  selectors: {
104
167
  dark: {
105
168
  bg: bgDark,
169
+ border: borderDark,
106
170
  },
107
171
  },
108
172
  });
109
173
 
110
174
  const Horizontal = create(RNView, {
175
+ base: {
176
+ flex: 1,
177
+ },
111
178
  variants: {
112
179
  size: {
113
- flex: { flex: 1 },
114
- micro: { width: scale.micro },
115
- tiny: { width: scale.tiny },
116
- small: { width: scale.small },
117
- medium: { width: scale.medium },
118
- large: { width: scale.large },
119
- xl: { width: scale.xl },
180
+ micro: { width: scale.micro, flex: 0 },
181
+ tiny: { width: scale.tiny, flex: 0 },
182
+ small: { width: scale.small, flex: 0 },
183
+ medium: { width: scale.medium, flex: 0 },
184
+ large: { width: scale.large, flex: 0 },
185
+ xl: { width: scale.xl, flex: 0 },
120
186
  },
121
187
  },
122
188
  });
123
189
 
124
190
  const Vertical = create(RNView, {
191
+ base: {
192
+ flex: 1,
193
+ },
125
194
  variants: {
126
195
  size: {
127
- flex: { flex: 1 },
128
- micro: { height: scale.micro },
129
- tiny: { height: scale.tiny },
130
- small: { height: scale.small },
131
- medium: { height: scale.medium },
132
- large: { height: scale.large },
133
- xl: { height: scale.xl },
196
+ micro: { height: scale.micro, flex: 0 },
197
+ tiny: { height: scale.tiny, flex: 0 },
198
+ small: { height: scale.small, flex: 0 },
199
+ medium: { height: scale.medium, flex: 0 },
200
+ large: { height: scale.large, flex: 0 },
201
+ xl: { height: scale.xl, flex: 0 },
134
202
  },
135
203
  },
136
204
  });
@@ -142,15 +210,15 @@ export const Spacer = {
142
210
 
143
211
  export const Divider = create(RNView, {
144
212
  base: {
145
- borderWidth: 0.5,
146
- borderColor: lightTheme.border.default,
213
+ height: StyleSheet.hairlineWidth,
214
+ backgroundColor: lightTheme.border.default,
147
215
  },
148
216
 
149
217
  variants: {
150
218
  weight: {
151
- thin: { borderWidth: 0.5 },
152
- normal: { borderWidth: 1 },
153
- heavy: { borderWidth: 2 },
219
+ thin: { height: StyleSheet.hairlineWidth },
220
+ normal: { height: 1 },
221
+ heavy: { height: 2 },
154
222
  },
155
223
 
156
224
  ...margin,
@@ -158,7 +226,10 @@ export const Divider = create(RNView, {
158
226
 
159
227
  selectors: {
160
228
  dark: {
161
- borderColor: darkTheme.border.default,
229
+ base: {
230
+ height: StyleSheet.hairlineWidth,
231
+ backgroundColor: darkTheme.border.default,
232
+ },
162
233
  },
163
234
  },
164
235
  });
@@ -0,0 +1,128 @@
1
+ import * as React from 'react';
2
+ import { StyleSheet, ViewStyle, ImageStyle, TextStyle } from 'react-native';
3
+
4
+ import { useTheme } from './useExpoTheme';
5
+
6
+ type StyleType = ViewStyle | TextStyle | ImageStyle;
7
+
8
+ type Options = {
9
+ base?: StyleType;
10
+ variants?: VariantMap<StyleType>;
11
+ };
12
+
13
+ type VariantMap<T> = { [key: string]: { [key: string]: T } };
14
+
15
+ type Nested<Type> = {
16
+ [Property in keyof Type]?: keyof Type[Property];
17
+ };
18
+
19
+ type SelectorMap<Variants> = Partial<{
20
+ [K in keyof Variants]?: {
21
+ [T in keyof Variants[K]]?: StyleType;
22
+ };
23
+ }>;
24
+
25
+ type Selectors<Variants> = {
26
+ light?: SelectorMap<Variants>;
27
+ dark?: SelectorMap<Variants>;
28
+ };
29
+
30
+ type SelectorProps = {
31
+ light?: StyleType;
32
+ dark?: StyleType;
33
+ };
34
+
35
+ export function create<T, O extends Options>(
36
+ component: React.ComponentType<T>,
37
+ config: O & { selectors?: Selectors<O['variants']>; props?: T }
38
+ ) {
39
+ config.selectors = config.selectors ?? {};
40
+ config.variants = config.variants ?? {};
41
+
42
+ const Component = React.forwardRef<
43
+ T,
44
+ React.PropsWithChildren<T> & Nested<typeof config['variants']> & { selectors?: SelectorProps }
45
+ >((props, ref) => {
46
+ const theme = useTheme();
47
+
48
+ const variantStyles = stylesForVariants(props, config.variants);
49
+ const selectorStyles = stylesForSelectors(props, config.selectors, { theme });
50
+ const selectorPropsStyles = stylesForSelectorProps(props.selectors, { theme });
51
+
52
+ const variantFreeProps: any = { ...props };
53
+
54
+ // @ts-ignore
55
+ // there could be a conflict between the primitive prop and the variant name
56
+ // for example - variant name "width" and prop "width"
57
+ // in these cases, favor the variant because it is under the users control (e.g they can update the conflicting name)
58
+
59
+ Object.keys(config.variants).forEach((variant) => {
60
+ delete variantFreeProps[variant];
61
+ });
62
+
63
+ return React.createElement(component, {
64
+ ...config.props,
65
+ ...variantFreeProps,
66
+ style: StyleSheet.flatten([
67
+ config.base,
68
+ variantStyles,
69
+ selectorStyles,
70
+ selectorPropsStyles,
71
+ // @ts-ignore
72
+ props.style || {},
73
+ ]),
74
+ ref,
75
+ });
76
+ });
77
+
78
+ return Component;
79
+ }
80
+
81
+ function stylesForVariants(props: any, variants: any = {}) {
82
+ let styles = {};
83
+
84
+ for (const key in props) {
85
+ if (variants[key]) {
86
+ const value = props[key];
87
+
88
+ const styleValue = variants[key][value];
89
+ if (styleValue) {
90
+ styles = StyleSheet.flatten(StyleSheet.compose(styles, styleValue));
91
+ }
92
+ }
93
+ }
94
+
95
+ return styles;
96
+ }
97
+
98
+ function stylesForSelectors(props: any, selectors: any = {}, state: any = {}) {
99
+ const styles: any[] = [];
100
+
101
+ if (state.theme != null) {
102
+ if (selectors[state.theme] != null) {
103
+ const variants = selectors[state.theme];
104
+ const variantStyles = stylesForVariants(props, variants);
105
+
106
+ if (variants.base != null) {
107
+ styles.push(variants.base);
108
+ }
109
+
110
+ styles.push(variantStyles);
111
+ }
112
+ }
113
+
114
+ return StyleSheet.flatten(styles);
115
+ }
116
+
117
+ function stylesForSelectorProps(selectors: any = {}, state: any = {}) {
118
+ const styles: any[] = [];
119
+
120
+ if (state.theme != null) {
121
+ if (selectors[state.theme] != null) {
122
+ const selectorStyles = selectors[state.theme];
123
+ styles.push(selectorStyles);
124
+ }
125
+ }
126
+
127
+ return StyleSheet.flatten(styles);
128
+ }
@@ -0,0 +1,14 @@
1
+ import * as React from 'react';
2
+
3
+ import { Image } from '../Image';
4
+ import { useCurrentTheme } from '../useExpoTheme';
5
+
6
+ const lightIcon = require('../../assets/branch-icon-light.png');
7
+ const icon = require('../../assets/branch-icon.png');
8
+
9
+ export function BranchIcon(props: Partial<React.ComponentProps<typeof Image>>) {
10
+ const theme = useCurrentTheme();
11
+ const themedIcon = theme === 'dark' ? lightIcon : icon;
12
+
13
+ return <Image source={themedIcon} {...props} />;
14
+ }
@@ -1,9 +1,14 @@
1
1
  import * as React from 'react';
2
2
 
3
3
  import { Image } from '../Image';
4
+ import { useCurrentTheme } from '../useExpoTheme';
4
5
 
6
+ const lightIcon = require('../../assets/check-icon-light.png');
5
7
  const icon = require('../../assets/check-icon.png');
6
8
 
7
9
  export function CheckIcon(props: Partial<React.ComponentProps<typeof Image>>) {
8
- return <Image source={icon} {...props} />;
10
+ const theme = useCurrentTheme();
11
+ const themedIcon = theme === 'dark' ? lightIcon : icon;
12
+
13
+ return <Image source={themedIcon} {...props} />;
9
14
  }
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+
3
+ import { Image } from '../Image';
4
+
5
+ const icon = require('../../assets/clipboard-icon.png');
6
+
7
+ export function ClipboardIcon(props: Partial<React.ComponentProps<typeof Image>>) {
8
+ return <Image source={icon} {...props} />;
9
+ }
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+
3
+ import { Image } from '../Image';
4
+
5
+ const icon = require('../../assets/debug-icon.png');
6
+
7
+ export function DebugIcon(props: Partial<React.ComponentProps<typeof Image>>) {
8
+ return <Image source={icon} {...props} />;
9
+ }
@@ -0,0 +1,31 @@
1
+ import * as React from 'react';
2
+
3
+ import { Image } from '../Image';
4
+ import { useCurrentTheme } from '../useExpoTheme';
5
+
6
+ const activeLightIcon = require('../../assets/extensions-filled-active-icon-light.png');
7
+ const activeIcon = require('../../assets/extensions-filled-active-icon.png');
8
+ const inactiveLightIcon = require('../../assets/extensions-filled-inactive-icon-light.png');
9
+ const inactiveIcon = require('../../assets/extensions-filled-inactive-icon.png');
10
+
11
+ const iconMap = {
12
+ light: {
13
+ active: activeIcon,
14
+ inactive: inactiveIcon,
15
+ },
16
+ dark: {
17
+ active: activeLightIcon,
18
+ inactive: inactiveLightIcon,
19
+ },
20
+ };
21
+
22
+ type TabBarIconProps = Partial<React.ComponentProps<typeof Image>> & {
23
+ focused?: boolean;
24
+ };
25
+
26
+ export function ExtensionsFilledIcon(props: TabBarIconProps) {
27
+ const theme = useCurrentTheme();
28
+ const themedIcon = iconMap[theme];
29
+ const icon = props.focused ? themedIcon.active : themedIcon.inactive;
30
+ return <Image source={icon} {...props} />;
31
+ }
@@ -0,0 +1,14 @@
1
+ import * as React from 'react';
2
+
3
+ import { Image } from '../Image';
4
+ import { useCurrentTheme } from '../useExpoTheme';
5
+
6
+ const lightIcon = require('../../assets/extensions-icon-light.png');
7
+ const icon = require('../../assets/extensions-icon.png');
8
+
9
+ export function ExtensionsIcon(props: Partial<React.ComponentProps<typeof Image>>) {
10
+ const theme = useCurrentTheme();
11
+ const themedIcon = theme === 'dark' ? lightIcon : icon;
12
+
13
+ return <Image source={themedIcon} {...props} />;
14
+ }
@@ -1,15 +1,31 @@
1
1
  import * as React from 'react';
2
2
 
3
3
  import { Image } from '../Image';
4
+ import { useCurrentTheme } from '../useExpoTheme';
4
5
 
6
+ const activeLightIcon = require('../../assets/home-filled-active-icon-light.png');
5
7
  const activeIcon = require('../../assets/home-filled-active-icon.png');
8
+ const inactiveLightIcon = require('../../assets/home-filled-inactive-icon-light.png');
6
9
  const inactiveIcon = require('../../assets/home-filled-inactive-icon.png');
7
10
 
11
+ const iconMap = {
12
+ light: {
13
+ active: activeIcon,
14
+ inactive: inactiveIcon,
15
+ },
16
+ dark: {
17
+ active: activeLightIcon,
18
+ inactive: inactiveLightIcon,
19
+ },
20
+ };
21
+
8
22
  type TabBarIconProps = Partial<React.ComponentProps<typeof Image>> & {
9
23
  focused?: boolean;
10
24
  };
11
25
 
12
26
  export function HomeFilledIcon(props: TabBarIconProps) {
13
- const icon = props.focused ? activeIcon : inactiveIcon;
27
+ const theme = useCurrentTheme();
28
+ const themedIcon = iconMap[theme];
29
+ const icon = props.focused ? themedIcon.active : themedIcon.inactive;
14
30
  return <Image source={icon} {...props} />;
15
31
  }
@@ -1,9 +1,14 @@
1
1
  import * as React from 'react';
2
2
 
3
3
  import { Image } from '../Image';
4
+ import { useCurrentTheme } from '../useExpoTheme';
4
5
 
6
+ const lightIcon = require('../../assets/info-icon-light.png');
5
7
  const icon = require('../../assets/info-icon.png');
6
8
 
7
9
  export function InfoIcon(props: Partial<React.ComponentProps<typeof Image>>) {
8
- return <Image source={icon} {...props} />;
10
+ const theme = useCurrentTheme();
11
+ const themedIcon = theme === 'dark' ? lightIcon : icon;
12
+
13
+ return <Image source={themedIcon} {...props} />;
9
14
  }
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+
3
+ import { Image } from '../Image';
4
+
5
+ const icon = require('../../assets/inspect-element-icon.png');
6
+
7
+ export function InspectElementIcon(props: Partial<React.ComponentProps<typeof Image>>) {
8
+ return <Image source={icon} {...props} />;
9
+ }
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+
3
+ import { Image } from '../Image';
4
+
5
+ const icon = require('../../assets/loading-indicator-icon.png');
6
+
7
+ export function LoadingIndicatorIcon(props: Partial<React.ComponentProps<typeof Image>>) {
8
+ return <Image source={icon} {...props} />;
9
+ }
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+
3
+ import { Image } from '../Image';
4
+
5
+ const icon = require('../../assets/performance-icon.png');
6
+
7
+ export function PerformanceIcon(props: Partial<React.ComponentProps<typeof Image>>) {
8
+ return <Image source={icon} {...props} />;
9
+ }
@@ -0,0 +1,9 @@
1
+ import * as React from 'react';
2
+
3
+ import { Image } from '../Image';
4
+
5
+ const icon = require('../../assets/run-icon.png');
6
+
7
+ export function RunIcon(props: Partial<React.ComponentProps<typeof Image>>) {
8
+ return <Image source={icon} {...props} />;
9
+ }
@@ -1,15 +1,31 @@
1
1
  import * as React from 'react';
2
2
 
3
3
  import { Image } from '../Image';
4
+ import { useCurrentTheme } from '../useExpoTheme';
4
5
 
6
+ const activeLightIcon = require('../../assets/settings-filled-active-icon-light.png');
5
7
  const activeIcon = require('../../assets/settings-filled-active-icon.png');
8
+ const inactiveLightIcon = require('../../assets/settings-filled-inactive-icon-light.png');
6
9
  const inactiveIcon = require('../../assets/settings-filled-inactive-icon.png');
7
10
 
11
+ const iconMap = {
12
+ light: {
13
+ active: activeIcon,
14
+ inactive: inactiveIcon,
15
+ },
16
+ dark: {
17
+ active: activeLightIcon,
18
+ inactive: inactiveLightIcon,
19
+ },
20
+ };
21
+
8
22
  type TabBarIconProps = Partial<React.ComponentProps<typeof Image>> & {
9
23
  focused?: boolean;
10
24
  };
11
25
 
12
26
  export function SettingsFilledIcon(props: TabBarIconProps) {
13
- const icon = props.focused ? activeIcon : inactiveIcon;
27
+ const theme = useCurrentTheme();
28
+ const themedIcon = iconMap[theme];
29
+ const icon = props.focused ? themedIcon.active : themedIcon.inactive;
14
30
  return <Image source={icon} {...props} />;
15
31
  }
@@ -1,9 +1,14 @@
1
1
  import * as React from 'react';
2
2
 
3
3
  import { Image } from '../Image';
4
+ import { useCurrentTheme } from '../useExpoTheme';
4
5
 
6
+ const lightIcon = require('../../assets/shake-device-icon-light.png');
5
7
  const icon = require('../../assets/shake-device-icon.png');
6
8
 
7
9
  export function ShakeDeviceIcon(props: Partial<React.ComponentProps<typeof Image>>) {
8
- return <Image {...props} source={icon} />;
10
+ const theme = useCurrentTheme();
11
+ const themedIcon = theme === 'dark' ? lightIcon : icon;
12
+
13
+ return <Image source={themedIcon} {...props} />;
9
14
  }
@@ -1,9 +1,14 @@
1
1
  import * as React from 'react';
2
2
 
3
3
  import { Image } from '../Image';
4
+ import { useCurrentTheme } from '../useExpoTheme';
4
5
 
6
+ const lightIcon = require('../../assets/show-menu-at-launch-icon-light.png');
5
7
  const icon = require('../../assets/show-menu-at-launch-icon.png');
6
8
 
7
9
  export function ShowMenuIcon(props: Partial<React.ComponentProps<typeof Image>>) {
8
- return <Image source={icon} {...props} />;
10
+ const theme = useCurrentTheme();
11
+ const themedIcon = theme === 'dark' ? lightIcon : icon;
12
+
13
+ return <Image source={themedIcon} {...props} />;
9
14
  }
@@ -1,9 +1,14 @@
1
1
  import * as React from 'react';
2
2
 
3
3
  import { Image } from '../Image';
4
+ import { useCurrentTheme } from '../useExpoTheme';
4
5
 
6
+ const lightIcon = require('../../assets/three-finger-long-press-icon-light.png');
5
7
  const icon = require('../../assets/three-finger-long-press-icon.png');
6
8
 
7
9
  export function ThreeFingerPressIcon(props: Partial<React.ComponentProps<typeof Image>>) {
8
- return <Image source={icon} {...props} />;
10
+ const theme = useCurrentTheme();
11
+ const themedIcon = theme === 'dark' ? lightIcon : icon;
12
+
13
+ return <Image source={themedIcon} {...props} />;
9
14
  }
@@ -0,0 +1,14 @@
1
+ import * as React from 'react';
2
+
3
+ import { Image } from '../Image';
4
+ import { useCurrentTheme } from '../useExpoTheme';
5
+
6
+ const lightIcon = require('../../assets/update-icon-light.png');
7
+ const icon = require('../../assets/update-icon.png');
8
+
9
+ export function UpdateIcon(props: Partial<React.ComponentProps<typeof Image>>) {
10
+ const theme = useCurrentTheme();
11
+ const themedIcon = theme === 'dark' ? lightIcon : icon;
12
+
13
+ return <Image source={themedIcon} {...props} />;
14
+ }
@@ -1,9 +1,14 @@
1
1
  import * as React from 'react';
2
2
 
3
3
  import { Image } from '../Image';
4
+ import { useCurrentTheme } from '../useExpoTheme';
4
5
 
6
+ const lightIcon = require('../../assets/user-icon-light.png');
5
7
  const icon = require('../../assets/user-icon.png');
6
8
 
7
9
  export function UserIcon(props: Partial<React.ComponentProps<typeof Image>>) {
8
- return <Image source={icon} {...props} />;
10
+ const theme = useCurrentTheme();
11
+ const themedIcon = theme === 'dark' ? lightIcon : icon;
12
+
13
+ return <Image source={themedIcon} {...props} />;
9
14
  }