@td-design/react-native
Version:
react-native UI组件库
40 lines • 1.06 kB
JavaScript
import React, { useMemo } from 'react';
import helpers from '../helpers';
import UIActivityIndicator from '../indicator/UIActivityIndicator';
import Pressable from '../pressable';
import Text from '../text';
import useButton from './useButton';
const {
px
} = helpers;
const Button = props => {
const {
loading,
title
} = props;
const {
pressableProps,
textColor,
variant,
indicatorColor,
loadingIconSize
} = useButton(props);
const Title = useMemo(() => {
if (typeof title === 'string') return /*#__PURE__*/React.createElement(Text, {
variant: variant,
color: textColor
}, title);
return title;
}, [title, textColor, variant]);
return /*#__PURE__*/React.createElement(Pressable, pressableProps, !!loading && /*#__PURE__*/React.createElement(UIActivityIndicator, {
color: indicatorColor,
size: loadingIconSize,
animating: loading,
style: {
marginRight: px(4)
}
}), Title);
};
Button.displayName = 'Button';
export default Button;
//# sourceMappingURL=index.js.map