123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- import * as React from "react";
- interface ITextLineComponentProps {
- label?: string;
- value?: string;
- color?: string;
- underline?: boolean;
- onLink?: () => void;
- url?: string;
- ignoreValue?: boolean;
- additionalClass?: string;
- }
- export class TextLineComponent extends React.Component<ITextLineComponentProps> {
- constructor(props: ITextLineComponentProps) {
- super(props);
- }
- onLink() {
- if (this.props.url) {
- window.open(this.props.url, '_blank');
- return;
- }
- if (!this.props.onLink) {
- return;
- }
- this.props.onLink();
- }
- renderContent() {
- if (this.props.ignoreValue) {
- return null;
- }
- if (this.props.onLink || this.props.url) {
- return (
- <div className="link-value" title={this.props.value} onClick={() => this.onLink()}>
- {this.props.url ? "doc" : (this.props.value || "no name")}
- </div>
- )
- }
- return (
- <div className="value" title={this.props.value} style={{ color: this.props.color ? this.props.color : "" }}>
- {this.props.value || "no name"}
- </div>
- )
- }
- render() {
- return (
- <div className={this.props.underline ? "textLine underline" : "textLine" + (this.props.additionalClass ? " " + this.props.additionalClass : "")}>
- <div className="label" title={this.props.label ?? ""}>
- {this.props.label ?? ""}
- </div>
- {this.renderContent()}
- </div>
- );
- }
- }
|