@butternutbox/pawprint-native 0.23.2 → 0.23.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@butternutbox/pawprint-native",
3
- "version": "0.23.2",
3
+ "version": "0.23.3",
4
4
  "type": "module",
5
5
  "description": "ButternutBox Pawprint Design System - React Native Components",
6
6
  "main": "./dist/index.cjs",
@@ -83,18 +83,6 @@ const StyledButton = styled(Pressable)<{
83
83
  })
84
84
  )
85
85
 
86
- const StyledTextWrapper = styled(View)<{
87
- textOpacity: number
88
- fullWidth?: boolean
89
- }>(({ textOpacity, fullWidth }) => ({
90
- opacity: textOpacity,
91
- // `flexShrink` (not `flex: 1`) so the text wrapper can shrink to let long /
92
- // translated copy wrap under the button's `minHeight`, WITHOUT growing to
93
- // fill the row on short copy — which would push a `startIcon`/`endIcon` out
94
- // to the button edge instead of sitting next to the centred text.
95
- ...(fullWidth ? { flexShrink: 1 } : {})
96
- }))
97
-
98
86
  const StyledSpinnerWrapper = styled(View)({
99
87
  position: "absolute",
100
88
  alignItems: "center",
@@ -233,21 +221,26 @@ const Button = React.forwardRef<View, ButtonProps>(
233
221
  {...rest}
234
222
  >
235
223
  {startIcon && <IconWrapper>{startIcon}</IconWrapper>}
236
- <StyledTextWrapper textOpacity={loading ? 0 : 1} fullWidth={fullWidth}>
237
- <Typography
238
- token={{
239
- fontFamily: typography.fontFamily,
240
- fontWeight: typography.fontWeight,
241
- fontSize: typography.fontSize,
242
- lineHeight: typography.lineHeight,
243
- letterSpacing: typography.letterSpacing
244
- }}
245
- color={variantStyles.textColor as never}
246
- align="center"
247
- >
248
- {children}
249
- </Typography>
250
- </StyledTextWrapper>
224
+ {/* `Typography` is a DIRECT child of the button row (no wrapping View)
225
+ so its `<Text>` participates in flex shrink and wraps long /
226
+ translated labels to multiple lines under the button's `minHeight`.
227
+ A `<Text>` nested inside an intermediate flex `<View>` does not
228
+ re-wrap once the wrapper resolves its width. Loading hides the label
229
+ via a transparent colour (keeping its footprint) while the spinner
230
+ overlays it. */}
231
+ <Typography
232
+ token={{
233
+ fontFamily: typography.fontFamily,
234
+ fontWeight: typography.fontWeight,
235
+ fontSize: typography.fontSize,
236
+ lineHeight: typography.lineHeight,
237
+ letterSpacing: typography.letterSpacing
238
+ }}
239
+ color={(loading ? "transparent" : variantStyles.textColor) as never}
240
+ align="center"
241
+ >
242
+ {children}
243
+ </Typography>
251
244
  {endIcon && <IconWrapper>{endIcon}</IconWrapper>}
252
245
  {loading && (
253
246
  <StyledSpinnerWrapper>
@@ -66,6 +66,12 @@ const StyledTag = styled(View)<{
66
66
  }
67
67
  })
68
68
 
69
+ // Lets the label shrink so a long tag wraps within its container instead of
70
+ // growing past it (e.g. long translated copy overflowing a card's padding).
71
+ const StyledLabel = styled(View)({
72
+ flexShrink: 1
73
+ })
74
+
69
75
  /**
70
76
  * Tag component for labelling and categorising content.
71
77
  *
@@ -118,12 +124,14 @@ export const Tag = React.forwardRef<View, TagProps>(
118
124
  colour={iconColourMap[variant]}
119
125
  />
120
126
  )}
121
- <Typography
122
- token={typography[size].default}
123
- color={textColorMap[variant]}
124
- >
125
- {children}
126
- </Typography>
127
+ <StyledLabel>
128
+ <Typography
129
+ token={typography[size].default}
130
+ color={textColorMap[variant]}
131
+ >
132
+ {children}
133
+ </Typography>
134
+ </StyledLabel>
127
135
  </StyledTag>
128
136
  )
129
137
  }
@@ -217,6 +217,12 @@ export const Typography = React.forwardRef<Text, TypographyProps>(
217
217
  } = props
218
218
 
219
219
  const style: TextStyle = {
220
+ // Token-mode text is component-owned and lives inside flex rows
221
+ // (buttons, tabs, tags). `flexShrink` lets it wrap to multiple lines
222
+ // when the row is narrower than the text, instead of laying out on one
223
+ // line and overflowing/clipping — a `<Text>` nested in a flex `<View>`
224
+ // won't re-wrap on its own after the parent's width is resolved.
225
+ flexShrink: 1,
220
226
  ...nativeTokenToStyle(token),
221
227
  ...(color ? { color } : {}),
222
228
  ...getCommonStyles(align, textTransform, textDecoration)
@@ -114,7 +114,11 @@ const StyledTab = styled(Pressable)<{
114
114
  alignItems: "center",
115
115
  justifyContent: "center",
116
116
  gap: tabGap,
117
- height: tabHeight,
117
+ // `minHeight` (not a fixed `height`) so a tab whose label wraps to more
118
+ // than one line — e.g. long translated copy in `fixed` layout — grows to
119
+ // fit instead of clipping/overflowing. The list's `alignItems: "stretch"`
120
+ // then matches every tab to the tallest, keeping labels vertically aligned.
121
+ minHeight: tabHeight,
118
122
  minWidth: tabMinWidth,
119
123
  paddingTop: tabPaddingTop,
120
124
  paddingBottom: tabPaddingBottom,
@@ -223,7 +227,7 @@ const TabNavigationTab = React.forwardRef<View, TabNavigationTabProps>(
223
227
  {icon && (
224
228
  <Icon icon={icon} customColour={textColour as string} aria-hidden />
225
229
  )}
226
- <Typography token={token} color={textColour}>
230
+ <Typography token={token} color={textColour} align="center">
227
231
  {children}
228
232
  </Typography>
229
233
  </StyledTab>