From 0e52a59917406ad03c174e030c6c1c92ab23449d Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Mon, 30 Oct 2023 12:44:11 +0100
Subject: refactor(components): extract SettingsForm component form
 SettingsModal

We could use an array of items and map over it instead of repeating the
Switch component for each settings but with translations, it becomes
quickly unreadable. So I prefer to keep separate components.
---
 .../forms/settings-form/settings-form.tsx          | 31 ++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 src/components/organisms/forms/settings-form/settings-form.tsx

(limited to 'src/components/organisms/forms/settings-form/settings-form.tsx')

diff --git a/src/components/organisms/forms/settings-form/settings-form.tsx b/src/components/organisms/forms/settings-form/settings-form.tsx
new file mode 100644
index 0000000..117665d
--- /dev/null
+++ b/src/components/organisms/forms/settings-form/settings-form.tsx
@@ -0,0 +1,31 @@
+import { type ForwardRefRenderFunction, forwardRef } from 'react';
+import { Form, type FormProps } from '../../../atoms';
+import { AckeeToggle } from './ackee-toggle';
+import { MotionToggle } from './motion-toggle';
+import { PrismThemeToggle } from './prism-theme-toggle';
+import styles from './settings-form.module.scss';
+import { ThemeToggle } from './theme-toggle';
+
+export type SettingsFormProps = Omit<FormProps, 'children'>;
+
+const SettingsFormWithRef: ForwardRefRenderFunction<
+  HTMLFormElement,
+  SettingsFormProps
+> = ({ className = '', ...props }, ref) => {
+  const formClass = `${styles.form} ${className}`;
+
+  return (
+    <Form {...props} className={formClass} ref={ref}>
+      <ThemeToggle className={styles.item} />
+      <PrismThemeToggle className={styles.item} />
+      <MotionToggle className={styles.item} />
+      <AckeeToggle
+        className={styles.item}
+        // eslint-disable-next-line react/jsx-no-literals
+        direction="upwards"
+      />
+    </Form>
+  );
+};
+
+export const SettingsForm = forwardRef(SettingsFormWithRef);
-- 
cgit v1.2.3

