From 2d5d015d23409b456e36a0370466ee42aa47631f Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Thu, 7 Apr 2022 11:58:33 +0200
Subject: chore: add a MotionToggle component

---
 src/components/molecules/forms/motion-toggle.tsx | 50 ++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 src/components/molecules/forms/motion-toggle.tsx

(limited to 'src/components/molecules/forms/motion-toggle.tsx')

diff --git a/src/components/molecules/forms/motion-toggle.tsx b/src/components/molecules/forms/motion-toggle.tsx
new file mode 100644
index 0000000..77291ed
--- /dev/null
+++ b/src/components/molecules/forms/motion-toggle.tsx
@@ -0,0 +1,50 @@
+import Toggle, {
+  ToggleChoices,
+  ToggleProps,
+} from '@components/atoms/forms/toggle';
+import { FC, useState } from 'react';
+import { useIntl } from 'react-intl';
+
+export type MotionToggleProps = Pick<ToggleProps, 'value'>;
+
+/**
+ * MotionToggle component
+ *
+ * Render a Toggle component to set reduce motion.
+ */
+const MotionToggle: FC<MotionToggleProps> = ({ value }) => {
+  const intl = useIntl();
+  const [isDeactivated, setIsDeactivated] = useState<boolean>(value);
+  const reduceMotionLabel = intl.formatMessage({
+    defaultMessage: 'Animations:',
+    description: 'MotionToggle: reduce motion label',
+    id: '/q5csZ',
+  });
+  const onLabel = intl.formatMessage({
+    defaultMessage: 'On',
+    description: 'MotionToggle: activate reduce motion label',
+    id: 'va65iw',
+  });
+  const offLabel = intl.formatMessage({
+    defaultMessage: 'Off',
+    description: 'MotionToggle: deactivate reduce motion label',
+    id: 'pWKyyR',
+  });
+  const reduceMotionChoices: ToggleChoices = {
+    left: onLabel,
+    right: offLabel,
+  };
+
+  return (
+    <Toggle
+      id="reduce-motion-settings"
+      name="reduce-motion-settings"
+      label={reduceMotionLabel}
+      choices={reduceMotionChoices}
+      value={isDeactivated}
+      setValue={setIsDeactivated}
+    />
+  );
+};
+
+export default MotionToggle;
-- 
cgit v1.2.3

