Farmbot-Web-App/frontend/controls/key_val_show_row.tsx

38 lines
999 B
TypeScript
Raw Normal View History

import * as React from "react";
import { Row, Col } from "../ui/index";
import { ToggleButton } from "./toggle_button";
2019-04-02 13:59:37 -06:00
import { t } from "../i18next_wrapper";
export interface KeyValRowProps {
label: string;
labelPlaceholder: string;
value: string;
valuePlaceholder: string;
onClick(): void;
disabled: boolean;
2017-09-20 17:56:41 -06:00
toggleValue?: number | undefined;
2018-12-03 20:05:45 -07:00
title?: string;
}
2018-12-18 11:25:17 -07:00
/** A row containing a label, value, and toggle button. Useful for maintaining
* lists of things (peripherals, feeds, tools etc). */
export function KeyValShowRow(p: KeyValRowProps) {
2018-12-03 20:05:45 -07:00
const { label, value, toggleValue, disabled, onClick, title } = p;
return <Row>
<Col xs={4}>
<label>{label}</label>
</Col>
<Col xs={4}>
2017-09-20 17:56:41 -06:00
<p>{value}</p>
</Col>
<Col xs={4}>
<ToggleButton
2017-09-20 17:56:41 -06:00
toggleValue={toggleValue}
toggleAction={onClick}
2018-12-03 20:05:45 -07:00
title={title}
2018-03-13 21:55:15 -06:00
customText={{ textFalse: t("off"), textTrue: t("on") }}
disabled={disabled} />
</Col>
</Row>;
}