aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/atoms/loaders/spinner/spinner.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/atoms/loaders/spinner/spinner.tsx')
-rw-r--r--src/components/atoms/loaders/spinner/spinner.tsx42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/components/atoms/loaders/spinner/spinner.tsx b/src/components/atoms/loaders/spinner/spinner.tsx
new file mode 100644
index 0000000..6c6c23c
--- /dev/null
+++ b/src/components/atoms/loaders/spinner/spinner.tsx
@@ -0,0 +1,42 @@
+import type { FC, HTMLAttributes, ReactNode } from 'react';
+import type { Position } from '../../../../types';
+import styles from './spinner.module.scss';
+
+export type SpinnerProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
+ /**
+ * The loading message.
+ */
+ children?: ReactNode;
+ /**
+ * Define the position of the loading message if any.
+ *
+ * @default 'right'
+ */
+ position?: Exclude<Position, 'center'>;
+};
+
+/**
+ * Spinner component
+ *
+ * Render a loading message with animation.
+ */
+export const Spinner: FC<SpinnerProps> = ({
+ children,
+ className = '',
+ position = 'right',
+ ...props
+}) => {
+ const positionClass = styles[`wrapper--${position}`];
+ const wrapperClass = `${styles.wrapper} ${positionClass} ${className}`;
+
+ return (
+ <div {...props} className={wrapperClass}>
+ <div aria-hidden className={styles.icon}>
+ <div className={styles.icon__ball} />
+ <div className={styles.icon__ball} />
+ <div className={styles.icon__ball} />
+ </div>
+ <div className={styles.body}>{children}</div>
+ </div>
+ );
+};