From b3ac82bba9605fa9d9c4b1d29c5a56a52e9de015 Mon Sep 17 00:00:00 2001
From: Armand Philippot <git@armandphilippot.com>
Date: Fri, 15 Apr 2022 17:38:16 +0200
Subject: chore: add a SocialMedia component

---
 src/components/organisms/widgets/social-media.tsx | 41 +++++++++++++++++++++++
 1 file changed, 41 insertions(+)
 create mode 100644 src/components/organisms/widgets/social-media.tsx

(limited to 'src/components/organisms/widgets/social-media.tsx')

diff --git a/src/components/organisms/widgets/social-media.tsx b/src/components/organisms/widgets/social-media.tsx
new file mode 100644
index 0000000..58b2f73
--- /dev/null
+++ b/src/components/organisms/widgets/social-media.tsx
@@ -0,0 +1,41 @@
+import SocialLink, {
+  type SocialLinkProps,
+} from '@components/atoms/links/social-link';
+import Widget, { type WidgetProps } from '@components/molecules/layout/widget';
+import { FC } from 'react';
+import styles from './social-media.module.scss';
+
+export type Media = SocialLinkProps;
+
+export type SocialMediaProps = Pick<WidgetProps, 'level' | 'title'> & {
+  media: Media[];
+};
+
+/**
+ * Social Media widget component
+ *
+ * Render a social media list with links.
+ */
+const SocialMedia: FC<SocialMediaProps> = ({ media, ...props }) => {
+  /**
+   * Retrieve the social media items.
+   *
+   * @param {SocialMedia[]} links - An array of social media name and url.
+   * @returns {JSX.Element[]} The social links.
+   */
+  const getItems = (links: Media[]): JSX.Element[] => {
+    return links.map((link, index) => (
+      <li key={`media-${index}`}>
+        <SocialLink name={link.name} url={link.url} />
+      </li>
+    ));
+  };
+
+  return (
+    <Widget expanded={true} {...props}>
+      <ul className={styles.list}>{getItems(media)}</ul>
+    </Widget>
+  );
+};
+
+export default SocialMedia;
-- 
cgit v1.2.3

