UNPKG

elephant-com

Version:

the general component for elephant washing shoes

22 lines (19 loc) 611 B
import React from 'react'; import { TouchableOpacity } from 'react-native'; import { Flex, Icon } from 'antd-mobile'; import _ from 'lodash'; const fill = '\ue660'; const unfill = '\ue661'; /* eslint-disable no-undef */ export default Rating = ({ stars = 0, color = '#f00', size = 20, total = 5, onChange, style }) => { return (<Flex style={style}> { _.range(total).map(i => <TouchableOpacity key={i} onPress={() => onChange && onChange(i + 1)} > <Icon type={i + 1 > stars ? unfill : fill} color={color} size={size} /> </TouchableOpacity>) } </Flex>); };