@tamagui/button 1.72.3 → 1.73.1

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.
package/src/Button.tsx CHANGED
@@ -28,7 +28,19 @@ export const ButtonContext = createStyledContext<
28
28
  size: SizeTokens
29
29
  }
30
30
  >
31
- >({})
31
+ >({
32
+ // keeping these here means they work with styled() passing down color to text
33
+ color: undefined,
34
+ ellipse: undefined,
35
+ fontFamily: undefined,
36
+ fontSize: undefined,
37
+ fontStyle: undefined,
38
+ fontWeight: undefined,
39
+ letterSpacing: undefined,
40
+ maxFontSizeMultiplier: undefined,
41
+ size: undefined,
42
+ textAlign: undefined,
43
+ })
32
44
 
33
45
  type ButtonIconProps = { color?: string; size?: number }
34
46
  type IconProp = JSX.Element | FunctionComponent<ButtonIconProps> | null
@@ -207,34 +219,26 @@ function useButton<Props extends ButtonProps>(
207
219
  propsIn: Props,
208
220
  { Text = Button.Text }: { Text: any } = { Text: Button.Text }
209
221
  ) {
222
+ const isNested = useContext(ButtonNestingContext)
223
+
224
+ const propsActive = useProps(propsIn) as any as ButtonProps
225
+
210
226
  // careful not to desctructure and re-order props, order is important
211
227
  const {
212
228
  children,
213
229
  icon,
214
230
  iconAfter,
215
- noTextWrap,
216
- theme: themeName,
217
231
  space,
218
232
  spaceFlex,
219
233
  scaleIcon = 1,
220
234
  scaleSpace = 0.66,
221
235
  separator,
222
-
223
- // text props
224
- color,
225
- fontWeight,
226
- letterSpacing,
227
- fontSize,
236
+ noTextWrap,
228
237
  fontFamily,
229
- fontStyle,
230
- textAlign,
231
- textProps,
238
+ fontSize,
232
239
 
233
240
  ...rest
234
- } = propsIn
235
-
236
- const isNested = useContext(ButtonNestingContext)
237
- const propsActive = useProps(propsIn) as any as ButtonProps
241
+ } = propsActive
238
242
 
239
243
  const size = propsActive.size || (propsActive.unstyled ? undefined : '$true')
240
244
 
@@ -242,19 +246,24 @@ function useButton<Props extends ButtonProps>(
242
246
  (typeof size === 'number' ? size * 0.5 : getFontSize(size as FontSizeTokens)) *
243
247
  scaleIcon
244
248
 
245
- const getThemedIcon = useGetThemedIcon({ size: iconSize, color: color as any })
249
+ const getThemedIcon = useGetThemedIcon({
250
+ size: iconSize,
251
+ color: propsActive.color as any,
252
+ })
246
253
  const [themedIcon, themedIconAfter] = [icon, iconAfter].map(getThemedIcon)
247
254
  const spaceSize = propsActive.space ?? getVariableValue(iconSize) * scaleSpace
248
- const contents = wrapChildrenInText(
249
- Text,
250
- propsActive,
251
- Text === ButtonText && propsIn.unstyled !== true
252
- ? {
253
- unstyled: false,
254
- size,
255
- }
256
- : undefined
257
- )
255
+ const contents = noTextWrap
256
+ ? [children]
257
+ : wrapChildrenInText(
258
+ Text,
259
+ { children, fontFamily, fontSize },
260
+ Text === ButtonText && propsIn.unstyled !== true
261
+ ? {
262
+ unstyled: false,
263
+ size,
264
+ }
265
+ : undefined
266
+ )
258
267
 
259
268
  const inner = spacedChildren({
260
269
  // a bit arbitrary but scaling to font size is necessary so long as button does
@@ -279,6 +288,7 @@ function useButton<Props extends ButtonProps>(
279
288
  : undefined
280
289
 
281
290
  const props = {
291
+ size,
282
292
  ...(propsActive.disabled && {
283
293
  // in rnw - false still has keyboard tabIndex, undefined = not actually focusable
284
294
  focusable: undefined,
@@ -294,6 +304,8 @@ function useButton<Props extends ButtonProps>(
294
304
  children: (
295
305
  <ButtonNestingContext.Provider value={true}>{inner}</ButtonNestingContext.Provider>
296
306
  ),
307
+ // forces it to be a runtime pressStyle so it passes through context text colors
308
+ disableClassName: true,
297
309
  } as Props
298
310
 
299
311
  return {