Merge remote-tracking branch 'origin/main' into starter-packs

* origin/main:
  Convert button to use forwardRef (#4576)
  use 1000x1000 for image height in avatar cropper (#4453)
  fix for autofill covering border (#4573)
This commit is contained in:
Eric Bailey
2024-06-19 18:48:48 -05:00
4 changed files with 354 additions and 328 deletions
+25 -6
View File
@@ -88,7 +88,9 @@ export function useButtonContext() {
return React.useContext(Context) return React.useContext(Context)
} }
export function Button({ export const Button = React.forwardRef<View, ButtonProps>(
(
{
children, children,
variant, variant,
color, color,
@@ -99,7 +101,9 @@ export function Button({
style, style,
hoverStyle: hoverStyleProp, hoverStyle: hoverStyleProp,
...rest ...rest
}: ButtonProps) { },
ref,
) => {
const t = useTheme() const t = useTheme()
const [state, setState] = React.useState({ const [state, setState] = React.useState({
pressed: false, pressed: false,
@@ -179,7 +183,9 @@ export function Button({
}) })
} else { } else {
baseStyles.push(a.border, { baseStyles.push(a.border, {
borderColor: light ? t.palette.primary_200 : t.palette.primary_900, borderColor: light
? t.palette.primary_200
: t.palette.primary_900,
}) })
} }
} else if (variant === 'ghost') { } else if (variant === 'ghost') {
@@ -278,9 +284,19 @@ export function Button({
if (shape === 'default') { if (shape === 'default') {
if (size === 'large') { if (size === 'large') {
baseStyles.push({paddingVertical: 15}, a.px_2xl, a.rounded_sm, a.gap_md) baseStyles.push(
{paddingVertical: 15},
a.px_2xl,
a.rounded_sm,
a.gap_md,
)
} else if (size === 'medium') { } else if (size === 'medium') {
baseStyles.push({paddingVertical: 12}, a.px_2xl, a.rounded_sm, a.gap_md) baseStyles.push(
{paddingVertical: 12},
a.px_2xl,
a.rounded_sm,
a.gap_md,
)
} else if (size === 'small') { } else if (size === 'small') {
baseStyles.push({paddingVertical: 9}, a.px_lg, a.rounded_sm, a.gap_sm) baseStyles.push({paddingVertical: 9}, a.px_lg, a.rounded_sm, a.gap_sm)
} else if (size === 'xsmall') { } else if (size === 'xsmall') {
@@ -368,6 +384,7 @@ export function Button({
role="button" role="button"
accessibilityHint={undefined} // optional accessibilityHint={undefined} // optional
{...rest} {...rest}
ref={ref}
aria-label={label} aria-label={label}
aria-pressed={state.pressed} aria-pressed={state.pressed}
accessibilityLabel={label} accessibilityLabel={label}
@@ -417,7 +434,9 @@ export function Button({
</Context.Provider> </Context.Provider>
</Pressable> </Pressable>
) )
} },
)
Button.displayName = 'Button'
export function useSharedButtonTextStyles() { export function useSharedButtonTextStyles() {
const t = useTheme() const t = useTheme()
+7
View File
@@ -197,6 +197,13 @@ export function createInput(Component: typeof TextInput) {
textAlignVertical: rest.multiline ? 'top' : undefined, textAlignVertical: rest.multiline ? 'top' : undefined,
minHeight: rest.multiline ? 80 : undefined, minHeight: rest.multiline ? 80 : undefined,
}, },
// fix for autofill styles covering border
web({
paddingTop: 12,
paddingBottom: 12,
marginTop: 2,
marginBottom: 2,
}),
android({ android({
paddingBottom: 16, paddingBottom: 16,
}), }),
+2 -2
View File
@@ -181,8 +181,8 @@ export function StepProfile() {
image = await openCropper({ image = await openCropper({
mediaType: 'photo', mediaType: 'photo',
cropperCircleOverlay: true, cropperCircleOverlay: true,
height: image.height, height: 1000,
width: image.width, width: 1000,
path: image.path, path: image.path,
}) })
} }
+2 -2
View File
@@ -303,8 +303,8 @@ let EditableUserAvatar = ({
const croppedImage = await openCropper({ const croppedImage = await openCropper({
mediaType: 'photo', mediaType: 'photo',
cropperCircleOverlay: true, cropperCircleOverlay: true,
height: item.height, height: 1000,
width: item.width, width: 1000,
path: item.path, path: item.path,
}) })