grommet
Version:
focus on the essential experience
54 lines (50 loc) • 1.76 kB
JavaScript
import styled, { css } from 'styled-components';
import { genericStyles, normalizeColor } from '../../utils';
import { defaultProps } from '../../default-props';
var sizeStyle = function sizeStyle(props) {
var size = props.size || 'medium';
var data = props.theme.text[size];
if (data) {
return css(["font-size:", ";line-height:", ";"], data.size, data.height);
}
return css(["font-size:", ";line-height:normal;"], size);
};
var TEXT_ALIGN_MAP = {
center: 'center',
end: 'right',
start: 'left'
};
var textAlignStyle = css(["text-align:", ";"], function (props) {
return TEXT_ALIGN_MAP[props.textAlign];
});
var truncateStyle = "\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n";
var colorStyle = css(["color:", ";"], function (props) {
return normalizeColor(props.colorProp, props.theme);
});
var weightStyle = css(["font-weight:", ";"], function (props) {
return props.weight;
});
var wordBreakStyle = css(["word-break:", ";"], function (props) {
return props.wordBreak;
});
var StyledText = styled.span.withConfig({
displayName: "StyledText",
componentId: "sc-1sadyjn-0"
})(["", " ", " ", " ", " ", " ", " ", " ", ""], genericStyles, function (props) {
return sizeStyle(props);
}, function (props) {
return props.textAlign && textAlignStyle;
}, function (props) {
return props.truncate && truncateStyle;
}, function (props) {
return props.colorProp && colorStyle;
}, function (props) {
return props.weight && weightStyle;
}, function (props) {
return props.wordBreak && wordBreakStyle;
}, function (props) {
return props.theme.text && props.theme.text.extend;
});
StyledText.defaultProps = {};
Object.setPrototypeOf(StyledText.defaultProps, defaultProps);
export { StyledText };