tooot/src/components/Icon.tsx

56 lines
1.2 KiB
TypeScript
Raw Normal View History

import FeatherNames from '@expo/vector-icons/build/vendor/react-native-vector-icons/glyphmaps/Feather.json'
import Feather from '@expo/vector-icons/Feather'
import React from 'react'
2021-04-09 21:43:12 +02:00
import { AccessibilityProps, StyleProp, View, ViewStyle } from 'react-native'
export type IconName = keyof typeof FeatherNames
export interface Props {
2021-04-09 21:43:12 +02:00
accessibilityLabel?: AccessibilityProps['accessibilityLabel']
name: IconName
size: number
color: string
style?: StyleProp<ViewStyle>
2022-12-14 23:37:41 +01:00
crossOut?: boolean
}
const Icon: React.FC<Props> = ({
2021-04-09 21:43:12 +02:00
accessibilityLabel,
name,
size,
color,
2022-12-14 23:37:41 +01:00
style,
crossOut = false
}) => {
return (
<View
2021-04-09 21:43:12 +02:00
accessibilityLabel={accessibilityLabel}
style={[
style,
{
width: size,
height: size,
justifyContent: 'center',
2021-01-04 14:55:34 +01:00
alignItems: 'center'
}
]}
>
<Feather name={name} size={size} color={color} />
2022-12-14 23:37:41 +01:00
{crossOut ? (
<View
style={{
position: 'absolute',
transform: [{ rotate: '45deg' }],
width: size * 1.35,
borderBottomColor: color,
borderBottomWidth: 2
2022-12-14 23:37:41 +01:00
}}
/>
) : null}
</View>
)
}
export default Icon