tooot/src/components/Icon.tsx

50 lines
937 B
TypeScript
Raw Normal View History

import React, { createElement } from 'react'
2021-04-09 21:43:12 +02:00
import { AccessibilityProps, StyleProp, View, ViewStyle } from 'react-native'
import * as FeatherIcon from 'react-native-feather'
export interface Props {
2021-04-09 21:43:12 +02:00
accessibilityLabel?: AccessibilityProps['accessibilityLabel']
name: string
size: number
color: string
fill?: string
strokeWidth?: number
style?: StyleProp<ViewStyle>
}
const Icon: React.FC<Props> = ({
2021-04-09 21:43:12 +02:00
accessibilityLabel,
name,
size,
color,
fill,
strokeWidth = 2,
style
}) => {
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'
}
]}
>
{createElement(FeatherIcon[name], {
width: size,
height: size,
color,
fill,
strokeWidth
})}
</View>
)
}
export default Icon