Create SwitchField component
authorMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Thu, 27 Dec 2018 14:56:06 +0000 (15:56 +0100)
committerMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Thu, 27 Dec 2018 14:56:06 +0000 (15:56 +0100)
Feature #13708

Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski@contractors.roche.com>

src/components/switch-field/switch-field.tsx [new file with mode: 0644]

diff --git a/src/components/switch-field/switch-field.tsx b/src/components/switch-field/switch-field.tsx
new file mode 100644 (file)
index 0000000..4541e37
--- /dev/null
@@ -0,0 +1,14 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import { FormFieldProps, FormField } from '~/components/form-field/form-field';
+import { Switch } from '@material-ui/core';
+import { SwitchProps } from '@material-ui/core/Switch';
+
+export const SwitchField = ({ switchProps, ...props }: FormFieldProps & { switchProps: SwitchProps }) =>
+    <FormField {...props}>
+        {input => <Switch {...switchProps} checked={input.checked} onChange={input.onChange} />}
+    </FormField>;
+