2019-10-31 05:28:11 +00:00
|
|
|
import * as React from "react";
|
|
|
|
|
import { Text, Classes } from "@blueprintjs/core";
|
|
|
|
|
import styled from "styled-components";
|
|
|
|
|
import { ComponentProps } from "../appsmith/BaseComponent";
|
2019-11-05 05:09:50 +00:00
|
|
|
import { TextStyle } from "../../../widgets/TextWidget";
|
2019-10-31 05:28:11 +00:00
|
|
|
|
|
|
|
|
type TextStyleProps = {
|
|
|
|
|
styleName: "primary" | "secondary" | "error";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export const BaseText = styled(Text)<TextStyleProps>``;
|
|
|
|
|
|
|
|
|
|
export interface TextComponentProps extends ComponentProps {
|
|
|
|
|
text?: string;
|
|
|
|
|
ellipsize?: boolean;
|
|
|
|
|
textStyle?: TextStyle;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class TextComponent extends React.Component<TextComponentProps> {
|
|
|
|
|
getTextClass(textStyle?: TextStyle) {
|
|
|
|
|
switch (textStyle) {
|
|
|
|
|
case "HEADING":
|
|
|
|
|
return Classes.TEXT_LARGE;
|
|
|
|
|
case "LABEL":
|
|
|
|
|
return undefined;
|
|
|
|
|
case "BODY":
|
|
|
|
|
return Classes.TEXT_SMALL;
|
|
|
|
|
default:
|
|
|
|
|
return undefined;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
return (
|
2019-11-13 07:00:25 +00:00
|
|
|
<Text
|
|
|
|
|
className={this.getTextClass(this.props.textStyle)}
|
|
|
|
|
ellipsize={this.props.ellipsize}
|
|
|
|
|
>
|
|
|
|
|
{this.props.text}
|
|
|
|
|
</Text>
|
2019-10-31 05:28:11 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default TextComponent;
|