@td-design/react-native
Version:
react-native UI组件库
50 lines • 1.32 kB
JavaScript
import React, { memo } from 'react';
import { useTheme } from '@shopify/restyle';
import Flex from '../flex';
import Text from '../text';
const Label = /*#__PURE__*/memo(_ref => {
let {
colon,
label,
required,
labelHeight
} = _ref;
const theme = useTheme();
const style = {};
if (labelHeight) {
Object.assign(style, {
height: labelHeight
});
} else {
Object.assign(style, {
paddingVertical: theme.spacing.x2
});
}
if (!label) return null;
if (typeof label === 'string') return /*#__PURE__*/React.createElement(Flex, {
marginRight: "x2",
alignItems: "center",
style: style
}, required && /*#__PURE__*/React.createElement(Text, {
variant: "p1",
color: "func600"
}, "*"), /*#__PURE__*/React.createElement(Text, {
variant: "p1",
color: "text"
}, label), /*#__PURE__*/React.createElement(Text, {
variant: "p1",
color: "text"
}, colon ? ':' : ''));
return /*#__PURE__*/React.createElement(Flex, {
marginRight: "x2",
style: style
}, required && /*#__PURE__*/React.createElement(Text, {
variant: "p1",
color: "func600"
}, "*"), label, /*#__PURE__*/React.createElement(Text, {
variant: "p1",
color: "text"
}, colon ? ':' : ''));
});
export default Label;
//# sourceMappingURL=index.js.map