Farmbot-Web-App/frontend/devices/components/hardware_settings/single_setting_row.tsx

33 lines
1.1 KiB
TypeScript
Raw Normal View History

2020-02-15 11:29:09 -07:00
import * as React from "react";
import { Row, Col, Help } from "../../../ui/index";
import { Position } from "@blueprintjs/core";
2020-02-18 12:21:09 -07:00
import { DeviceSetting } from "../../../constants";
import { Highlight } from "../maybe_highlight";
import { t } from "../../../i18next_wrapper";
2020-03-13 15:06:40 -06:00
import { DevSettings } from "../../../account/dev/dev_support";
2020-02-18 12:21:09 -07:00
export interface SingleSettingRowProps {
label: DeviceSetting;
tooltip: string;
children: React.ReactChild;
settingType: "button" | "input";
}
2020-02-15 11:29:09 -07:00
export const SingleSettingRow =
2020-03-13 15:06:40 -06:00
({ label, tooltip, settingType, children }: SingleSettingRowProps) => {
const newFormat = DevSettings.futureFeaturesEnabled();
return <Highlight settingName={label}>
<Row>
<Col xs={newFormat ? 12 : 6} className={"widget-body-tooltips"}>
2020-02-18 12:21:09 -07:00
<label>{t(label)}</label>
2020-03-13 15:06:40 -06:00
<Help text={tooltip} requireClick={true} position={Position.TOP_RIGHT} />
2020-02-18 12:21:09 -07:00
</Col>
{settingType === "button"
2020-03-13 15:06:40 -06:00
? <Col xs={newFormat ? 5 : 2} className={"centered-button-div"}>
{children}
</Col>
: <Col xs={newFormat ? 8 : 6}>{children}</Col>}
</Row>
</Highlight>;
};