Skip to content

Commit

Permalink
Merge branch 'hailey/dialogs-pt7-rework' into hailey/dialogs-pt8
Browse files Browse the repository at this point in the history
  • Loading branch information
haileyok committed Oct 2, 2024
2 parents 1ca6d36 + 431f1ff commit fee2468
Show file tree
Hide file tree
Showing 11 changed files with 388 additions and 373 deletions.
110 changes: 6 additions & 104 deletions src/components/BottomSheetButton.tsx
Original file line number Diff line number Diff line change
@@ -1,110 +1,12 @@
import React from 'react'
import {AccessibilityProps, ViewStyle} from 'react-native'
import {PressableEvent} from 'react-native-gesture-handler/lib/typescript/components/Pressable/PressableProps'
import {
BlueskyBottomSheetPressable,
BlueskyBottomSheetPressableProps,
} from '@haileyok/bluesky-bottom-sheet'

import {atoms as a} from '#/alf'
import {
ButtonContext,
useSharedButtonStyles,
VariantProps,
} from '#/components/Button'

export function BottomSheetButton({
children,
label,
color,
variant,
shape = 'default',
size,
disabled,
style,
...rest
}: BlueskyBottomSheetPressableProps &
AccessibilityProps &
VariantProps & {
/**
* For a11y, try to make this descriptive and clear
*/
label: string
}) {
const [state, setState] = React.useState({
pressed: false,
hovered: false,
focused: false,
})

const onPressInOuter = rest.onPressIn
const onPressIn = React.useCallback(
(e: PressableEvent) => {
setState(s => ({
...s,
pressed: true,
}))
onPressInOuter?.(e)
},
[setState, onPressInOuter],
)
const onPressOutOuter = rest.onPressOut
const onPressOut = React.useCallback(
(e: PressableEvent) => {
setState(s => ({
...s,
pressed: false,
}))
onPressOutOuter?.(e)
},
[setState, onPressOutOuter],
)

const {baseStyles, hoverStyles} = useSharedButtonStyles({
/**
* For a11y, try to make this descriptive and clear
*/
color,
variant,
shape,
size,
disabled,
})

const context = React.useMemo<ButtonContext>(
() => ({
...state,
variant,
color,
size,
disabled: disabled || false,
}),
[state, variant, color, size, disabled],
)
import {Button, ButtonProps} from '#/components/Button'
import {NormalizedRNGHPressable} from '#/components/NormalizedRNGHPressable'

export function BottomSheetButton({children, ...rest}: ButtonProps) {
return (
<BlueskyBottomSheetPressable
style={[
a.flex_row,
a.align_center,
a.justify_center,
baseStyles,
style as ViewStyle,
...(state.hovered || state.pressed ? [hoverStyles] : []),
]}
aria-label={label}
aria-pressed={state.pressed}
accessibilityLabel={label}
accessibilityHint={undefined}
accessibilityState={{
disabled: disabled || false,
}}
onPressIn={onPressIn}
onPressOut={onPressOut}
{...rest}>
<ButtonContext.Provider value={context}>
{typeof children === 'function' ? children(context) : children}
</ButtonContext.Provider>
</BlueskyBottomSheetPressable>
<Button {...rest} Component={NormalizedRNGHPressable}>
{children}
</Button>
)
}
6 changes: 3 additions & 3 deletions src/components/BottomSheetLink.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import React from 'react'
import {BlueskyBottomSheetPressable} from '@haileyok/bluesky-bottom-sheet'
import {StackActions, useNavigation} from '@react-navigation/native'

import {NavigationProp} from '#/lib/routes/types'
import {flatten, useTheme} from '#/alf'
import {useDialogContext} from '#/components/Dialog'
import {useInteractionState} from '#/components/hooks/useInteractionState'
import {InlineLinkProps, useLink} from '#/components/Link'
import {NormalizedRNGHPressable} from '#/components/NormalizedRNGHPressable'
import {Text} from '#/components/Typography'
import {router} from '#/routes'

Expand Down Expand Up @@ -64,7 +64,7 @@ export function BottomSheetInlineLinkText({

// eslint-disable-next-line bsky-internal/avoid-unwrapped-text
return (
<BlueskyBottomSheetPressable
<NormalizedRNGHPressable
onPress={onPress}
onLongPress={onLongPress}
onPressIn={onPressIn}
Expand All @@ -87,6 +87,6 @@ export function BottomSheetInlineLinkText({
]}>
{children}
</Text>
</BlueskyBottomSheetPressable>
</NormalizedRNGHPressable>
)
}
Loading

0 comments on commit fee2468

Please sign in to comment.