Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@observation.org/react-native-components",
"version": "1.92.0",
"version": "1.93.0",
"main": "src/index.ts",
"exports": {
".": "./src/index.ts",
Expand Down
23 changes: 11 additions & 12 deletions src/components/BottomSheetWithSearchInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { useTheme as useNavigationTheme } from '@react-navigation/native'
import { Easing } from 'react-native-reanimated'
import { useSafeAreaInsets } from 'react-native-safe-area-context'

import { Icon } from './Icon'
import IconButton from './IconButton'
import ItemSeparator from './ItemSeparator'
import ListItem from './ListItem'
import useBottomSheetBackHandler from '../hooks/useBottomSheetBackHandler'
Expand Down Expand Up @@ -121,19 +121,18 @@ const BottomSheetWithSearchInput = ({
onChangeText: onChange,
}}
rightIcon={
<TouchableOpacity
style={styles.iconButtonContainer}
<IconButton
Touchable={TouchableOpacity}
containerStyle={styles.iconButtonContainer}
onPress={onClear}
testID="clearButton"
activeOpacity={0.5}
>
<Icon
name="circle-xmark"
style="solid"
color={theme.color.icon.system.subtler}
size={theme.icon.size.s}
/>
</TouchableOpacity>
icon={{
name: 'circle-xmark',
style: 'solid',
color: theme.color.icon.system.subtler,
size: theme.icon.size.s,
}}
/>
}
/>
<SectionHeader title={sectionTitle} />
Expand Down
19 changes: 14 additions & 5 deletions src/components/IconButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { StyleProp, TouchableOpacity, ViewStyle } from 'react-native'
import React, { ComponentType } from 'react'
import { StyleProp, TouchableOpacity, TouchableOpacityProps, ViewStyle } from 'react-native'

import { Icon, IconProps } from './Icon'
import { useTheme } from '../theme/ThemeProvider'
Expand All @@ -11,12 +11,21 @@ type Props = {
icon: IconProps
accessibilityLabel?: string
testID?: string
Touchable?: ComponentType<TouchableOpacityProps>
}

const IconButton = ({ containerStyle, disabled, onPress, icon, accessibilityLabel, testID = 'pressable' }: Props) => {
const IconButton = ({
containerStyle,
disabled,
onPress,
icon,
accessibilityLabel,
testID = 'pressable',
Touchable = TouchableOpacity,
}: Props) => {
const theme = useTheme()
return (
<TouchableOpacity
<Touchable
testID={testID}
accessibilityLabel={accessibilityLabel}
style={containerStyle}
Expand All @@ -25,7 +34,7 @@ const IconButton = ({ containerStyle, disabled, onPress, icon, accessibilityLabe
activeOpacity={0.5}
>
<Icon size={theme.icon.size.l} {...icon} />
</TouchableOpacity>
</Touchable>
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,24 @@ exports[`BottomSheetWithSearchInput Rendering Initial state 1`] = `
}
}
rightIcon={
<TouchableOpacity
activeOpacity={0.5}
onPress={[Function]}
style={
<IconButton
Touchable={[Function]}
containerStyle={
{
"paddingRight": 16,
}
}
icon={
{
"color": "#939393",
"name": "circle-xmark",
"size": 12,
"style": "solid",
}
}
onPress={[Function]}
testID="clearButton"
>
<Icon
color="#939393"
name="circle-xmark"
size={12}
style="solid"
/>
</TouchableOpacity>
/>
}
textInputComponent={[Function]}
/>
Expand Down Expand Up @@ -652,23 +653,24 @@ exports[`BottomSheetWithSearchInput Rendering With selected item 1`] = `
}
}
rightIcon={
<TouchableOpacity
activeOpacity={0.5}
onPress={[Function]}
style={
<IconButton
Touchable={[Function]}
containerStyle={
{
"paddingRight": 16,
}
}
icon={
{
"color": "#939393",
"name": "circle-xmark",
"size": 12,
"style": "solid",
}
}
onPress={[Function]}
testID="clearButton"
>
<Icon
color="#939393"
name="circle-xmark"
size={12}
style="solid"
/>
</TouchableOpacity>
/>
}
textInputComponent={[Function]}
/>
Expand Down