diff --git a/app/src/frontend/building/data-components/logical-data-entry/logical-data-entry.tsx b/app/src/frontend/building/data-components/logical-data-entry/logical-data-entry.tsx new file mode 100644 index 00000000..36f87dea --- /dev/null +++ b/app/src/frontend/building/data-components/logical-data-entry/logical-data-entry.tsx @@ -0,0 +1,100 @@ +import React from 'react'; + +import { BaseDataEntryProps } from '../data-entry'; +import { DataTitleCopyable } from '../data-title'; + +interface ToggleButtonProps { + value: string; + checked: boolean; + disabled: boolean; + onChange: React.ChangeEventHandler; + checkedClassName: string; + uncheckedClassName: string; +} + +const ToggleButton: React.FC = ({ + value, + checked, + disabled, + onChange, + checkedClassName, + uncheckedClassName, + children +}) => { + + return ( + /** + * If the toggle button is both checked and disabled, we can't set disabled CSS class + * because then Bootstrap makes the button look like it wasn't checked. + * So we skip the class and force cursor type manually so it doesn't look clickable. + */ + + ); +} + +interface LogicalDataEntryProps extends BaseDataEntryProps { + value: boolean; + disallowTrue?: boolean; + disallowFalse?: boolean; + disallowNull?: boolean; +} + +export const LogicalDataEntry: React.FC = (props) => { + function handleValueChange(e: React.ChangeEvent) { + props.onChange?.(props.slug, e.target.value === 'null' ? null : e.target.value === 'true'); + } + + const isDisabled = props.mode === 'view' || props.disabled; + + return ( + <> + +
+ Yes + + ? + + No +
+ + ); +};